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
September 2012
- 3 participants
- 44 discussions
r3703 - in trunk/pollen-services/src: main/java/org/chorem/pollen/services main/java/org/chorem/pollen/services/impl test/java/org/chorem/pollen/services
by tchemit@users.chorem.org 23 Sep '12
by tchemit@users.chorem.org 23 Sep '12
23 Sep '12
Author: tchemit
Date: 2012-09-23 16:36:50 +0200 (Sun, 23 Sep 2012)
New Revision: 3703
Url: http://chorem.org/repositories/revision/pollen/3703
Log:
service context is reponsible of generating id (to mock it in test later)
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
trunk/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2012-09-23 13:48:42 UTC (rev 3702)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/DefaultPollenServiceContext.java 2012-09-23 14:36:50 UTC (rev 3703)
@@ -30,6 +30,7 @@
import java.net.URL;
import java.util.Date;
import java.util.Locale;
+import java.util.UUID;
/**
* Instances of this class will be given to service factory.
@@ -137,4 +138,9 @@
public VoteCountingStrategyProvider getVoteCountingStrategyProvider() {
return voteCountingStrategyProvider;
}
+
+ @Override
+ public String generateId() {
+ return UUID.randomUUID().toString().replaceAll("-", "");
+ }
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2012-09-23 13:48:42 UTC (rev 3702)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceContext.java 2012-09-23 14:36:50 UTC (rev 3703)
@@ -24,6 +24,8 @@
package org.chorem.pollen.services;
import org.chorem.pollen.PollenConfiguration;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.votecounting.strategy.VoteCountingStrategyProvider;
import org.nuiton.topia.TopiaContext;
@@ -62,4 +64,13 @@
VoteCountingStrategyProvider getVoteCountingStrategyProvider();
+ /**
+ * Generates a unique id usable for {@link Poll#getPollId()} or
+ * {@link PollAccount#getAccountId()}.
+ *
+ * @return a fresh generated id
+ * @since 1.5
+ */
+ String generateId();
+
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-09-23 13:48:42 UTC (rev 3702)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-09-23 14:36:50 UTC (rev 3703)
@@ -26,8 +26,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.entities.PollenDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -39,7 +37,6 @@
import java.util.Date;
import java.util.List;
import java.util.Locale;
-import java.util.UUID;
import static org.nuiton.i18n.I18n.l_;
@@ -154,6 +151,7 @@
throw new PollenTechnicalException("Could not create entity ", e);
}
}
+
protected <T extends TopiaEntity, D extends TopiaDAO<? super T>> T createWithProperties(D dao, Object... properties) {
try {
return (T) dao.create(properties);
@@ -195,15 +193,4 @@
tx.getHibernate().flush();
}
- /**
- * Generates a unique id usable for {@link Poll#getPollId()} or
- * {@link PollAccount#getAccountId()}.
- *
- * @return a fresh generated id
- * @since 1.4
- */
- protected String generateId() {
- return UUID.randomUUID().toString().replaceAll("-", "");
- }
-
}
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-09-23 13:48:42 UTC (rev 3702)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-09-23 14:36:50 UTC (rev 3703)
@@ -283,7 +283,7 @@
PollDAO pollDAO = getDAO(Poll.class);
Poll result = createWithProperties(
pollDAO,
- Poll.PROPERTY_POLL_ID, generateId(),
+ Poll.PROPERTY_POLL_ID, serviceContext.generateId(),
Poll.PROPERTY_POLL_VOTE_VISIBILITY, poll.getPollVoteVisibility(),
Poll.PROPERTY_POLL_COMMENT_VISIBILITY, poll.getPollCommentVisibility());
@@ -315,7 +315,7 @@
PollAccountDAO pollAccountDAO = getDAO(PollAccount.class);
PollAccount creatorCreated = createWithProperties(
pollAccountDAO,
- PollAccount.PROPERTY_ACCOUNT_ID, generateId());
+ PollAccount.PROPERTY_ACCOUNT_ID, serviceContext.generateId());
PollAccount creator = poll.getCreator();
creatorCreated.setVotingId(creator.getVotingId());
creatorCreated.setEmail(creator.getEmail());
@@ -937,7 +937,7 @@
// creates a new pollAccount
pollAccountLoaded = createWithProperties(
pollAccountDAO,
- PollAccount.PROPERTY_ACCOUNT_ID, generateId());
+ PollAccount.PROPERTY_ACCOUNT_ID, serviceContext.generateId());
if (log.isInfoEnabled()) {
log.info(String.format(
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java 2012-09-23 13:48:42 UTC (rev 3702)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java 2012-09-23 14:36:50 UTC (rev 3703)
@@ -41,6 +41,7 @@
import java.util.Date;
import java.util.Locale;
import java.util.Properties;
+import java.util.UUID;
/**
* Provide an implementation of {@link PollenServiceContext} suitable for repeatable,
@@ -133,6 +134,11 @@
return null;
}
+ @Override
+ public String generateId() {
+ return UUID.randomUUID().toString().replaceAll("-", "");
+ }
+
public void setCurrentTime(Date fakeCurrentTime) {
this.fakeCurrentTime = fakeCurrentTime;
}
1
0
r3702 - in trunk/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/json resources resources/config webapp/WEB-INF/jsp/admin webapp/WEB-INF/jsp/user webapp/js
by tchemit@users.chorem.org 23 Sep '12
by tchemit@users.chorem.org 23 Sep '12
23 Sep '12
Author: tchemit
Date: 2012-09-23 15:48:42 +0200 (Sun, 23 Sep 2012)
New Revision: 3702
Url: http://chorem.org/repositories/revision/pollen/3702
Log:
normalize json actions (all will use a data field
Added:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONSimpleAction.java
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.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/resources/config/struts-json.xml
trunk/pollen-ui-struts2/src/main/resources/struts.xml
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/pollsList.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/invitedList.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp
trunk/pollen-ui-struts2/src/main/webapp/js/favoriteList.js
trunk/pollen-ui-struts2/src/main/webapp/js/usersList.js
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONPaginedAction.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -28,6 +28,8 @@
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.topia.persistence.pager.TopiaPagerBean;
+import java.util.Map;
+
/**
* Abstract JSON action with pagination support.
*
@@ -38,6 +40,8 @@
private static final long serialVersionUID = 1L;
+ public abstract Map<String, Object>[] getData();
+
public final Integer getRows() {
return pager.getPageSize();
}
Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONSimpleAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONSimpleAction.java (rev 0)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONSimpleAction.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -0,0 +1,18 @@
+package org.chorem.pollen.ui.actions.json;
+
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+import java.util.Map;
+
+/**
+ * Abstract JSON action for a simple result (one row).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.5
+ */
+public abstract class AbstractJSONSimpleAction extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ public abstract Map<String, Object> getData();
+}
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/AbstractJSONSimpleAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -44,10 +44,11 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] polls;
+ protected transient Map<String, Object>[] data;
- public Map<String, Object>[] getPolls() {
- return polls;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -59,7 +60,7 @@
pager,
getPollenUserAccount());
- polls = new Map[pollList.size()];
+ data = new Map[pollList.size()];
Binder<Poll, Poll> binder =
PollenBinderHelper.getSimpleTopiaBinder(Poll.class);
int index = 0;
@@ -72,7 +73,7 @@
map.put("resultId", poll.getPollId());
map.put("adminId", poll.getAdminId());
map.put("functions", getPollFunctions(poll));
- polls[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -24,7 +24,6 @@
import com.google.common.collect.Maps;
import org.chorem.pollen.business.persistence.PersonList;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
import java.util.Map;
@@ -34,13 +33,13 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class GetFavoriteList extends PollenActionSupport {
+public class GetFavoriteList extends AbstractJSONSimpleAction {
private static final long serialVersionUID = 1L;
private String favoriteListId;
- private transient Map<String, Object> favoriteList;
+ private transient Map<String, Object> data;
public String getFavoriteListId() {
return favoriteListId;
@@ -50,8 +49,9 @@
this.favoriteListId = favoriteListId;
}
- public Map<String, Object> getFavoriteList() {
- return favoriteList;
+ @Override
+ public Map<String, Object> getData() {
+ return data;
}
@Override
@@ -60,9 +60,9 @@
PersonList personList =
getFavoriteService().getEntityById(PersonList.class, favoriteListId);
- favoriteList = Maps.newHashMap();
- favoriteList.put("id", personList.getTopiaId());
- favoriteList.put(PersonList.PROPERTY_NAME, personList.getName());
+ data = Maps.newHashMap();
+ data.put("id", personList.getTopiaId());
+ data.put(PersonList.PROPERTY_NAME, personList.getName());
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -24,7 +24,6 @@
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.beans.Binder;
import java.util.Map;
@@ -35,13 +34,13 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class GetFavoriteListPollAccount extends PollenActionSupport {
+public class GetFavoriteListPollAccount extends AbstractJSONSimpleAction {
private static final long serialVersionUID = 1L;
private String pollAccountId;
- private transient Map<String, Object> pollAccount;
+ private transient Map<String, Object> data;
public String getPollAccountId() {
return pollAccountId;
@@ -51,8 +50,9 @@
this.pollAccountId = pollAccountId;
}
- public Map<String, Object> getPollAccount() {
- return pollAccount;
+ @Override
+ public Map<String, Object> getData() {
+ return data;
}
@Override
@@ -63,12 +63,12 @@
Binder<PollAccount, PollAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class);
- pollAccount = binder.obtainProperties(
+ data = binder.obtainProperties(
userAccount,
PollAccount.PROPERTY_VOTING_ID,
PollAccount.PROPERTY_EMAIL
);
- pollAccount.put("id", userAccount.getTopiaId());
+ data.put("id", userAccount.getTopiaId());
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -41,12 +41,13 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] pollAccounts;
+ protected transient Map<String, Object>[] data;
protected String favoriteListId;
- public Map<String, Object>[] getPollAccounts() {
- return pollAccounts;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
public String getFavoriteListId() {
@@ -69,7 +70,7 @@
favoriteList,
pager);
- pollAccounts = new Map[allPollAccounts.size()];
+ data = new Map[allPollAccounts.size()];
Binder<PollAccount, PollAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class);
int index = 0;
@@ -80,7 +81,7 @@
PollAccount.PROPERTY_EMAIL
);
map.put("id", pollAccount.getTopiaId());
- pollAccounts[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -38,10 +38,11 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] favoriteLists;
+ protected transient Map<String, Object>[] data;
- public Map<String, Object>[] getFavoriteLists() {
- return favoriteLists;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -51,14 +52,14 @@
getPollenUserAccount(),
pager);
- favoriteLists = new Map[allFavoriteLists.size()];
+ data = new Map[allFavoriteLists.size()];
int index = 0;
for (PersonList favoriteList : allFavoriteLists) {
Map<String, Object> map = Maps.newHashMap();
map.put(PersonList.PROPERTY_NAME, favoriteList.getName());
map.put("id", favoriteList.getTopiaId());
map.put("nbAccounts", favoriteList.sizePollAccount());
- favoriteLists[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -47,10 +47,11 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] polls;
+ protected transient Map<String, Object>[] data;
- public Map<String, Object>[] getPolls() {
- return polls;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -61,7 +62,7 @@
List<Pair<Poll, PollAccount>> invitedPolls =
pollService.getInvitedPolls(pager, getPollenUserAccount());
- polls = new Map[invitedPolls.size()];
+ data = new Map[invitedPolls.size()];
Binder<Poll, Poll> binder =
PollenBinderHelper.getSimpleTopiaBinder(Poll.class);
int index = 0;
@@ -81,7 +82,7 @@
Set<String> functions = getPollFunctions(poll, pollUri);
map.put("functions", functions);
- polls[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -47,10 +47,11 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] polls;
+ protected transient Map<String, Object>[] data;
- public Map<String, Object>[] getPolls() {
- return polls;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -61,7 +62,7 @@
List<Pair<Poll, PollAccount>> participatedPolls =
pollService.getParticipatedPolls(pager, getPollenUserAccount());
- polls = new Map[participatedPolls.size()];
+ data = new Map[participatedPolls.size()];
Binder<Poll, Poll> binder =
PollenBinderHelper.getSimpleTopiaBinder(Poll.class);
int index = 0;
@@ -87,7 +88,7 @@
Set<String> functions = getPollFunctions(poll, pollUri);
map.put("functions", functions);
- polls[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] comments;
+ protected transient Map<String, Object>[] data;
protected String pollId;
@@ -52,8 +52,9 @@
this.pollId = pollId;
}
- public Map<String, Object>[] getComments() {
- return comments;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -71,7 +72,7 @@
getPollenUserAccount(), pollId, null, poll);
securityContext.loadUserRoles(getSecurityService());
- comments = new Map[commentList.size()];
+ data = new Map[commentList.size()];
Binder<Comment, Comment> binder =
PollenBinderHelper.getSimpleTopiaBinder(Comment.class);
int index = 0;
@@ -88,7 +89,7 @@
comment,
securityContext);
map.put("functions", functions);
- comments[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -41,10 +41,11 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] polls;
+ protected transient Map<String, Object>[] data;
- public Map<String, Object>[] getPolls() {
- return polls;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -54,7 +55,7 @@
List<Poll> pollList = pollService.getPolls(pager);
- polls = new Map[pollList.size()];
+ data = new Map[pollList.size()];
Binder<Poll, Poll> binder =
PollenBinderHelper.getSimpleTopiaBinder(Poll.class);
int index = 0;
@@ -64,7 +65,7 @@
map.put("adminId", poll.getAdminId());
map.put("functions", Sets.newHashSet("summary"));
- polls[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -24,7 +24,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.beans.Binder;
import java.util.Map;
@@ -35,13 +34,13 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class GetUser extends PollenActionSupport {
+public class GetUser extends AbstractJSONSimpleAction {
private static final long serialVersionUID = 1L;
private String userId;
- private transient Map<String, Object> user;
+ private transient Map<String, Object> data;
public String getUserId() {
return userId;
@@ -51,8 +50,9 @@
this.userId = userId;
}
- public Map<String, Object> getUser() {
- return user;
+ @Override
+ public Map<String, Object> getData() {
+ return data;
}
@Override
@@ -63,10 +63,8 @@
Binder<UserAccount, UserAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class);
- user = binder.obtainProperties(
- userAccount
- );
- user.put("id", userAccount.getTopiaId());
+ data = binder.obtainProperties(userAccount);
+ data.put("id", userAccount.getTopiaId());
return SUCCESS;
}
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-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-09-23 13:48:42 UTC (rev 3702)
@@ -41,10 +41,11 @@
private static final long serialVersionUID = 1L;
- protected transient Map<String, Object>[] users;
+ protected transient Map<String, Object>[] data;
- public Map<String, Object>[] getUsers() {
- return users;
+ @Override
+ public Map<String, Object>[] getData() {
+ return data;
}
@Override
@@ -53,7 +54,7 @@
List<UserAccount> allUsers = getUserService().getUsers(pager);
UserAccount userAccount = getPollenUserAccount();
- users = new Map[allUsers.size()];
+ data = new Map[allUsers.size()];
Binder<UserAccount, UserAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class);
int index = 0;
@@ -65,7 +66,7 @@
Set<String> functions = getUserFunctions(userAccount, user);
map.put("functions", functions);
- users[index++] = map;
+ data[index++] = map;
}
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-json.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-09-23 13:48:42 UTC (rev 3702)
@@ -28,7 +28,8 @@
<package name="json" extends="default" namespace="/json">
- <action name="get*" class="org.chorem.pollen.ui.actions.json.Get{1}">
+ <action name="get*" class="org.chorem.pollen.ui.actions.json.Get{1}"
+ method="execute">
<interceptor-ref name="pollenBasicStack"/>
<result type="json"/>
</action>
Modified: trunk/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/struts.xml 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/resources/struts.xml 2012-09-23 13:48:42 UTC (rev 3702)
@@ -44,13 +44,13 @@
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.devMode" value="false"/>
- <bean class="org.chorem.pollen.services.PollenServiceFactory" />
+ <bean class="org.chorem.pollen.services.PollenServiceFactory"/>
<!--Performance tuning-->
<!--see http://struts.apache.org/2.2.3/docs/performance-tuning.html-->
<constant name="struts.freemarker.templatesCache" value="true"/>
- <package name="default" extends="json-default" namespace="/">
+ <package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="redirectToHome"
@@ -67,6 +67,14 @@
<param name="location">${redirectUrl}</param>
<param name="prependServletContext">false</param>
</result-type>
+
+ <result-type name="json" class="org.apache.struts2.json.JSONResult">
+ <param name="includeProperties">
+ rows,page,total,records,data,data.*,sord,sidx,filters,searchField,searchString,searchOper
+ </param>
+ <param name="ignoreHierarchy">false</param>
+ <!--<param name="defaultEncoding">UTF-8</param>-->
+ </result-type>
</result-types>
<interceptors>
@@ -92,7 +100,9 @@
<interceptor-ref name="multiselect"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
- <param name="excludeParams">dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*</param>
+ <param name="excludeParams">
+ dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*
+ </param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
</interceptor-stack>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/pollsList.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/pollsList.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/pollsList.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -36,7 +36,7 @@
<s:url id="loadUrl" action="getPolls" namespace="/json" escapeAmp="false"/>
-<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
+<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="data"
sortable="true" pager="true" pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -56,7 +56,7 @@
});
</script>
-<sjg:grid id="users" dataType="json" href="%{loadUsers}" gridModel="users"
+<sjg:grid id="users" dataType="json" href="%{loadUsers}" gridModel="data"
sortable="true" pager="true" pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='users-rowSelect' editinline="false"
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -55,7 +55,7 @@
<s:url id="loadUrl" action="getCreatedPolls" namespace="/json"
escapeAmp="false"/>
-<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
+<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="data"
sortable="true" pager="true" pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -71,7 +71,7 @@
</h1>
<sjg:grid id="pollAccounts" dataType="json" href="%{loadPollAccounts}"
- gridModel="pollAccounts" sortable="true" pager="true"
+ gridModel="data" sortable="true" pager="true"
pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='pollAccounts-rowSelect' editinline="false"
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -69,7 +69,7 @@
</div>
</s:set>
<sjg:grid id="favoriteLists" dataType="json" href='%{loadFavoriteLists}'
- gridModel="favoriteLists" sortable="true" pager="true"
+ gridModel="data" sortable="true" pager="true"
pagerButtons="true" pagerInput="true" navigator="true"
rownumbers="false" autowidth="true" viewrecords="true"
onSelectRowTopics='favoriteLists-rowSelect'
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/invitedList.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/invitedList.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/invitedList.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -39,7 +39,7 @@
<s:url id="loadInvitedUrl" action="getInvitedPolls"
namespace="/json" escapeAmp="false"/>
-<sjg:grid dataType="json" href="%{loadInvitedUrl}" gridModel="polls"
+<sjg:grid dataType="json" href="%{loadInvitedUrl}" gridModel="data"
sortable="true" pager="true" pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp 2012-09-23 13:48:42 UTC (rev 3702)
@@ -39,7 +39,7 @@
<s:url id="loadParticipatedUrl" action="getParticipatedPolls"
namespace="/json" escapeAmp="false"/>
-<sjg:grid dataType="json" href="%{loadParticipatedUrl}" gridModel="polls"
+<sjg:grid dataType="json" href="%{loadParticipatedUrl}" gridModel="data"
sortable="true" pager="true" pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
Modified: trunk/pollen-ui-struts2/src/main/webapp/js/favoriteList.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/favoriteList.js 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/favoriteList.js 2012-09-23 13:48:42 UTC (rev 3702)
@@ -80,7 +80,7 @@
jQuery.getJSON(
loadPollActionUrl, { "pollAccountId":id }, function (result) {
- var pollAccount = result.pollAccount;
+ var pollAccount = result.data;
$('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id);
$('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId);
$('#editForm [name="editPollAccount.email"]').val(pollAccount.email);
Modified: trunk/pollen-ui-struts2/src/main/webapp/js/usersList.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/usersList.js 2012-09-23 13:16:05 UTC (rev 3701)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/usersList.js 2012-09-23 13:48:42 UTC (rev 3702)
@@ -89,7 +89,7 @@
jQuery.getJSON(
loadUserUrl, { "userId":id }, function (result) {
- var user = result.user;
+ var user = result.data;
$('#editForm [name="editUser.topiaId"]').val(user.id);
$('#editForm [name="editUser.login"]').val(user.login);
$('#editForm [name="editUser.email"]').val(user.email);
1
0
23 Sep '12
Author: tchemit
Date: 2012-09-23 15:16:05 +0200 (Sun, 23 Sep 2012)
New Revision: 3701
Url: http://chorem.org/repositories/revision/pollen/3701
Log:
optimize dependencies
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-votecounting-api/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-09-23 13:09:29 UTC (rev 3700)
+++ trunk/pollen-persistence/pom.xml 2012-09-23 13:16:05 UTC (rev 3701)
@@ -34,6 +34,10 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
Modified: trunk/pollen-votecounting-api/pom.xml
===================================================================
--- trunk/pollen-votecounting-api/pom.xml 2012-09-23 13:09:29 UTC (rev 3700)
+++ trunk/pollen-votecounting-api/pom.xml 2012-09-23 13:16:05 UTC (rev 3701)
@@ -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>
@@ -18,6 +20,10 @@
<dependencies>
<dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
1
0
23 Sep '12
Author: tchemit
Date: 2012-09-23 15:09:29 +0200 (Sun, 23 Sep 2012)
New Revision: 3700
Url: http://chorem.org/repositories/revision/pollen/3700
Log:
move to version 1.5-SNAPSHOT
Added:
trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_5.java
Removed:
trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4_5_2.java
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java
trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties
trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties
trunk/pollen-persistence/src/main/xmi/pollen.properties
trunk/pollen-services/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java 2012-09-23 13:09:29 UTC (rev 3700)
@@ -1,5 +1,28 @@
package org.chorem.pollen.business.persistence;
+/*
+ * #%L
+ * Pollen :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import org.chorem.pollen.PollenFunctions;
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties
===================================================================
--- trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties 2012-09-23 13:09:29 UTC (rev 3700)
@@ -1,4 +1,7 @@
pollen.application.config=Pollen configuration
+pollen.choiceType.date=Date
+pollen.choiceType.image=Image
+pollen.choiceType.text=Text
pollen.configuration.adminEmail=email for default admin
pollen.configuration.charset=Charset used by Pollen
pollen.configuration.contactEmail=email for contact link
@@ -26,6 +29,9 @@
pollen.configuration.tmpDirectory=Temporary directory (is cleaned at each startup of application)
pollen.pollCommentVisibilty.everybody=Use comments on poll
pollen.pollCommentVisibilty.nobody=No usage of comments on poll
+pollen.pollType.free=Free
+pollen.pollType.group=Group
+pollen.pollType.restricted=Restricted
pollen.pollVoteVisibilty.creatorOnly=Visible for creator
pollen.pollVoteVisibilty.creatorOnly.help=On poll's creator or administrator can see votes
pollen.pollVoteVisibilty.everybody=Public vote
@@ -34,12 +40,6 @@
pollen.pollVoteVisibilty.nobody.help=Poll is anonymous, nobody can see votes
pollen.pollVoteVisibilty.participantOnly=Visible for participant
pollen.pollVoteVisibilty.participantOnly.help=Only poll's participants can see votes
-pollen.choiceType.date=Date
-pollen.choiceType.image=Image
-pollen.choiceType.text=Text
-pollen.pollType.free=Free
-pollen.pollType.group=Group
-pollen.pollType.restricted=Restricted
pollen.voteCountingType.condorcet=Condorcet
pollen.voteCountingType.normal=Normal
pollen.voteCountingType.number=Number
Modified: trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties
===================================================================
--- trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties 2012-09-23 13:09:29 UTC (rev 3700)
@@ -1,4 +1,7 @@
pollen.application.config=Configuration de Pollen
+pollen.choiceType.date=Date
+pollen.choiceType.image=Image
+pollen.choiceType.text=Texte
pollen.configuration.adminEmail=Email de l'utilisateur par défaut (Utilisateur crée lors du premier lancement de pollen)
pollen.configuration.charset=Encoding utilisé par Pollen
pollen.configuration.contactEmail=Email pour le lien Contact
@@ -26,6 +29,9 @@
pollen.configuration.tmpDirectory=Répertoire temporaire (est nettoyé à chaque démarrage de l'application)
pollen.pollCommentVisibilty.everybody=Utiliser les commentaires
pollen.pollCommentVisibilty.nobody=Interdir les commentaires sur le sondage
+pollen.pollType.free=Libre
+pollen.pollType.group=Groupe
+pollen.pollType.restricted=Restreint
pollen.pollVoteVisibilty.creatorOnly=Visible pour le créateur
pollen.pollVoteVisibilty.creatorOnly.help=Seul le créateur ou un administrateur peut voir les votes
pollen.pollVoteVisibilty.everybody=Vote publique
@@ -34,12 +40,6 @@
pollen.pollVoteVisibilty.nobody.help=Le sondage est anonyme, personne ne peut voir les votes
pollen.pollVoteVisibilty.participantOnly=Visible pour les participants
pollen.pollVoteVisibilty.participantOnly.help=Seuls les participants du sondage peuvent voir les votes
-pollen.choiceType.date=Date
-pollen.choiceType.image=Image
-pollen.choiceType.text=Texte
-pollen.pollType.free=Libre
-pollen.pollType.group=Groupe
-pollen.pollType.restricted=Restreint
pollen.voteCountingType.condorcet=Condorcet
pollen.voteCountingType.normal=Normal
pollen.voteCountingType.number=Nombre
Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-persistence/src/main/xmi/pollen.properties 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2012-09-23 13:09:29 UTC (rev 3700)
@@ -24,7 +24,7 @@
#model.tagvalue.dbSchema=Pollen
model.tagvalue.constantPrefix=PROPERTY_
model.tagvalue.java.lang.String=text
-model.tagvalue.version=1.4.5.2
+model.tagvalue.version=1.5
model.tagvalue.doNotGenerateBooleanGetMethods=true
model.tagvalue.indexForeignKeys=true
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4_5_2.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4_5_2.java 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4_5_2.java 2012-09-23 13:09:29 UTC (rev 3700)
@@ -1,195 +0,0 @@
-package org.chorem.pollen.entities.migration;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-import com.opensymphony.xwork2.ActionContext;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.PollenApplicationContext;
-import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.business.persistence.PollDAO;
-import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.business.persistence.Vote;
-import org.chorem.pollen.entities.PollenDAOHelper;
-import org.chorem.pollen.services.DefaultPollenServiceContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.PollenServiceFactory;
-import org.chorem.pollen.services.impl.VoteService;
-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.Collection;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-/**
- * Migration for version {@code 1.4.5.2}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.4.5.2
- */
-public class PollenMigrationCallbackV1_4_5_2 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(PollenMigrationCallbackV1_4_5_2.class);
-
- @Override
- public Version getVersion() {
- return VersionUtil.valueOf("1.4.5.2");
- }
-
- @Override
- protected void prepareMigrationScript(TopiaContextImplementor tx,
- List<String> queries,
- boolean showSql,
- boolean showProgression) throws TopiaException {
-
- PollenApplicationContext applicationContext = PollenApplicationContext.get(
- ActionContext.getContext());
-
- PollenServiceContext sContext = DefaultPollenServiceContext.newContext(
- Locale.getDefault(),
- tx,
- applicationContext.getConfiguration(),
- new PollenServiceFactory(),
- applicationContext.getVoteCountingStrategyProvider()
- );
-
- // clean pollAccount for votes
- // see http://chorem.org/issues/804
- removeDuplicateVoteWithSameUserAccount(tx, sContext, queries);
- }
-
- private void removeDuplicateVoteWithSameUserAccount(TopiaContextImplementor tx,
- PollenServiceContext sContext,
- List<String> queries) throws TopiaException {
-
- // get all poll with several votes with same userAccount
- TopiaSQLQuery<String> getAllPollIdsQuery = new TopiaSQLQuery<String>() {
-
- @Override
- protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- PreparedStatement ps = connection.prepareStatement(
- "SELECT p.pollid FROM poll p WHERE " +
- "(SELECT COUNT(pa) > COUNT(DISTINCT(pa.useraccount)) " +
- "FROM vote v,pollaccount pa WHERE " +
- "v.poll = p.topiaid AND v.pollaccount = pa.topiaid " +
- "AND pa.useraccount IS NOT NULL);");
- return ps;
- }
-
- @Override
- protected String prepareResult(ResultSet set) throws SQLException {
- String pollId = set.getString(1);
- return pollId;
- }
- };
-
- List<String> pollIds = getAllPollIdsQuery.findMultipleResult(tx);
-
- PollDAO pollDAO = PollenDAOHelper.getPollDAO(tx);
-
- VoteService voteService = sContext.newService(VoteService.class);
-
- Multimap<Poll, PollAccount> accountToAnonymous = ArrayListMultimap.create();
- Multimap<Poll, Vote> voteToFixByPoll = ArrayListMultimap.create();
-
- long nbPolls = pollIds.size();
- int currentPollIndex = 0;
-
- for (String pollId : pollIds) {
-
- if (log.isInfoEnabled()) {
- log.info("Treat bad poll [" + (currentPollIndex++) + "/" +
- nbPolls + "]" + pollId);
- }
-
- Poll poll = pollDAO.findByPollId(pollId);
- boolean pollAnonymous = poll.isAnonymous();
-
- List<Vote> votes = voteService.getAllVotes(poll);
-
- Multimap<UserAccount, Vote> voteByUserAccount = ArrayListMultimap.create();
- for (Vote vote : votes) {
- UserAccount useraccount = voteToUserAccount.apply(vote);
- if (useraccount != null) {
- voteByUserAccount.put(useraccount, vote);
- }
- }
-
- for (UserAccount userAccount : voteByUserAccount.keySet()) {
-
- if (userAccount != null) {
-
- Collection<Vote> votesForUser = voteByUserAccount.get(userAccount);
- if (votesForUser.size() > 1) {
-
- // ok found a userAccount
- if (log.isWarnEnabled()) {
- log.warn("Poll" + (pollAnonymous ? "(anonymous)" : "") + " [" + poll.getPollId() + "] with multi vote for the same userAccount : " +
- userAccount.getEmail());
- }
- if (pollAnonymous) {
- for (Vote vote : votesForUser) {
- accountToAnonymous.put(poll, vote.getPollAccount());
- }
- } else {
- voteToFixByPoll.putAll(poll, votesForUser);
- }
- }
- }
- }
- }
-
- // treat anonymous vote
- Set<Poll> anonymousPollToFix = accountToAnonymous.keySet();
-
- if (CollectionUtils.isNotEmpty(anonymousPollToFix)) {
- if (log.isWarnEnabled()) {
- log.warn("There is " + anonymousPollToFix.size() + " anonymous " +
- "poll to fix, will remove the userAccount from " +
- "anonymous votes");
- }
- String request = "UPDATE pollaccount set useraccount = NULL WHERE topiaid='%s';";
- for (PollAccount account : accountToAnonymous.values()) {
- queries.add(String.format(request, account.getTopiaId()));
- }
- }
-
- // treat other votes
- Set<Poll> pollToFix = voteToFixByPoll.keySet();
- if (CollectionUtils.isNotEmpty(pollToFix)) {
- if (log.isWarnEnabled()) {
- log.warn("There is " + pollToFix.size() + " other polls " +
- "to fix, will remove the userAccount from any votes");
- }
- String request = "UPDATE pollaccount set useraccount = NULL WHERE topiaid='%s';";
- for (Vote account : voteToFixByPoll.values()) {
- queries.add(String.format(request, account.getPollAccount().getTopiaId()));
- }
- }
-
- }
-
- final Function<Vote, UserAccount> voteToUserAccount = new Function<Vote, UserAccount>() {
- @Override
- public UserAccount apply(Vote input) {
- PollAccount pollAccount = input.getPollAccount();
- return pollAccount == null ? null : pollAccount.getUserAccount();
- }
- };
-
-}
\ No newline at end of file
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_5.java (from rev 3697, trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4_5_2.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_5.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_5.java 2012-09-23 13:09:29 UTC (rev 3700)
@@ -0,0 +1,218 @@
+package org.chorem.pollen.entities.migration;
+
+/*
+ * #%L
+ * Pollen :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Function;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.opensymphony.xwork2.ActionContext;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenApplicationContext;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
+import org.chorem.pollen.business.persistence.PollDAO;
+import org.chorem.pollen.business.persistence.UserAccount;
+import org.chorem.pollen.business.persistence.Vote;
+import org.chorem.pollen.entities.PollenDAOHelper;
+import org.chorem.pollen.services.DefaultPollenServiceContext;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.PollenServiceFactory;
+import org.chorem.pollen.services.impl.VoteService;
+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.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Migration for version {@code 1.4.5.2}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4.5.2
+ */
+public class PollenMigrationCallbackV1_5 extends TopiaMigrationCallbackByClassNG.MigrationCallBackForVersion {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(PollenMigrationCallbackV1_5.class);
+
+ @Override
+ public Version getVersion() {
+ return VersionUtil.valueOf("1.5");
+ }
+
+ @Override
+ protected void prepareMigrationScript(TopiaContextImplementor tx,
+ List<String> queries,
+ boolean showSql,
+ boolean showProgression) throws TopiaException {
+
+ PollenApplicationContext applicationContext = PollenApplicationContext.get(
+ ActionContext.getContext());
+
+ PollenServiceContext sContext = DefaultPollenServiceContext.newContext(
+ Locale.getDefault(),
+ tx,
+ applicationContext.getConfiguration(),
+ new PollenServiceFactory(),
+ applicationContext.getVoteCountingStrategyProvider()
+ );
+
+ // clean pollAccount for votes
+ // see http://chorem.org/issues/804
+ removeDuplicateVoteWithSameUserAccount(tx, sContext, queries);
+ }
+
+ private void removeDuplicateVoteWithSameUserAccount(TopiaContextImplementor tx,
+ PollenServiceContext sContext,
+ List<String> queries) throws TopiaException {
+
+ // get all poll with several votes with same userAccount
+ TopiaSQLQuery<String> getAllPollIdsQuery = new TopiaSQLQuery<String>() {
+
+ @Override
+ protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ PreparedStatement ps = connection.prepareStatement(
+ "SELECT p.pollid FROM poll p WHERE " +
+ "(SELECT COUNT(pa) > COUNT(DISTINCT(pa.useraccount)) " +
+ "FROM vote v,pollaccount pa WHERE " +
+ "v.poll = p.topiaid AND v.pollaccount = pa.topiaid " +
+ "AND pa.useraccount IS NOT NULL);");
+ return ps;
+ }
+
+ @Override
+ protected String prepareResult(ResultSet set) throws SQLException {
+ String pollId = set.getString(1);
+ return pollId;
+ }
+ };
+
+ List<String> pollIds = getAllPollIdsQuery.findMultipleResult(tx);
+
+ PollDAO pollDAO = PollenDAOHelper.getPollDAO(tx);
+
+ VoteService voteService = sContext.newService(VoteService.class);
+
+ Multimap<Poll, PollAccount> accountToAnonymous = ArrayListMultimap.create();
+ Multimap<Poll, Vote> voteToFixByPoll = ArrayListMultimap.create();
+
+ long nbPolls = pollIds.size();
+ int currentPollIndex = 0;
+
+ for (String pollId : pollIds) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Treat bad poll [" + (currentPollIndex++) + "/" +
+ nbPolls + "]" + pollId);
+ }
+
+ Poll poll = pollDAO.findByPollId(pollId);
+ boolean pollAnonymous = poll.isAnonymous();
+
+ List<Vote> votes = voteService.getAllVotes(poll);
+
+ Multimap<UserAccount, Vote> voteByUserAccount = ArrayListMultimap.create();
+ for (Vote vote : votes) {
+ UserAccount useraccount = voteToUserAccount.apply(vote);
+ if (useraccount != null) {
+ voteByUserAccount.put(useraccount, vote);
+ }
+ }
+
+ for (UserAccount userAccount : voteByUserAccount.keySet()) {
+
+ if (userAccount != null) {
+
+ Collection<Vote> votesForUser = voteByUserAccount.get(userAccount);
+ if (votesForUser.size() > 1) {
+
+ // ok found a userAccount
+ if (log.isWarnEnabled()) {
+ log.warn("Poll" + (pollAnonymous ? "(anonymous)" : "") + " [" + poll.getPollId() + "] with multi vote for the same userAccount : " +
+ userAccount.getEmail());
+ }
+ if (pollAnonymous) {
+ for (Vote vote : votesForUser) {
+ accountToAnonymous.put(poll, vote.getPollAccount());
+ }
+ } else {
+ voteToFixByPoll.putAll(poll, votesForUser);
+ }
+ }
+ }
+ }
+ }
+
+ // treat anonymous vote
+ Set<Poll> anonymousPollToFix = accountToAnonymous.keySet();
+
+ if (CollectionUtils.isNotEmpty(anonymousPollToFix)) {
+ if (log.isWarnEnabled()) {
+ log.warn("There is " + anonymousPollToFix.size() + " anonymous " +
+ "poll to fix, will remove the userAccount from " +
+ "anonymous votes");
+ }
+ String request = "UPDATE pollaccount set useraccount = NULL WHERE topiaid='%s';";
+ for (PollAccount account : accountToAnonymous.values()) {
+ queries.add(String.format(request, account.getTopiaId()));
+ }
+ }
+
+ // treat other votes
+ Set<Poll> pollToFix = voteToFixByPoll.keySet();
+ if (CollectionUtils.isNotEmpty(pollToFix)) {
+ if (log.isWarnEnabled()) {
+ log.warn("There is " + pollToFix.size() + " other polls " +
+ "to fix, will remove the userAccount from any votes");
+ }
+ String request = "UPDATE pollaccount set useraccount = NULL WHERE topiaid='%s';";
+ for (Vote account : voteToFixByPoll.values()) {
+ queries.add(String.format(request, account.getPollAccount().getTopiaId()));
+ }
+ }
+
+ }
+
+ final Function<Vote, UserAccount> voteToUserAccount = new Function<Vote, UserAccount>() {
+ @Override
+ public UserAccount apply(Vote input) {
+ PollAccount pollAccount = input.getPollAccount();
+ return pollAccount == null ? null : pollAccount.getUserAccount();
+ }
+ };
+
+}
\ No newline at end of file
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_5.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-services/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
===================================================================
--- trunk/pollen-services/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-services/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion 2012-09-23 13:09:29 UTC (rev 3700)
@@ -4,4 +4,4 @@
org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_3_1
org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_4
org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_4_5
-org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_4_5_2
\ No newline at end of file
+org.chorem.pollen.entities.migration.PollenMigrationCallbackV1_5
\ No newline at end of file
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java 2012-09-23 13:09:29 UTC (rev 3700)
@@ -1,5 +1,28 @@
package org.chorem.pollen.votecounting.model;
+/*
+ * #%L
+ * Pollen :: VoteCounting Api
+ * $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%
+ */
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
Property changes on: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java 2012-09-23 13:03:52 UTC (rev 3699)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java 2012-09-23 13:09:29 UTC (rev 3700)
@@ -1,5 +1,28 @@
package org.chorem.pollen.votecounting.model;
+/*
+ * #%L
+ * Pollen :: VoteCounting Api
+ * $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%
+ */
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
Property changes on: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
23 Sep '12
Author: tchemit
Date: 2012-09-23 15:03:52 +0200 (Sun, 23 Sep 2012)
New Revision: 3699
Url: http://chorem.org/repositories/revision/pollen/3699
Log:
move to version 1.5-SNAPSHOT
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-services/pom.xml
trunk/pollen-ui-struts2/pom.xml
trunk/pollen-votecounting-api/pom.xml
trunk/pollen-votecounting-strategy-borda/pom.xml
trunk/pollen-votecounting-strategy-condorcet/pom.xml
trunk/pollen-votecounting-strategy-coombs/pom.xml
trunk/pollen-votecounting-strategy-instant-runoff/pom.xml
trunk/pollen-votecounting-strategy-normal/pom.xml
trunk/pollen-votecounting-strategy-number/pom.xml
trunk/pollen-votecounting-strategy-percentage/pom.xml
trunk/pollen-votecounting-strategy/pom.xml
trunk/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-persistence/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-services/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-ui-struts2/pom.xml
===================================================================
--- trunk/pollen-ui-struts2/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-ui-struts2/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-api/pom.xml
===================================================================
--- trunk/pollen-votecounting-api/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-api/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-borda/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-borda/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-borda/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-condorcet/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-condorcet/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-condorcet/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-coombs/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-coombs/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-coombs/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-instant-runoff/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-instant-runoff/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-instant-runoff/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-normal/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-normal/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-normal/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-number/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-number/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-number/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pollen-votecounting-strategy-percentage/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-percentage/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pollen-votecounting-strategy-percentage/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
+++ trunk/pom.xml 2012-09-23 13:03:52 UTC (rev 3699)
@@ -15,7 +15,7 @@
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.4.5.2-SNAPSHOT</version>
+ <version>1.5-SNAPSHOT</version>
<modules>
<module>pollen-votecounting-api</module>
1
0
Author: tchemit
Date: 2012-09-23 15:01:38 +0200 (Sun, 23 Sep 2012)
New Revision: 3698
Url: http://chorem.org/repositories/revision/pollen/3698
Log:
refs #590: Refactor votecounting module (remove votecounting module)
fixes #541: Add new voting system (Instant-runoff voting aka alternative vote)
fixes #542: Add new voting system (Borda count)
fixes #543: Add new voting system (Coombs' method)
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/ChoiceType.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/I18nAble.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollType.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java
Removed:
trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServicePredicates.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/I18nAble.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollCommentVisibility.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java
trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties
trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java
trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.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/PollVoteCountingService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
trunk/pollen-ui-struts2/pom.xml
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/poll/ResultForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/form/AbstractPollForm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AddChoice.java
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/result.jsp
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupVoteCountingResult.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteForChoice.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoterBuilder.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/AbstractVoteCountingStrategy.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java
trunk/pollen-votecounting-strategy-borda/src/test/java/org/chorem/pollen/votecounting/strategy/BordaStrategyTest.java
trunk/pollen-votecounting-strategy-condorcet/src/test/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategyTest.java
trunk/pollen-votecounting-strategy-coombs/src/test/java/org/chorem/pollen/votecounting/strategy/CoombsStrategyTest.java
trunk/pollen-votecounting-strategy-instant-runoff/src/test/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategyTest.java
trunk/pollen-votecounting-strategy-normal/src/test/java/org/chorem/pollen/votecounting/strategy/NormalStrategyTest.java
trunk/pollen-votecounting-strategy-number/src/test/java/org/chorem/pollen/votecounting/strategy/NumberStrategyTest.java
trunk/pollen-votecounting-strategy-percentage/src/test/java/org/chorem/pollen/votecounting/strategy/PercentageStrategyTest.java
trunk/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
@@ -17,9 +17,10 @@
<artifactId>pollen-persistence</artifactId>
<dependencies>
+
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting</artifactId>
+ <artifactId>pollen-votecounting-api</artifactId>
<version>${project.version}</version>
</dependency>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -28,10 +28,10 @@
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.persistence.ChoiceType;
import org.chorem.pollen.business.persistence.PollCommentVisibility;
+import org.chorem.pollen.business.persistence.PollType;
import org.chorem.pollen.business.persistence.PollVoteVisibility;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.util.FileUtil;
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -24,8 +24,8 @@
import org.chorem.pollen.business.persistence.PollCommentVisibility;
import org.chorem.pollen.business.persistence.PollVoteVisibility;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.business.persistence.ChoiceType;
+import org.chorem.pollen.business.persistence.PollType;
import org.hibernate.dialect.H2Dialect;
import org.nuiton.util.ApplicationConfig;
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/PollenFunctions.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -23,27 +23,13 @@
package org.chorem.pollen;
import com.google.common.base.Function;
-import com.google.common.collect.Lists;
import org.apache.commons.lang3.tuple.Pair;
-import org.chorem.pollen.business.persistence.Choice;
-import org.chorem.pollen.business.persistence.Comment;
-import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
-import org.chorem.pollen.business.persistence.VoteToChoice;
-import org.chorem.pollen.business.persistence.VotingList;
-import org.chorem.pollen.votecounting.business.NumberMethod;
-import org.chorem.pollen.votecounting.dto.CommentDTO;
-import org.chorem.pollen.votecounting.dto.PollChoiceDTO;
-import org.chorem.pollen.votecounting.dto.PollDTO;
-import org.chorem.pollen.votecounting.dto.VoteToChoiceDTO;
-import org.chorem.pollen.votecounting.dto.VotingGroupDTO;
-import org.chorem.pollen.votecounting.dto.VotingPersonDTO;
import org.nuiton.topia.persistence.TopiaEntity;
-import java.util.List;
import java.util.Map;
/**
@@ -68,97 +54,97 @@
}
};
- public static final Function<Poll, PollDTO> POLL_TO_BEAN = new Function<Poll, PollDTO>() {
- @Override
- public PollDTO apply(Poll input) {
- PollDTO result = new PollDTO(input.getPollId());
- result.setTitle(input.getTitle());
- result.setDescription(input.getDescription());
- result.setBeginChoiceDate(input.getBeginChoiceDate());
- result.setBeginDate(input.getBeginDate());
- result.setEndDate(input.getEndDate());
- result.setAnonymous(input.isAnonymous());
- result.setAnonymousVoteAllowed(input.isAnonymousVoteAllowed());
- result.setPublicResults(input.isPublicResults());
- result.setContinuousResults(input.isContinuousResults());
- result.setChoiceAddAllowed(input.isChoiceAddAllowed());
- result.setClosed(input.isClosed());
- result.setCreatorId(input.getCreator().getVotingId());
- result.setCreatorEmail(input.getCreator().getEmail());
- result.setMaxChoiceNb(input.getMaxChoiceNb());
- result.setPollType(input.getPollType());
- result.setChoiceType(input.getChoiceType());
- result.setVoteCounting(input.getVoteCountingType());
+// public static final Function<Poll, PollDTO> POLL_TO_BEAN = new Function<Poll, PollDTO>() {
+// @Override
+// public PollDTO apply(Poll input) {
+// PollDTO result = new PollDTO(input.getPollId());
+// result.setTitle(input.getTitle());
+// result.setDescription(input.getDescription());
+// result.setBeginChoiceDate(input.getBeginChoiceDate());
+// result.setBeginDate(input.getBeginDate());
+// result.setEndDate(input.getEndDate());
+// result.setAnonymous(input.isAnonymous());
+// result.setAnonymousVoteAllowed(input.isAnonymousVoteAllowed());
+// result.setPublicResults(input.isPublicResults());
+// result.setContinuousResults(input.isContinuousResults());
+// result.setChoiceAddAllowed(input.isChoiceAddAllowed());
+// result.setClosed(input.isClosed());
+// result.setCreatorId(input.getCreator().getVotingId());
+// result.setCreatorEmail(input.getCreator().getEmail());
+// result.setMaxChoiceNb(input.getMaxChoiceNb());
+// result.setPollType(input.getPollType());
+// result.setChoiceType(input.getChoiceType());
+// result.setVoteCounting(input.getVoteCountingType());
+//
+// result.setComments(Lists.transform(input.getComment(),
+// COMMENT_TO_BEAN));
+//
+// result.setChoices(Lists.transform(input.getChoice(),
+// CHOICE_TO_BEAN));
+//
+// if (!input.isVotingListEmpty()) {
+//
+// result.setVotingGroups(Lists.transform(input.getVotingList(),
+// newVotingListToBean(input)
+// ));
+// } else {
+// // un groupe par défaut si il y en a pas
+// VotingGroupDTO group = new VotingGroupDTO("unique", 1);
+// group.setName("unique");
+// List<VotingPersonDTO> votes = Lists.transform(input.getVote(),
+// VOTE_TO_BEAN);
+// group.setVotingPersons(votes);
+// result.getVotingGroups().add(group);
+// }
+// return result;
+// }
+// };
+//
+// public static final Function<Comment, CommentDTO> COMMENT_TO_BEAN = new Function<Comment, CommentDTO>() {
+// @Override
+// public CommentDTO apply(Comment input) {
+// CommentDTO result = new CommentDTO(
+// input.getAuthor(), input.getText());
+// return result;
+// }
+// };
+//
+// public static final Function<Choice, PollChoiceDTO> CHOICE_TO_BEAN = new Function<Choice, PollChoiceDTO>() {
+// @Override
+// public PollChoiceDTO apply(Choice input) {
+// PollChoiceDTO result = new PollChoiceDTO(input.getTopiaId());
+// String choiceName = input.getName();
+// result.setName(choiceName);
+// result.setHidden(choiceName != null &&
+// choiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
+// result.setDescription(input.getDescription());
+// return result;
+// }
+// };
+//
+// public static Function<VotingList, VotingGroupDTO> newVotingListToBean(final Poll poll) {
+// return new Function<VotingList, VotingGroupDTO>() {
+// @Override
+// public VotingGroupDTO apply(VotingList input) {
+// VotingGroupDTO result = new VotingGroupDTO(
+// input.getTopiaId(),
+// input.getWeight());
+//
+// result.setName(input.getName());
+//
+// for (PersonToList pToList : input.getPollAccountPersonToList()) {
+// Vote vote = poll.getVoteByPollAccount(pToList.getPollAccount());
+// if (vote != null) {
+// // Pas de vote pour cette personne : doit engendrer erreur ?!?
+// VotingPersonDTO bean = VOTE_TO_BEAN.apply(vote);
+// result.getVotingPersons().add(bean);
+// }
+// }
+// return result;
+// }
+// };
+// }
- result.setComments(Lists.transform(input.getComment(),
- COMMENT_TO_BEAN));
-
- result.setChoices(Lists.transform(input.getChoice(),
- CHOICE_TO_BEAN));
-
- if (!input.isVotingListEmpty()) {
-
- result.setVotingGroups(Lists.transform(input.getVotingList(),
- newVotingListToBean(input)
- ));
- } else {
- // un groupe par défaut si il y en a pas
- VotingGroupDTO group = new VotingGroupDTO("unique", 1);
- group.setName("unique");
- List<VotingPersonDTO> votes = Lists.transform(input.getVote(),
- VOTE_TO_BEAN);
- group.setVotingPersons(votes);
- result.getVotingGroups().add(group);
- }
- return result;
- }
- };
-
- public static final Function<Comment, CommentDTO> COMMENT_TO_BEAN = new Function<Comment, CommentDTO>() {
- @Override
- public CommentDTO apply(Comment input) {
- CommentDTO result = new CommentDTO(
- input.getAuthor(), input.getText());
- return result;
- }
- };
-
- public static final Function<Choice, PollChoiceDTO> CHOICE_TO_BEAN = new Function<Choice, PollChoiceDTO>() {
- @Override
- public PollChoiceDTO apply(Choice input) {
- PollChoiceDTO result = new PollChoiceDTO(input.getTopiaId());
- String choiceName = input.getName();
- result.setName(choiceName);
- result.setHidden(choiceName != null &&
- choiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
- result.setDescription(input.getDescription());
- return result;
- }
- };
-
- public static Function<VotingList, VotingGroupDTO> newVotingListToBean(final Poll poll) {
- return new Function<VotingList, VotingGroupDTO>() {
- @Override
- public VotingGroupDTO apply(VotingList input) {
- VotingGroupDTO result = new VotingGroupDTO(
- input.getTopiaId(),
- input.getWeight());
-
- result.setName(input.getName());
-
- for (PersonToList pToList : input.getPollAccountPersonToList()) {
- Vote vote = poll.getVoteByPollAccount(pToList.getPollAccount());
- if (vote != null) {
- // Pas de vote pour cette personne : doit engendrer erreur ?!?
- VotingPersonDTO bean = VOTE_TO_BEAN.apply(vote);
- result.getVotingPersons().add(bean);
- }
- }
- return result;
- }
- };
- }
-
// public static final Function<VotingList, VotingGroupDTO> VOTING_LIST_TO_BEAN = new Function<VotingList, VotingGroupDTO>() {
// @Override
// public VotingGroupDTO apply(VotingList input) {
@@ -180,36 +166,44 @@
// }
// };
- public static final Function<Vote, VotingPersonDTO> VOTE_TO_BEAN = new Function<Vote, VotingPersonDTO>() {
+ public static final Function<Vote, PollAccount> VOTE_TO_POLL_ACCOUNT = new Function<Vote, PollAccount>() {
@Override
- public VotingPersonDTO apply(Vote input) {
- VotingPersonDTO result =
- new VotingPersonDTO(input.getPollAccount().getVotingId(), input.getWeight());
- result.setEmail(input.getPollAccount().getEmail());
-
- if (!input.isChoiceVoteToChoiceEmpty()) {
- for (VoteToChoice vToChoice : input.getChoiceVoteToChoice()) {
- if (vToChoice != null && vToChoice.getChoice() != null) {
- VoteToChoiceDTO bean = VOTE_TO_CHOICE_TO_BEAN.apply(vToChoice);
- result.getChoices().add(bean);
- }
- }
- }
+ public PollAccount apply(Vote input) {
+ PollAccount result = input.getPollAccount();
return result;
}
};
- public static final Function<VoteToChoice, VoteToChoiceDTO> VOTE_TO_CHOICE_TO_BEAN = new Function<VoteToChoice, VoteToChoiceDTO>() {
- @Override
- public VoteToChoiceDTO apply(VoteToChoice input) {
- VoteToChoiceDTO result = new VoteToChoiceDTO(
- input.getChoice().getTopiaId(),
- input.getVoteValue());
+// public static final Function<Vote, VotingPersonDTO> VOTE_TO_BEAN = new Function<Vote, VotingPersonDTO>() {
+// @Override
+// public VotingPersonDTO apply(Vote input) {
+// VotingPersonDTO result =
+// new VotingPersonDTO(input.getPollAccount().getVotingId(), input.getWeight());
+// result.setEmail(input.getPollAccount().getEmail());
+//
+// if (!input.isChoiceVoteToChoiceEmpty()) {
+// for (VoteToChoice vToChoice : input.getChoiceVoteToChoice()) {
+// if (vToChoice != null && vToChoice.getChoice() != null) {
+// VoteToChoiceDTO bean = VOTE_TO_CHOICE_TO_BEAN.apply(vToChoice);
+// result.getChoices().add(bean);
+// }
+// }
+// }
+// return result;
+// }
+// };
+//
+// public static final Function<VoteToChoice, VoteToChoiceDTO> VOTE_TO_CHOICE_TO_BEAN = new Function<VoteToChoice, VoteToChoiceDTO>() {
+// @Override
+// public VoteToChoiceDTO apply(VoteToChoice input) {
+// VoteToChoiceDTO result = new VoteToChoiceDTO(
+// input.getChoice().getTopiaId(),
+// input.getVoteValue());
+//
+// return result;
+// }
+// };
- return result;
- }
- };
-
public static final Function<Map.Entry<Poll, PollAccount>, Pair<Poll, PollAccount>> MAP_ENTRY_TO_PAIR_FUNCTION = new Function<Map.Entry<Poll, PollAccount>, Pair<Poll, PollAccount>>() {
@Override
public Pair<Poll, PollAccount> apply(Map.Entry<Poll, PollAccount> input) {
Copied: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/ChoiceType.java (from rev 3691, trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java)
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/ChoiceType.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/ChoiceType.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -0,0 +1,54 @@
+/*
+ * #%L
+ * Pollen :: Vote Counting
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+import static org.nuiton.i18n.I18n.n_;
+
+public enum ChoiceType implements I18nAble {
+ TEXT(n_("pollen.choiceType.text")),
+ DATE(n_("pollen.choiceType.date")),
+ IMAGE(n_("pollen.choiceType.image"));
+
+ private final String i18nKey;
+
+ ChoiceType(String i18nKey) {
+ this.i18nKey = i18nKey;
+ }
+
+ @Override
+ public String getI18nKey() {
+ return i18nKey;
+ }
+
+ public static ChoiceType valueOf(int ordinal) {
+
+ ChoiceType result = null;
+ for (ChoiceType curr : ChoiceType.values()) {
+ if (curr.ordinal() == ordinal) {
+ result = curr;
+ break;
+ }
+ }
+ return result;
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/ChoiceType.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/I18nAble.java (from rev 3691, trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/I18nAble.java)
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/I18nAble.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/I18nAble.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -0,0 +1,34 @@
+/*
+ * #%L
+ * Pollen :: Vote Counting
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+/**
+ * Contract to expose a i18n key.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public interface I18nAble {
+
+ String getI18nKey();
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/I18nAble.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollCommentVisibility.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollCommentVisibility.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollCommentVisibility.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,8 +22,6 @@
* #L%
*/
-import org.chorem.pollen.common.I18nAble;
-
import static org.nuiton.i18n.I18n.n_;
/**
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -24,7 +24,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import org.chorem.pollen.common.PollType;
import java.util.Date;
import java.util.List;
Copied: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollType.java (from rev 3691, trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java)
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollType.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollType.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -0,0 +1,54 @@
+/*
+ * #%L
+ * Pollen :: Vote Counting
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+import static org.nuiton.i18n.I18n.n_;
+
+public enum PollType implements I18nAble {
+
+ FREE(n_("pollen.pollType.free")),
+ RESTRICTED(n_("pollen.pollType.restricted")),
+ GROUP(n_("pollen.pollType.group"));
+
+ private final String i18nKey;
+
+ PollType(String i18nKey) {
+ this.i18nKey = i18nKey;
+ }
+
+ @Override
+ public String getI18nKey() {
+ return i18nKey;
+ }
+
+ public static PollType valueOf(int ordinal) {
+ PollType result = null;
+ for (PollType curr : PollType.values()) {
+ if (curr.ordinal() == ordinal) {
+ result = curr;
+ break;
+ }
+ }
+ return result;
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollType.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,8 +22,6 @@
* #L%
*/
-import org.chorem.pollen.common.I18nAble;
-
import static org.nuiton.i18n.I18n.n_;
/**
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -0,0 +1,96 @@
+package org.chorem.pollen.business.persistence;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import org.chorem.pollen.PollenFunctions;
+import org.chorem.pollen.votecounting.model.GroupOfVoter;
+import org.chorem.pollen.votecounting.model.GroupOfVoterBuilder;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
+import org.chorem.pollen.votecounting.model.Voter;
+import org.chorem.pollen.votecounting.model.VoterBuilder;
+import org.chorem.pollen.votecounting.strategy.VoteCountingStrategy;
+import org.chorem.pollen.votecounting.strategy.VoteCountingStrategyProvider;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Useful methods around {@link Poll}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4.6
+ */
+public class Polls {
+
+ public static boolean isGroupPoll(Poll poll) {
+ return PollType.GROUP == poll.getPollType();
+ }
+
+ public static boolean isRestrictedPoll(Poll poll) {
+ return PollType.RESTRICTED == poll.getPollType();
+ }
+
+ public static boolean isFreePoll(Poll poll) {
+ return PollType.FREE == poll.getPollType();
+ }
+
+ public static GroupOfVoter toSimpleGroupOfVoters(Poll poll) {
+ Preconditions.checkNotNull(poll);
+ SimpleVoterBuilder builder = new SimpleVoterBuilder();
+
+ for (Vote vote : poll.getVote()) {
+ fillSimpleVoter(builder, vote);
+ }
+ Set<Voter> voter = builder.getVoters();
+ GroupOfVoter result = GroupOfVoter.newVoter(null, 1.0, voter);
+ return result;
+ }
+
+ public static GroupOfVoter toGroupOfVoters(Poll poll) {
+ Preconditions.checkNotNull(poll);
+ GroupOfVoterBuilder builder = new GroupOfVoterBuilder();
+
+ // create group of voter
+ Map<PollAccount, Vote> voteByPollAccount = Maps.uniqueIndex(
+ poll.getVote(), PollenFunctions.VOTE_TO_POLL_ACCOUNT);
+
+ for (VotingList votingList : poll.getVotingList()) {
+
+ builder.newGroupVoter(votingList.getTopiaId(),
+ votingList.getWeight());
+
+ for (PersonToList personToList : votingList.getPollAccountPersonToList()) {
+ PollAccount voterAccount = personToList.getPollAccount();
+ Vote vote = voteByPollAccount.get(voterAccount);
+ if (vote != null) {
+ fillSimpleVoter(builder, vote);
+ }
+ }
+ }
+
+ Set<Voter> voter = builder.getVoters();
+ GroupOfVoter result = GroupOfVoter.newVoter(null, 1.0, voter);
+ return result;
+ }
+
+ public static VoteCountingStrategy getVoteCountingStrategy(VoteCountingStrategyProvider provider, Poll poll) {
+ Preconditions.checkNotNull(provider);
+ Preconditions.checkNotNull(poll);
+ int strategyId = poll.getVoteCountingType();
+ VoteCountingStrategy result = provider.getStrategy(strategyId);
+ Preconditions.checkNotNull(
+ result, "Could not find strategry for id " + strategyId);
+ return result;
+ }
+
+
+ protected static void fillSimpleVoter(VoterBuilder builder, Vote vote) {
+ builder.newVoter(vote.getPollAccount().getAccountId(), vote.getWeight());
+ for (VoteToChoice voteToChoice : vote.getChoiceVoteToChoice()) {
+ builder.addVoteForChoice(
+ voteToChoice.getChoice().getTopiaId(),
+ Double.valueOf(voteToChoice.getVoteValue()));
+ }
+
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/Polls.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties
===================================================================
--- trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties 2012-09-23 13:01:38 UTC (rev 3698)
@@ -34,3 +34,13 @@
pollen.pollVoteVisibilty.nobody.help=Poll is anonymous, nobody can see votes
pollen.pollVoteVisibilty.participantOnly=Visible for participant
pollen.pollVoteVisibilty.participantOnly.help=Only poll's participants can see votes
+pollen.choiceType.date=Date
+pollen.choiceType.image=Image
+pollen.choiceType.text=Text
+pollen.pollType.free=Free
+pollen.pollType.group=Group
+pollen.pollType.restricted=Restricted
+pollen.voteCountingType.condorcet=Condorcet
+pollen.voteCountingType.normal=Normal
+pollen.voteCountingType.number=Number
+pollen.voteCountingType.percentage=Percentage
Modified: trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties
===================================================================
--- trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties 2012-09-23 13:01:38 UTC (rev 3698)
@@ -34,3 +34,13 @@
pollen.pollVoteVisibilty.nobody.help=Le sondage est anonyme, personne ne peut voir les votes
pollen.pollVoteVisibilty.participantOnly=Visible pour les participants
pollen.pollVoteVisibilty.participantOnly.help=Seuls les participants du sondage peuvent voir les votes
+pollen.choiceType.date=Date
+pollen.choiceType.image=Image
+pollen.choiceType.text=Texte
+pollen.pollType.free=Libre
+pollen.pollType.group=Groupe
+pollen.pollType.restricted=Restreint
+pollen.voteCountingType.condorcet=Condorcet
+pollen.voteCountingType.normal=Normal
+pollen.voteCountingType.number=Nombre
+pollen.voteCountingType.percentage=Pourcentage
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
@@ -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>
@@ -17,18 +19,15 @@
<artifactId>pollen-services</artifactId>
<dependencies>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pollen-votecounting-api</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>pollen-persistence</artifactId>
<version>${project.version}</version>
</dependency>
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResult.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -23,7 +23,7 @@
package org.chorem.pollen.bean;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.business.persistence.ChoiceType;
import java.io.Serializable;
@@ -52,25 +52,6 @@
private boolean hidden;
- public PollResult() {
-
- }
-
- public PollResult(String id) {
- this.id = id;
- }
-
- public PollResult(String name,
- String pollId,
- ChoiceType choiceType,
- int voteCountingType) {
- super();
- this.name = name;
- this.pollId = pollId;
- this.choiceType = choiceType;
- this.voteCountingType = voteCountingType;
- }
-
public String getId() {
return id;
}
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollResultList.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * Pollen :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.bean;
-
-import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class PollResultList {
-
- /** Liste des résultats */
- private List<PollResult> pollResults;
-
- /** Résultat issu du dépouillement du vote */
- private VoteCountingResultDTO voteCountingResult;
-
- public List<PollResult> getPollResults() {
- return pollResults;
- }
-
- public void setPollResults(List<PollResult> pollResults) {
- this.pollResults = pollResults;
- }
-
- public VoteCountingResultDTO getVoteCountingResult() {
- return voteCountingResult;
- }
-
- public void setVoteCountingResult(VoteCountingResultDTO voteCountingResult) {
- this.voteCountingResult = voteCountingResult;
- }
-
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,8 +26,8 @@
import com.google.common.collect.Maps;
import org.apache.commons.lang3.tuple.Pair;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.business.persistence.ChoiceType;
+import org.chorem.pollen.business.persistence.PollType;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaSQLQuery;
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -29,25 +29,19 @@
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.ChoiceType;
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.Vote;
-import org.chorem.pollen.business.persistence.VoteToChoice;
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.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.nuiton.topia.persistence.TopiaEntity;
import java.util.Date;
import java.util.List;
-import java.util.Set;
/**
* Usefull functions for the service (and higher) layers.
@@ -78,28 +72,28 @@
}
}
- public static final Function<Poll, Set<Voter>> POLL_TO_VOTERS = new Function<Poll, Set<Voter>>() {
- @Override
- public Set<Voter> apply(Poll input) {
+// public static final Function<Poll, Set<Voter>> POLL_TO_VOTERS = new Function<Poll, Set<Voter>>() {
+// @Override
+// public Set<Voter> apply(Poll input) {
+//
+// VoterBuilder builder = new SimpleVoterBuilder();
+// for (Vote vote : input.getVote()) {
+//
+// String voterId = vote.getPollAccount().getAccountId();
+// double voteWeight = vote.getWeight();
+// builder.newVoter(voterId, voteWeight);
+//
+// for (VoteToChoice voteToChoice : vote.getChoiceVoteToChoice()) {
+// String choiceId = voteToChoice.getChoice().getTopiaId();
+// Double voteValue = Double.valueOf(voteToChoice.getVoteValue());
+// builder.addVoteForChoice(choiceId, voteValue);
+// }
+// }
+// Set<Voter> result = builder.getVoters();
+// return result;
+// }
+// };
- VoterBuilder builder = new VoterBuilder();
- for (Vote vote : input.getVote()) {
-
- String voterId = vote.getPollAccount().getAccountId();
- double voteWeight = vote.getWeight();
- builder.newVoter(voterId, voteWeight);
-
- for (VoteToChoice voteToChoice : vote.getChoiceVoteToChoice()) {
- String choiceId = voteToChoice.getChoice().getTopiaId();
- Double voteValue = Double.valueOf(voteToChoice.getVoteValue());
- builder.addVoteForChoice(choiceId, voteValue);
- }
- }
- Set<Voter> result = builder.getVoters();
- return result;
- }
- };
-
public static final Function<Choice, String> CHOICE_TO_NAME = new Function<Choice, String>() {
@Override
public String apply(Choice input) {
@@ -125,6 +119,7 @@
return result;
}
};
+
public static TopiaIdExtractor newTopiaIdExtractor() {
return new TopiaIdExtractor();
}
@@ -289,8 +284,9 @@
dto.setPollId(poll.getPollId());
String resName = res.getName();
dto.setName(resName);
- dto.setHidden(resName != null &&
- resName.startsWith(NumberMethod.HIDDEN_PREFIX));
+// dto.setHidden(resName != null &&
+// resName.startsWith(NumberMethod.HIDDEN_PREFIX));
+ dto.setHidden(false);
dto.setValue(res.getResultValue());
dto.setByGroup(res.isByGroup());
dto.setChoiceType(poll.getChoiceType());
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServicePredicates.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServicePredicates.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServicePredicates.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -1,50 +0,0 @@
-/*
- * #%L
- * Pollen :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.services;
-
-import com.google.common.base.Predicate;
-import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.business.persistence.PollAccount;
-
-/**
- * Created: 16/04/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public final class PollenServicePredicates {
-
- private PollenServicePredicates() {
- // never instanciate a class with static methods
- }
-
- /** Check if the PollAccount is empty, i.e. has empty votingId or email. */
- public static final Predicate<PollAccount> POLL_ACCOUNT_NOT_EMPTY = new Predicate<PollAccount>() {
-
- @Override
- public boolean apply(PollAccount input) {
- String votingId = input.getVotingId();
- String email = input.getEmail();
- return StringUtils.isNotBlank(votingId) && StringUtils.isNotBlank(email);
- }
- };
-}
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -47,7 +47,6 @@
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
-import java.util.Date;
import java.util.List;
import static org.nuiton.i18n.I18n._;
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -24,42 +24,28 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.PollenFunctions;
import org.chorem.pollen.bean.PollResult;
-import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.ChoiceType;
import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.Polls;
import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.ResultDAO;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceFunctions;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.votecounting.business.NumberMethod;
-import org.chorem.pollen.votecounting.dto.ChoiceDTO;
-import org.chorem.pollen.votecounting.dto.PollDTO;
-import org.chorem.pollen.votecounting.dto.PollExportDTO;
-import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
-import org.chorem.pollen.votecounting.services.ImportExportService;
-import org.chorem.pollen.votecounting.services.VoteCountingService;
+import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.VoteCountingResult;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* Deals with poll results.
*
@@ -72,66 +58,6 @@
private static final Log log = LogFactory.getLog(PollResultsService.class);
/**
- * 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 à traiter
- * @return les résultats du sondage.
- */
- public PollResultList getResults(Poll poll) {
-
- Preconditions.checkNotNull(poll);
-
-
- VoteCountingResultDTO result;
- if (!poll.isResultUptodate()) {
-
- //must regenerate results
-
- result = generateResult(poll);
-
- commitTransaction("Could not generate poll result");
- } else {
-
- result = getResultDTO(poll);
-
- }
-
- boolean byGroup = poll.getPollType() == PollType.GROUP;
-
- int voteCountingType = poll.getVoteCountingType();
-
- // Conversion des résultats
- List<PollResult> list = Lists.transform(
- poll.getResult(),
- PollenServiceFunctions.newResultToBeanFunction(poll));
-
- // Filtrage des résultats que l'on veut retourner
-
- Iterator<PollResult> it = list.iterator();
- while (it.hasNext()) {
- PollResult currentResult = it.next();
-
- // Cas d'un sondage de type GROUP avec filtre
- if (byGroup) {
-
- // Filtre group : Suppression resultats non group
- if (!currentResult.isByGroup()) {
- it.remove();
- }
- }
- }
-
- PollResultList resultList = new PollResultList();
- resultList.setPollResults(list);
- resultList.setVoteCountingResult(result);
- return resultList;
- }
-
- /**
* Génère les résultats d'un sondage (= un dépouillement) et les stoque en
* base.
* <p/>
@@ -142,76 +68,115 @@
* @param poll le sondage à dépouiller
* @since 1.4
*/
- public VoteCountingResultDTO generateResult(Poll poll) {
-
+ public void generateResult(Poll poll) {
Preconditions.checkNotNull(poll);
if (log.isInfoEnabled()) {
log.info("Will regenerate results for poll " + poll.getPollId());
}
- VoteCountingResultDTO result = getResultDTO(poll);
+ PollVoteCountingService service =
+ newService(PollVoteCountingService.class);
+
+ VoteCountingResult mainResult;
+
+ if (Polls.isGroupPoll(poll)) {
+ mainResult = service.getGroupResult(poll).getMainResult();
+ } else {
+ mainResult = service.getSimpleResult(poll);
+ }
+
+ boolean groupPoll = Polls.isGroupPoll(poll);
+ int voteCountingType = poll.getVoteCountingType();
+
// clear result
poll.clearResult();
ResultDAO daoResult = getDAO(Result.class);
- for (ChoiceDTO choice : result.getChoices()) {
+ for (ChoiceScore choice : mainResult.getScores()) {
Result eResult = create(daoResult);
- Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+ Choice eChoice = poll.getChoiceByTopiaId(choice.getChoiceId());
eResult.setName(eChoice.getName());
- eResult.setByGroup(result.isByGroup());
-// eResult.setPoll(poll);
- eResult.setResultValue(String.valueOf(choice.getValue()));
- eResult.setVoteCountingType(poll.getVoteCountingType());
+ eResult.setByGroup(groupPoll);
+ eResult.setResultValue(String.valueOf(choice.getScoreValue()));
+ eResult.setVoteCountingType(voteCountingType);
poll.addResult(eResult);
}
-
poll.setResultUptodate(true);
-
- return result;
}
- public String exportPolltoXml(String pollId) throws PollNotFoundException {
+ /**
+ * Récurpération des résultats d'un sondage sous forme de
+ * {@link PollResult}.
+ * <p/>
+ * Si les résultats ne sont pas à jour ({@link Poll#isResultUptodate()},
+ * alors ils seront regénérés.
+ *
+ * @param poll le sondage à traiter
+ * @return les résultats du sondage.
+ */
+ public List<PollResult> getResults(Poll poll) {
- // Recherche du sondage
+ Preconditions.checkNotNull(poll);
- PollService pollService = newService(PollService.class);
+ if (!poll.isResultUptodate()) {
- Poll poll = pollService.getExistingPollByPollId(pollId);
+ //must regenerate results
- PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
+ generateResult(poll);
- VoteCountingService service = new VoteCountingService();
+ commitTransaction("Could not generate poll result");
+ }
- List<VoteCountingResultDTO> results = Lists.newArrayList();
+ // Conversion des résultats
+ List<PollResult> list = Lists.transform(
+ poll.getResult(),
+ PollenServiceFunctions.newResultToBeanFunction(poll));
+ return list;
+ }
- VoteCountingResultDTO result = service.executeVoteCounting(dto);
+ public String exportPolltoXml(String pollId) throws PollNotFoundException {
- results.add(result);
+ // Recherche du sondage
- if (poll.getPollType() == PollType.GROUP) {
- VoteCountingResultDTO groupResult =
- service.executeGroupCounting(dto);
- results.add(groupResult);
- }
+ PollService pollService = newService(PollService.class);
- // Transformation du sondage
- PollExportDTO pollExport = new PollExportDTO();
- pollExport.setPollId(pollId);
- pollExport.setPoll(dto);
- pollExport.setVoteCountingResults(results);
+ Poll poll = pollService.getExistingPollByPollId(pollId);
- // Export du sondage
- ImportExportService serviceExport = new ImportExportService();
- String content = serviceExport.exportToXml(pollExport);
-
- return content;
+ return "TODO in Pollen 2.0";
+// PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
+//
+// VoteCountingService service = new VoteCountingService();
+//
+// List<VoteCountingResultDTO> results = Lists.newArrayList();
+//
+// VoteCountingResultDTO result = service.executeVoteCounting(dto);
+//
+// results.add(result);
+//
+// if (poll.getPollType() == PollType.GROUP) {
+// VoteCountingResultDTO groupResult =
+// service.executeGroupCounting(dto);
+// results.add(groupResult);
+// }
+//
+// // Transformation du sondage
+// PollExportDTO pollExport = new PollExportDTO();
+// pollExport.setPollId(pollId);
+// pollExport.setPoll(dto);
+// pollExport.setVoteCountingResults(results);
+//
+// // Export du sondage
+// ImportExportService serviceExport = new ImportExportService();
+// String content = serviceExport.exportToXml(pollExport);
+//
+// return content;
}
public String getResultValue(Choice choice,
@@ -227,125 +192,6 @@
return val;
}
- public List<PollResult> createNumberVoteCountingResult(
- PollResultList resultListDTO,
- Multimap<String, String> choicesResults,
- Multimap<String, String> subtitles) {
- Preconditions.checkNotNull(resultListDTO);
- Preconditions.checkNotNull(choicesResults);
- Preconditions.checkNotNull(subtitles);
-
- List<PollResult> results = resultListDTO.getPollResults();
-
- /*
- * liste des vrais choix (les choix pas cachés).
- * cette variable sera affectée à la variable results
- */
- List<PollResult> results2 = Lists.newArrayList();
-
- // Ajout des résultats des choix cachés
- for (PollResult result : results) {
- if (result.isHidden()) {
- String name = result.getName();
- int indexOf = name.indexOf('#');
- String choice = name.substring(
- NumberMethod.HIDDEN_PREFIX.length(), indexOf);
-
- String votingId = name.substring(indexOf + 1);
- String value = result.getValue();
-
- choicesResults.put(choice, votingId);
- choicesResults.put(choice, value);
-
- } else {
- results2.add(result);
- }
- }
-
- Locale locale = getLocale();
-
- // Récupération du choix correspondant au résultat
- VoteCountingResultDTO voteCountingResult = resultListDTO
- .getVoteCountingResult();
-
- for (String choiceName : choicesResults.keySet()) {
- Collection<String> values = choicesResults.get(choiceName);
-
- for (ChoiceDTO choice : voteCountingResult.getChoices()) {
- if (choiceName.equals(choice.getName())) {
- subtitles.put(
- choiceName,
- l_(locale, "pollen.common.numberVote-total"));
- subtitles.put(
- choiceName,
- String.valueOf(choice.getValue()));
-
- subtitles.put(
- choiceName,
- l_(locale, "pollen.common.numberVote-average"));
- subtitles.put(
- choiceName,
- String.valueOf(choice.getAverage()));
-
- subtitles.put(
- choiceName,
- l_(locale, "pollen.common.numberVote-blank-votes"));
- subtitles.put(
- choiceName,
- String.valueOf(choice.getNbBlankVotes()));
-
- subtitles.put(
- choiceName,
- l_(locale, "pollen.common.numberVote-total-votes"));
- subtitles.put(
- choiceName,
- String.valueOf(values.size() / 2));
- break;
- }
- }
- }
-
- if (results2.size() == 1) {
- results2.remove(0);
- }
- return results2;
- }
-
- public List<PollResult> getTopRanking(List<PollResult> results) {
- List<PollResult> ranking = Lists.newArrayList(results);
-
- Collections.sort(ranking, new Comparator<PollResult>() {
- @Override
- public int compare(PollResult o1, PollResult o2) {
- Double result1 = Double.parseDouble(o1.getValue());
- Double result2 = Double.parseDouble(o2.getValue());
- int comp = 0; // résultat de la comparaison
-
- if (result1 > result2) {
- comp = -1;
- } else if (result1 < result2) {
- comp = 1;
- }
- if (comp == 0) {
- comp = o1.getName().compareTo(o2.getName());
- }
- return comp;
- }
- });
-
- List<PollResult> topRanking = Lists.newArrayList();
-
- if (CollectionUtils.isNotEmpty(ranking)) {
- String winValue = ranking.get(0).getValue();
- for (PollResult r : ranking) {
- if (winValue.equals(r.getValue())) {
- topRanking.add(r);
- }
- }
- }
- return topRanking;
- }
-
/**
* Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un
* double : 1,0 -> 1 et 1,2 -> 1,2.
@@ -386,16 +232,4 @@
}
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -39,6 +39,7 @@
import org.chorem.pollen.bean.PollImageChoice;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceDAO;
+import org.chorem.pollen.business.persistence.ChoiceType;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.business.persistence.Poll;
@@ -50,7 +51,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
-import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.services.PollenServiceFunctions;
import org.chorem.pollen.services.PollenServiceSupport;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollVoteCountingService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollVoteCountingService.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollVoteCountingService.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -23,22 +23,16 @@
package org.chorem.pollen.services.impl;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.Polls;
import org.chorem.pollen.services.PollenServiceSupport;
-import org.chorem.pollen.votecounting.model.ChoiceScore;
import org.chorem.pollen.votecounting.model.GroupOfVoter;
import org.chorem.pollen.votecounting.model.GroupVoteCountingResult;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
-import org.chorem.pollen.votecounting.model.VoteForChoice;
-import org.chorem.pollen.votecounting.model.Voter;
import org.chorem.pollen.votecounting.strategy.VoteCountingStrategy;
-import org.chorem.pollen.votecounting.strategy.VoteCountingStrategyProvider;
-import java.util.Map;
-import java.util.Set;
-
/**
* New Poll vote counting service.
*
@@ -52,106 +46,39 @@
LogFactory.getLog(PollVoteCountingService.class);
/**
- * Provider of {@link VoteCountingStrategy}.
- * <p/>
- * <strong>Note:</strong> this provider should be injected via method
- * {@link #setProvider(VoteCountingStrategyProvider)}.
- */
- private VoteCountingStrategyProvider provider;
-
- public VoteCountingStrategyProvider getProvider() {
- if (provider == null) {
- provider = serviceContext.getVoteCountingStrategyProvider();
- }
- return provider;
- }
-
- public void setProvider(VoteCountingStrategyProvider provider) {
- this.provider = provider;
- }
-
- /**
- * Execute a vote counting for a given strategy (by his id) and the
- * given {@code voters}.
+ * Execute a vote counting for a given poll.
*
- * @param strategyId the id of the vote counting strategy to use
- * @param voter the votes to vote count
+ * @param poll poll on wich vote count
* @return vote counting result
*/
- public VoteCountingResult voteCount(int strategyId, Set<Voter> voter) {
+ public VoteCountingResult getSimpleResult(Poll poll) {
- Preconditions.checkNotNull(getProvider());
- Preconditions.checkNotNull(voter);
-
- VoteCountingStrategy strategy = getProvider().getStrategy(strategyId);
+ Preconditions.checkNotNull(poll);
+ VoteCountingStrategy strategy = Polls.getVoteCountingStrategy(
+ serviceContext.getVoteCountingStrategyProvider(), poll);
Preconditions.checkNotNull(strategy);
- VoteCountingResult result = strategy.votecount(voter);
- return result;
+ // create vote counting model
+ GroupOfVoter group = Polls.toSimpleGroupOfVoters(poll);
+
+ // compute result by the strategy
+ GroupVoteCountingResult result = strategy.votecount(group);
+ return result.getMainResult();
}
- /**
- * Execute a vote counting for a given strategy (by his id) and the
- * given {@code voters}.
- *
- * @param strategyId the id of the vote counting strategy to use
- * @param voter the votes to vote count
- * @return vote counting result
- */
- public GroupVoteCountingResult voteCountByGroup(int strategyId, Set<Voter> voter) {
+ public GroupVoteCountingResult getGroupResult(Poll poll) {
- Preconditions.checkNotNull(getProvider());
- Preconditions.checkNotNull(voter);
-
- VoteCountingStrategy strategy = getProvider().getStrategy(strategyId);
+ Preconditions.checkNotNull(poll);
+ VoteCountingStrategy strategy = Polls.getVoteCountingStrategy(
+ serviceContext.getVoteCountingStrategyProvider(), poll);
Preconditions.checkNotNull(strategy);
// Create a groupVoter including of the root voters
- GroupOfVoter group = GroupOfVoter.newVoter(null, 1.0, null, voter);
+ GroupOfVoter group = Polls.toGroupOfVoters(poll);
-
- Map<GroupOfVoter, VoteCountingResult> groupResults = Maps.newHashMap();
- voteCount(strategy, group, groupResults);
-
- // get result for main group (and remove it from groups)
- VoteCountingResult mainResult = groupResults.remove(group);
-
- GroupVoteCountingResult result = GroupVoteCountingResult.newResult(
- mainResult, groupResults);
+ GroupVoteCountingResult result = strategy.votecount(group);
return result;
}
- protected void voteCount(VoteCountingStrategy strategy,
- GroupOfVoter group,
- Map<GroupOfVoter, VoteCountingResult> results) {
- // all childs of this group
- Set<Voter> voters = group.getVoters();
-
- // treat before all his group childs
- for (Voter voter : voters) {
- if (voter instanceof GroupOfVoter) {
-
- // treat group child before all
- voteCount(strategy, (GroupOfVoter) voter, results);
- }
- }
-
- // once here, all childs has been treated, can votecount this group
- VoteCountingResult voteCountingResult = strategy.votecount(voters);
-
- // store the result for this group
- results.put(group, voteCountingResult);
-
- // result of the group is now the voteForChoice for it
-
- for (ChoiceScore choiceScore : voteCountingResult.getScores()) {
- VoteForChoice voteForChoice = VoteForChoice.newVote(
- choiceScore.getChoiceId(),
- //FIXME-tchemit-2012-06-26 Which is the value to set as choice for each result?
- choiceScore.getScoreValue().doubleValue());
- group.addVoteForChoice(voteForChoice);
- }
-
- }
}
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -34,12 +34,12 @@
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountDAO;
+import org.chorem.pollen.business.persistence.PollType;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteDAO;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceDAO;
-import org.chorem.pollen.common.PollType;
import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
Modified: trunk/pollen-ui-struts2/pom.xml
===================================================================
--- trunk/pollen-ui-struts2/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
@@ -17,42 +17,19 @@
<artifactId>pollen-ui-struts2</artifactId>
<dependencies>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pollen-votecounting-api</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting-strategy</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting-strategy-borda</artifactId>
- </exclusion>
- <exclusion>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting-strategy-coombs</artifactId>
- </exclusion>
- <exclusion>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting-strategy-instant-runoff</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-votecounting</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>pollen-persistence</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pollen-services</artifactId>
@@ -60,8 +37,10 @@
</dependency>
<dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-validator</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>pollen-votecounting-strategy</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
<scope>runtime</scope>
</dependency>
@@ -115,47 +94,46 @@
</dependency>
<dependency>
- <groupId>com.jgeppert.struts2.jquery</groupId>
- <artifactId>struts2-jquery-plugin</artifactId>
- <scope>runtime</scope>
+ <groupId>org.jfree</groupId>
+ <artifactId>jfreechart</artifactId>
</dependency>
<dependency>
- <groupId>com.jgeppert.struts2.jquery</groupId>
- <artifactId>struts2-jquery-grid-plugin</artifactId>
- <scope>runtime</scope>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-runner</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts2-json-plugin</artifactId>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-web</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts2-sitemesh-plugin</artifactId>
- <scope>runtime</scope>
+ <groupId>org.jfree</groupId>
+ <artifactId>jcommon</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts2-jfreechart-plugin</artifactId>
- <scope>runtime</scope>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
</dependency>
<dependency>
- <groupId>org.jfree</groupId>
- <artifactId>jfreechart</artifactId>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-runner</artifactId>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-core</artifactId>
</dependency>
+ <!-- Provided dependencies -->
+
<dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-web</artifactId>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -164,48 +142,57 @@
<scope>provided</scope>
</dependency>
+ <!-- Runtime dependencies -->
+
<dependency>
- <groupId>org.jfree</groupId>
- <artifactId>jcommon</artifactId>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-validator</artifactId>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-plugin</artifactId>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-grid-plugin</artifactId>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-core</artifactId>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-json-plugin</artifactId>
</dependency>
- <!-- Provided dependencies -->
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-sitemesh-plugin</artifactId>
+ <scope>runtime</scope>
</dependency>
- <!-- Runtime dependencies -->
<dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-jfreechart-plugin</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
- <!-- base h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
- <!-- test dependencies -->
+ <!-- Test dependencies -->
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -35,6 +35,7 @@
import org.chorem.pollen.PollenUserSecurityContext;
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.Polls;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.DefaultPollenServiceContext;
import org.chorem.pollen.services.PollenServiceContext;
@@ -458,10 +459,8 @@
}
protected VoteCountingStrategy getVoteCountingStrategy(Poll poll) {
- int voteCountingType = poll.getVoteCountingType();
- VoteCountingStrategy result =
- getVoteCountingStrategyProvider().getStrategy(voteCountingType);
- return result;
+ return Polls.getVoteCountingStrategy(getVoteCountingStrategyProvider(),
+ poll);
}
/**
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,33 +22,32 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.views.util.UrlHelper;
-import org.chorem.pollen.bean.PollResult;
-import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.bean.PollUrl;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.ChoiceType;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
-import org.chorem.pollen.services.impl.PollResultsService;
+import org.chorem.pollen.business.persistence.Polls;
+import org.chorem.pollen.services.impl.PollVoteCountingService;
import org.chorem.pollen.ui.PollenUIUtils;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollUriAware;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.chorem.pollen.ui.actions.PollenUserSecurityAware;
import org.chorem.pollen.ui.converters.DateConverter;
+import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.GroupVoteCountingResult;
+import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.strategy.VoteCountingStrategy;
-import org.nuiton.util.StringUtil;
+import org.nuiton.topia.persistence.TopiaId;
import java.net.URL;
import java.util.Date;
@@ -70,20 +69,6 @@
private static final Log log = LogFactory.getLog(ResultForPoll.class);
/**
- * Is result by group ?
- *
- * @since 1.3
- */
- private Boolean byGroup;
-
- /**
- * Is user is poll's creator ?
- *
- * @since 1.4
- */
- private boolean creatorUser;
-
- /**
* Is feed exists for this poll ?
*
* @since 1.4
@@ -91,42 +76,18 @@
private boolean feedFileExisting;
/**
- * Résultats du sondage.
- * <p/>
- * La map est indexée par les noms de choix.
- *
- * @since 1.3
- */
- private transient Multimap<String, String> choicesResults;
-
- /**
- * Résultats du sondage.
- *
- * @since 1.3
- */
- private transient Multimap<String, String> subtitles;
-
- /**
* Loaded poll.
*
* @since 1.3
*/
private Poll poll;
- /**
- * Poll results.
- *
- * @since 1.3
- */
- private List<PollResult> results;
+ private GroupVoteCountingResult groupResult;
- /**
- * Top ranking results.
- *
- * @since 1.3
- */
- private List<PollResult> topRanking;
+ private VoteCountingResult pollResult;
+ private Map<String, Choice> choicesById;
+
/**
* Url helper (to build new url)
*
@@ -144,7 +105,7 @@
}
public boolean isCreatorOrAdmin() {
- return creatorUser || isUserAdmin();
+ return getUserSecurityContext().isCreator() || isUserAdmin();
}
public boolean isFeedFileExisting() {
@@ -182,7 +143,7 @@
public String getVoteUrl() {
PollUrl url = getPollUrlService().getPollVoteUrl(poll);
url.getPollUri().setAccountId(getUserSecurityContext().getAccountId());
- if (poll.isPollFree()) {
+ if (isFreePoll()) {
// can removed accountId only for free poll
//FIXME Should found out in ohter case the accountId (if exists for the connected id) if no accountId is given
@@ -191,10 +152,6 @@
return url.getUrl();
}
- public List<PollResult> getResults() {
- return results;
- }
-
public String getPollCreatorName() {
PollAccount creator = poll.getCreator();
String result = creator.getVotingId();
@@ -221,17 +178,17 @@
return result;
}
- public Date getResultAsDate(PollResult result) {
- Date date = new Date(Long.valueOf(result.getName()));
- return date;
+ public GroupVoteCountingResult getGroupResult() {
+ return groupResult;
}
- public Multimap<String, String> getChoicesResults() {
- return choicesResults;
+ public VoteCountingResult getPollResult() {
+ return pollResult;
}
- public Multimap<String, String> getSubtitles() {
- return subtitles;
+ public Date getResultAsDate(String choiceName) {
+ Date date = new Date(Long.valueOf(choiceName));
+ return date;
}
public String getVoteSizeMessage() {
@@ -242,15 +199,10 @@
public String getVictoryMessage() {
- String victoryMessage;
+ Set<ChoiceScore> topRanking = pollResult.getTopRanking();
- VoteCountingStrategy strategy = getVoteCountingStrategy(getPoll());
- boolean displayResultsByChoice = strategy.isDisplayResultsByChoice();
- //FIXME-tchemit-2012-06-24, why doing this ??? Should remove this...
-// if (isNumberVoteCounting()) {
- if (displayResultsByChoice) {
- victoryMessage = null;
- } else if (CollectionUtils.isEmpty(topRanking)) {
+ String victoryMessage;
+ if (CollectionUtils.isEmpty(topRanking)) {
victoryMessage = "";
} else if (topRanking.size() == 1) {
victoryMessage = _("pollen.common.victory");
@@ -260,93 +212,48 @@
return victoryMessage;
}
- /**
- * @param result la résultat à utiliser.
- * @return la valeur du résultat courant sans le .0 final
- */
- public String getTrimValue(PollResult result) {
-
- String value = result.getValue();
-
- // le résultat peut-être un double : 1,0 -> 1 et 1,2 -> 1,2
- if (value.endsWith(".0")) {
- value = value.substring(0, value.indexOf('.'));
- }
- return value;
- }
-
@Override
public String execute() throws Exception {
poll = getUserSecurityContext().getPoll();
+ choicesById = Maps.uniqueIndex(poll.getChoice(), TopiaId.GET_TOPIA_ID);
+
feedFileExisting = getPollFeedService().isFeedExists(poll);
- if (byGroup == null) {
+ PollVoteCountingService voteCountingService =
+ getService(PollVoteCountingService.class);
- // default byGroup value
- byGroup = isGroupPoll();
- }
+ if (isGroupPoll()) {
- creatorUser = getUserSecurityContext().isCreator();
+ // load group result
+ groupResult = voteCountingService.getGroupResult(poll);
- if (poll.isRunning(serviceContext.getCurrentTime())) {
- addFlashWarning(_("pollen.information.pollRunning"));
- }
+ pollResult = groupResult.getMainResult();
+ } else {
- // load results
-
- PollResultsService service = getPollResultsService();
-
- PollResultList resultListDTO = service.getResults(poll);
-
- results = resultListDTO.getPollResults();
-
- if (log.isDebugEnabled()) {
- for (PollResult res : results) {
- log.debug(res
- + ", (voteCounting=" + res.getVoteCountingType()
- + ", byGroup=" + res.isByGroup() + ")");
- }
+ // load simple result
+ pollResult = voteCountingService.getSimpleResult(poll);
}
- VoteCountingStrategy strategy = getVoteCountingStrategy(poll);
- if (strategy.isDisplayResultsByChoice()) {
-
- // resultats des choix cachés
- choicesResults = LinkedHashMultimap.create();
-
- // sous-titres des vrais choix (les choix pas cachés)
- subtitles = ArrayListMultimap.create();
-
- results = service.createNumberVoteCountingResult(
- resultListDTO,
- choicesResults,
- subtitles);
+ if (poll.isRunning(serviceContext.getCurrentTime())) {
+ addFlashWarning(_("pollen.information.pollRunning"));
}
-
- topRanking = service.getTopRanking(results);
-
- if (log.isDebugEnabled()) {
- log.debug("topRanking = " + topRanking);
+ if (log.isInfoEnabled()) {
+ log.info("topRanking = " + pollResult.getTopRanking());
}
-
return SUCCESS;
}
- public List<PollResult> getTopRanking() {
- return topRanking;
- }
-
public boolean isFreePoll() {
- return poll.isPollFree();
+ return Polls.isFreePoll(poll);
}
public boolean isRestrictedPoll() {
- return poll.getPollType() == PollType.RESTRICTED;
+ return Polls.isRestrictedPoll(poll);
}
public boolean isGroupPoll() {
- return poll.getPollType() == PollType.GROUP;
+ return Polls.isGroupPoll(poll);
}
public boolean isTextType() {
@@ -361,23 +268,30 @@
return poll.getChoiceType() == ChoiceType.IMAGE;
}
- public boolean isByGroup() {
- return byGroup;
+ public String getNormalPollResultChartUrl(int width, int height) {
+ return getPollResultChartUrl(pollResult, width, height);
}
- public void setByGroup(boolean byGroup) {
- this.byGroup = byGroup;
+ public String getGroupPollResultChartUrl(String groupId, int width, int height) {
+ VoteCountingResult result = groupResult.getGroupResult(groupId);
+ return getPollResultChartUrl(result, width, height);
}
- /** @return Récupération de la liste des résultats pour le diagramme. */
- public List<String> getChoices() {
+ public String getChoiceName(String id) {
+ String result = choicesById.get(id).getName();
+ return result;
+ }
+ protected String getPollResultChartUrl(VoteCountingResult results,
+ int width, int height) {
+
List<String> choiceValues = Lists.newArrayList();
- for (PollResult result : results) {
- String name = result.getName();
- String value = result.getValue();
+ for (ChoiceScore result : results.getScores()) {
+ String name = getChoiceName(result.getChoiceId());
+ String value = String.valueOf(result.getScoreValue());
+
if (isDateType()) {
// mise en forme de la date
Date date = new Date(Long.parseLong(name));
@@ -387,10 +301,7 @@
choiceValues.add(name);
choiceValues.add(value);
}
- return choiceValues;
- }
- public String getNormalPollResultChartUrl(int width, int height) {
URL applicationUrl = getApplicationUrl();
StringBuilder url = new StringBuilder(applicationUrl.toString());
@@ -400,7 +311,7 @@
params.put("width", width);
params.put("height", height);
params.put("title", "");
- params.put("values", getChoices());
+ params.put("values", choiceValues);
urlHelper.buildParametersString(params, url, "&");
@@ -408,36 +319,4 @@
return chartUrl;
}
- public Set<String> getChoicesResultNames() {
- return choicesResults.keySet();
- }
-
- public String getChoicesResultCharUrl(int width,
- int height,
- String choiceName) {
-
- URL applicationUrl = getApplicationUrl();
- StringBuilder url = new StringBuilder(applicationUrl.toString());
-
- url.append("/io/generateChart");
-
- Map<String, Object> params = Maps.newHashMap();
- params.put("width", width);
- params.put("height", height);
- params.put("title", "");
- params.put("values", choicesResults.get(choiceName));
- params.put("subtitles", subtitles.get(choiceName));
-
- urlHelper.buildParametersString(params, url, "&");
-
- String chartUrl = url.toString();
- return chartUrl;
-
- }
-
- public String getChoicesAsString() {
- List<String> choices = getChoices();
- return StringUtil.join(choices, ",", true);
- }
-
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/form/AbstractPollForm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/form/AbstractPollForm.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/form/AbstractPollForm.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -45,20 +45,20 @@
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceImpl;
+import org.chorem.pollen.business.persistence.ChoiceType;
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.PollCommentVisibility;
+import org.chorem.pollen.business.persistence.PollType;
import org.chorem.pollen.business.persistence.PollVoteVisibility;
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListImpl;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.I18nAble;
-import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.business.persistence.I18nAble;
import org.chorem.pollen.services.PollenServiceFunctions;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollService;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AbstractVoteAction.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AbstractVoteAction.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -29,9 +29,9 @@
import org.apache.struts2.interceptor.ParameterAware;
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.bean.PollResult;
-import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.ChoiceType;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
@@ -40,8 +40,7 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.business.persistence.PollType;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.ui.PollenUIUtils;
@@ -449,11 +448,8 @@
if (isResultAllowed()) {
// load poll results
- PollResultList pollResultList =
- getPollResultsService().getResults(poll);
+ results = getPollResultsService().getResults(poll);
- results = pollResultList.getPollResults();
-
if (log.isDebugEnabled()) {
for (PollResult res : results) {
log.debug(res.getName() + ": " + res.getValue()
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AddChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AddChoice.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/AddChoice.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -28,7 +28,7 @@
import org.chorem.pollen.bean.PollImageChoice;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.business.persistence.ChoiceType;
import org.chorem.pollen.services.PollenServiceFunctions;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.ui.actions.FileUploadAware;
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-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-09-23 13:01:38 UTC (rev 3698)
@@ -66,6 +66,7 @@
pollen.action.voteAction.help=Partager ce lien avec ceux que vous voulez voir voter
pollen.banner.newVersion=Nouvelle version \!
pollen.common.aboutPoll=A propos du sondage
+pollen.common.aboutPollResult=Résultats du sondage
pollen.common.addingChoices=Ajout des choix
pollen.common.administrator=Admin
pollen.common.beginChoiceDate=Date de début des choix
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-09-23 13:01:38 UTC (rev 3698)
@@ -81,42 +81,41 @@
</h4>
<%-- Victoire --%>
-<s:if test="victoryMessage != ''">
- <h4><s:property value="victoryMessage"/>
+<h4><s:property value="victoryMessage"/>
+ <br/>
+ <s:iterator value="pollResult.topRanking" var="result">
+ <s:set name="choiceName" value="%{getChoiceName(#result.choiceId)}"/>
+ <s:if test="textType">
+ <s:property value="%{#choiceName}"/>
+ </s:if>
+ <s:elseif test="dateType">
+ <s:property value="%{getResultAsDate(#choiceName)}"/>
+ </s:elseif>
+ <s:elseif test="imageType">
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false">
+ <s:param name="choiceId" value="%{#choiceName}"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="false"/>
+ </s:url>
+ <s:url id="imageUrlThumb" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false">
+ <s:param name="choiceId" value="%{#choiceName}"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="true"/>
+ </s:url>
+ <a href="<s:property value='imageUrl'/>" rel="lightbox">
+ <img alt="<s:property value='%{#choiceName}'/>"
+ title="<s:property value='%{#choiceName}'/>"
+ src="<s:property value='imageUrlThumb'/>">
+ </a>
+
+ </s:elseif>
<br/>
- <s:iterator value="topRanking" var="result">
- <s:if test="textType">
- <s:property value="name"/>
- </s:if>
- <s:elseif test="dateType">
- <s:property value="%{getResultAsDate(#result)}"/>
- </s:elseif>
- <s:elseif test="imageType">
- <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
- escapeAmp="false">
- <s:param name="choiceId" value="name"/>
- <s:param name="pollId" value="poll.pollId"/>
- <s:param name="thumb" value="false"/>
- </s:url>
- <s:url id="imageUrlThumb" namespace="/io" action="getPollChoiceImage"
- escapeAmp="false">
- <s:param name="choiceId" value="name"/>
- <s:param name="pollId" value="poll.pollId"/>
- <s:param name="thumb" value="true"/>
- </s:url>
- <a href="<s:property value='imageUrl'/>" rel="lightbox">
- <img alt="<s:property value='name'/>"
- title="<s:property value='name'/>"
- src="<s:property value='imageUrlThumb'/>">
- </a>
+ </s:iterator>
+</h4>
- </s:elseif>
- <br/>
- </s:iterator>
- </h4>
-</s:if>
-
-<!-- Diagramme -->
+<%-- Diagramme --%>
<div id="resultChart">
<div class="chartTypeDiv">
<sj:a id='displayChart1' href="#" onclick="return displayCharts(1);">
@@ -133,23 +132,23 @@
</sj:a>
</div>
- <div class="displayTypeDiv">
- <s:if test="groupPoll">
- <s:text name="pollen.common.results"/>
- <s:if test="byGroup">
- <s:a href="%{getResultUrl(false)}">
- <s:text name="pollen.common.normal"/>
- </s:a>
- - <s:text name="pollen.common.group"/>
- </s:if>
- <s:else>
- <s:text name="pollen.common.normal"/> -
- <s:a href="%{getResultUrl(true)}">
- <s:text name="pollen.common.group"/>
- </s:a>
- </s:else>
- </s:if>
- </div>
+ <%--<div class="displayTypeDiv">--%>
+ <%--<s:if test="groupPoll">--%>
+ <%--<s:text name="pollen.common.results"/>--%>
+ <%--<s:if test="byGroup">--%>
+ <%--<s:a href="%{getResultUrl(false)}">--%>
+ <%--<s:text name="pollen.common.normal"/>--%>
+ <%--</s:a>--%>
+ <%--- <s:text name="pollen.common.group"/>--%>
+ <%--</s:if>--%>
+ <%--<s:else>--%>
+ <%--<s:text name="pollen.common.normal"/> ---%>
+ <%--<s:a href="%{getResultUrl(true)}">--%>
+ <%--<s:text name="pollen.common.group"/>--%>
+ <%--</s:a>--%>
+ <%--</s:else>--%>
+ <%--</s:if>--%>
+ <%--</div>--%>
<sj:div id='chartContainer'>
<img id='chart_normal'/>
@@ -157,16 +156,16 @@
<%-- Diagramme par choix --%>
<%--<s:if test="choicesResults != null">--%>
- <%--<div id="resultChart">--%>
- <%--<div>--%>
- <%--<s:iterator value="choicesResultNames" var="choicesResultName"--%>
- <%--status="status">--%>
- <%--<img id='chart_<s:property value="#status.index"/>'--%>
- <%--alt="<s:property/>" title="<s:property/>"--%>
- <%--src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>">--%>
- <%--</s:iterator>--%>
- <%--</div>--%>
- <%--</div>--%>
+ <%--<div id="resultChart">--%>
+ <%--<div>--%>
+ <%--<s:iterator value="choicesResultNames" var="choicesResultName"--%>
+ <%--status="status">--%>
+ <%--<img id='chart_<s:property value="#status.index"/>'--%>
+ <%--alt="<s:property/>" title="<s:property/>"--%>
+ <%--src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>">--%>
+ <%--</s:iterator>--%>
+ <%--</div>--%>
+ <%--</div>--%>
<%--</s:if>--%>
</div>
<!-- Classement -->
Deleted: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -1,54 +0,0 @@
-/*
- * #%L
- * Pollen :: Vote Counting
- * $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.common;
-
-import static org.nuiton.i18n.I18n.n_;
-
-public enum ChoiceType implements I18nAble {
- TEXT(n_("pollen.choiceType.text")),
- DATE(n_("pollen.choiceType.date")),
- IMAGE(n_("pollen.choiceType.image"));
-
- private final String i18nKey;
-
- ChoiceType(String i18nKey) {
- this.i18nKey = i18nKey;
- }
-
- @Override
- public String getI18nKey() {
- return i18nKey;
- }
-
- public static ChoiceType valueOf(int ordinal) {
-
- ChoiceType result = null;
- for (ChoiceType curr : ChoiceType.values()) {
- if (curr.ordinal() == ordinal) {
- result = curr;
- break;
- }
- }
- return result;
- }
-}
Deleted: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/I18nAble.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/I18nAble.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/I18nAble.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -1,34 +0,0 @@
-/*
- * #%L
- * Pollen :: Vote Counting
- * $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.common;
-
-/**
- * Contract to expose a i18n key.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public interface I18nAble {
-
- String getI18nKey();
-}
Deleted: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -1,54 +0,0 @@
-/*
- * #%L
- * Pollen :: Vote Counting
- * $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.common;
-
-import static org.nuiton.i18n.I18n.n_;
-
-public enum PollType implements I18nAble {
-
- FREE(n_("pollen.pollType.free")),
- RESTRICTED(n_("pollen.pollType.restricted")),
- GROUP(n_("pollen.pollType.group"));
-
- private final String i18nKey;
-
- PollType(String i18nKey) {
- this.i18nKey = i18nKey;
- }
-
- @Override
- public String getI18nKey() {
- return i18nKey;
- }
-
- public static PollType valueOf(int ordinal) {
- PollType result = null;
- for (PollType curr : PollType.values()) {
- if (curr.ordinal() == ordinal) {
- result = curr;
- break;
- }
- }
- return result;
- }
-}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,6 +22,7 @@
*/
package org.chorem.pollen.votecounting.model;
+import java.io.Serializable;
import java.math.BigDecimal;
/**
@@ -30,8 +31,10 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public class ChoiceScore implements ChoiceIdAble, Comparable<ChoiceScore> {
+public class ChoiceScore implements ChoiceIdAble, Comparable<ChoiceScore>,Serializable {
+ private static final long serialVersionUID = 1L;
+
/** Id of the choice. */
private String choiceId;
@@ -78,15 +81,5 @@
int i1 = scoreValue == null ? -1 : scoreValue.intValue();
int i2 = o.scoreValue == null ? -1 : o.scoreValue.intValue();
return i1 - i2;
-// BigDecimal v1 = scoreValue;
-// BigDecimal v2 = o.scoreValue;
-// if (v1 == null) {
-// v1 = new BigDecimal(-1);
-// }
-// if (v2 == null) {
-// v2 = new BigDecimal(-1);
-// }
-// int i = v1.subtract(v2).intValue();
-// return i;
}
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -24,6 +24,7 @@
import com.google.common.collect.Sets;
+import java.util.Iterator;
import java.util.Set;
/**
@@ -32,17 +33,12 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public class GroupOfVoter implements Voter {
+public class GroupOfVoter implements Voter, Iterable<Voter> {
- /** Id of the group of voters. */
- private String voterId;
+ private static final long serialVersionUID = 1L;
- /** Weight of the group of voters. */
- private double weight;
+ private final SimpleVoter rootVoter = SimpleVoter.newVoter(null, 1.0, null);
- /** All votes for this group of voters. */
- private Set<VoteForChoice> voteForChoices;
-
/** Set of voters for this group. */
private Set<Voter> voters;
@@ -51,54 +47,37 @@
public static GroupOfVoter newVoter(String voterId,
double weight,
- Set<VoteForChoice> voteForChoices,
Set<Voter> voters) {
GroupOfVoter result = new GroupOfVoter();
result.setVoterId(voterId);
result.setWeight(weight);
- if (voters != null) {
- for (VoteForChoice voteForChoice : voteForChoices) {
- result.addVoteForChoice(voteForChoice);
- }
- }
result.setVoters(voters);
return result;
}
@Override
public String getVoterId() {
- return voterId;
+ return rootVoter.getVoterId();
}
@Override
public double getWeight() {
- return weight;
+ return rootVoter.getWeight();
}
@Override
public Set<VoteForChoice> getVoteForChoices() {
- if (voteForChoices == null) {
- voteForChoices = Sets.newHashSet();
- }
- return voteForChoices;
+ return rootVoter.getVoteForChoices();
}
- public Set<Voter> getVoters() {
- return voters;
- }
-
- public VoteCountingResult getResult() {
- return result;
- }
-
@Override
public void setVoterId(String voterId) {
- this.voterId = voterId;
+ rootVoter.setVoterId(voterId);
}
@Override
public void setWeight(double weight) {
- this.weight = weight;
+ rootVoter.setWeight(weight);
}
@Override
@@ -106,11 +85,38 @@
getVoteForChoices().add(voteForChoice);
}
+ public Set<Voter> getVoters() {
+ if (voters == null) {
+ voters = Sets.newHashSet();
+ }
+ return voters;
+ }
+
+ public void addVoter(Voter voter) {
+ getVoters().add(voter);
+ }
+
+ public VoteCountingResult getResult() {
+ return result;
+ }
+
public void setVoters(Set<Voter> voters) {
this.voters = voters;
}
public void setResult(VoteCountingResult result) {
this.result = result;
+ for (ChoiceScore choiceScore : result.getScores()) {
+ VoteForChoice voteForChoice = VoteForChoice.newVote(
+ choiceScore.getChoiceId(),
+ //FIXME-tchemit-2012-06-26 Which is the value to set as choice for each result?
+ choiceScore.getScoreValue().doubleValue());
+ addVoteForChoice(voteForChoice);
+ }
}
+
+ @Override
+ public Iterator<Voter> iterator() {
+ return getVoters().iterator();
+ }
}
Added: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java (rev 0)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -0,0 +1,69 @@
+package org.chorem.pollen.votecounting.model;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
+/**
+ * {@link GroupOfVoter} builder.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4.6
+ */
+public class GroupOfVoterBuilder implements VoterBuilder {
+
+ private Set<Voter> voters = Sets.newHashSet();
+
+ private GroupOfVoter groupOfVoter;
+
+ private Voter voter;
+
+ @Override
+ public Set<Voter> getVoters() {
+ flush();
+ return voters;
+ }
+
+ @Override
+ public GroupOfVoterBuilder newVoter(String voterId, double weight) {
+ Preconditions.checkState(groupOfVoter != null, "No groupOfVoter defined, use method newGroupVoter before");
+ flushVoter();
+ voter = SimpleVoter.newVoter(voterId, weight, null);
+ return this;
+ }
+
+ @Override
+ public GroupOfVoterBuilder addVoteForChoice(String choiceId, Double voteValue) {
+ Preconditions.checkState(voter != null, "No voter defined, use method newVoter before this one");
+ VoteForChoice voteForChoice = VoteForChoice.newVote(choiceId, voteValue);
+ voter.addVoteForChoice(voteForChoice);
+ return this;
+ }
+
+ public GroupOfVoterBuilder newGroupVoter(String voterId, double weight) {
+ flush();
+ groupOfVoter = GroupOfVoter.newVoter(voterId, weight, null);
+ return this;
+ }
+
+ public void flushVoter() {
+ if (voter != null) {
+ groupOfVoter.addVoter(voter);
+ voter = null;
+ }
+ }
+
+ @Override
+ public void flush() {
+ if (groupOfVoter != null) {
+ flushVoter();
+ voters.add(groupOfVoter);
+ groupOfVoter = null;
+ }
+ }
+
+ public GroupOfVoter getRoot() {
+ return (GroupOfVoter) getVoters().iterator().next();
+ }
+}
Property changes on: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoterBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupVoteCountingResult.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupVoteCountingResult.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupVoteCountingResult.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,7 +22,12 @@
*/
package org.chorem.pollen.votecounting.model;
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+
+import java.io.Serializable;
import java.util.Map;
+import java.util.Set;
/**
* TODO
@@ -30,34 +35,43 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public class GroupVoteCountingResult {
+public class GroupVoteCountingResult implements Serializable {
- protected VoteCountingResult mainResult;
+ private static final long serialVersionUID = 1L;
- protected Map<GroupOfVoter, VoteCountingResult> groupResults;
+ protected GroupOfVoter voter;
- public static GroupVoteCountingResult newResult(
- VoteCountingResult mainResult,
- Map<GroupOfVoter, VoteCountingResult> groupResults) {
+ protected Map<String, GroupOfVoter> groups;
+
+ public static GroupVoteCountingResult newResult(GroupOfVoter voter,
+ Set<GroupOfVoter> groups) {
GroupVoteCountingResult result = new GroupVoteCountingResult();
- result.setMainResult(mainResult);
- result.setGroupResults(groupResults);
+ result.setVoter(voter);
+ groups.remove(voter);
+ result.setGroups(groups);
return result;
}
public VoteCountingResult getMainResult() {
- return mainResult;
+ return voter.getResult();
}
- public void setMainResult(VoteCountingResult mainResult) {
- this.mainResult = mainResult;
+ public void setVoter(GroupOfVoter voter) {
+ this.voter = voter;
}
- public Map<GroupOfVoter, VoteCountingResult> getGroupResults() {
- return groupResults;
+ public void setGroups(Set<GroupOfVoter> groups) {
+ this.groups = Maps.uniqueIndex(groups, new Function<GroupOfVoter, String>() {
+ @Override
+ public String apply(GroupOfVoter input) {
+ return input.getVoterId();
+ }
+ });
}
- public void setGroupResults(Map<GroupOfVoter, VoteCountingResult> groupResults) {
- this.groupResults = groupResults;
+ public VoteCountingResult getGroupResult(String groupId) {
+ GroupOfVoter groupOfVoter = groups.get(groupId);
+ VoteCountingResult result = groupOfVoter.getResult();
+ return result;
}
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -34,6 +34,8 @@
*/
public class SimpleVoter implements Voter {
+ private static final long serialVersionUID = 1L;
+
/** Id of the voter. */
private String voterId;
Added: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java (rev 0)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -0,0 +1,48 @@
+package org.chorem.pollen.votecounting.model;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
+/**
+ * {@link SimpleVoter} builder.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4.6
+ */
+public class SimpleVoterBuilder implements VoterBuilder {
+
+ private Set<Voter> voters = Sets.newHashSet();
+
+ private Voter voter;
+
+ @Override
+ public SimpleVoterBuilder newVoter(String voterId, double weight) {
+ flush();
+ voter = SimpleVoter.newVoter(voterId, weight, null);
+ return this;
+ }
+
+ @Override
+ public SimpleVoterBuilder addVoteForChoice(String choiceId, Double voteValue) {
+ Preconditions.checkState(voter != null,"No voter defined, use method newVoter before this one");
+ VoteForChoice voteForChoice = VoteForChoice.newVote(choiceId, voteValue);
+ voter.addVoteForChoice(voteForChoice);
+ return this;
+ }
+
+ @Override
+ public Set<Voter> getVoters() {
+ flush();
+ return voters;
+ }
+
+ @Override
+ public void flush() {
+ if (voter != null) {
+ voters.add(voter);
+ voter = null;
+ }
+ }
+}
Property changes on: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoterBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,7 +22,15 @@
*/
package org.chorem.pollen.votecounting.model;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.apache.commons.collections.CollectionUtils;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Collections;
import java.util.List;
+import java.util.Set;
/**
* Contains results for a vote.
@@ -30,11 +38,15 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public class VoteCountingResult {
+public class VoteCountingResult implements Serializable {
+ private static final long serialVersionUID = 1L;
+
/** Results for each choice. */
private List<ChoiceScore> scores;
+ private Set<ChoiceScore> topRanking;
+
public static VoteCountingResult newResult(List<ChoiceScore> scores) {
VoteCountingResult result = new VoteCountingResult();
result.setScores(scores);
@@ -45,7 +57,37 @@
return scores;
}
+ public ChoiceScore getScore(String choiceId) {
+ ChoiceScore result = null;
+ for (ChoiceScore score : scores) {
+ if (choiceId.equals(score.getChoiceId())) {
+ result = score;
+ break;
+ }
+ }
+ return result;
+ }
+
public void setScores(List<ChoiceScore> scores) {
this.scores = scores;
+ List<ChoiceScore> ranking = Lists.newArrayList(getScores());
+
+ Collections.sort(ranking);
+ Collections.reverse(ranking);
+
+ topRanking = Sets.newHashSet();
+
+ if (CollectionUtils.isNotEmpty(ranking)) {
+ BigDecimal winValue = ranking.get(0).getScoreValue();
+ for (ChoiceScore r : ranking) {
+ if (winValue.equals(r.getScoreValue())) {
+ topRanking.add(r);
+ }
+ }
+ }
}
+
+ public Set<ChoiceScore> getTopRanking() {
+ return topRanking;
+ }
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteForChoice.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteForChoice.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteForChoice.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,14 +22,19 @@
*/
package org.chorem.pollen.votecounting.model;
+import java.io.Serializable;
+
/**
* A vote for a choice.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public class VoteForChoice implements ChoiceIdAble {
+public class VoteForChoice implements ChoiceIdAble, Serializable {
+ private static final long serialVersionUID = 1L;
+
+
/** Id of the choice. */
private String choiceId;
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,6 +22,7 @@
*/
package org.chorem.pollen.votecounting.model;
+import java.io.Serializable;
import java.util.Set;
/**
@@ -30,7 +31,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public interface Voter {
+public interface Voter extends Serializable {
/**
* Gets the voter unique id.
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoterBuilder.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoterBuilder.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoterBuilder.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -22,9 +22,6 @@
*/
package org.chorem.pollen.votecounting.model;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-
import java.util.Set;
/**
@@ -33,34 +30,13 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4.5
*/
-public class VoterBuilder {
+public interface VoterBuilder {
- private Set<Voter> voters = Sets.newHashSet();
+ public VoterBuilder newVoter(String voterId, double weight);
- private Voter voter;
+ public VoterBuilder addVoteForChoice(String choiceId, Double voteValue);
- public VoterBuilder newVoter(String voterId, double weight) {
- flushVoter();
- voter = SimpleVoter.newVoter(voterId, weight, null);
- return this;
- }
+ public Set<Voter> getVoters();
- public VoterBuilder addVoteForChoice(String choiceId, Double voteValue) {
- Preconditions.checkState(voter != null);
- VoteForChoice voteForChoice = VoteForChoice.newVote(choiceId, voteValue);
- voter.addVoteForChoice(voteForChoice);
- return this;
- }
-
- public Set<Voter> getVoters() {
- flushVoter();
- return voters;
- }
-
- protected void flushVoter() {
- if (voter != null) {
- voters.add(voter);
- voter = null;
- }
- }
+ public void flush();
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/AbstractVoteCountingStrategy.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/AbstractVoteCountingStrategy.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/AbstractVoteCountingStrategy.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -28,6 +28,8 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.GroupOfVoter;
+import org.chorem.pollen.votecounting.model.GroupVoteCountingResult;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.VoteForChoice;
import org.chorem.pollen.votecounting.model.Voter;
@@ -56,6 +58,17 @@
public static final BigDecimal ZERO_D = BigDecimal.valueOf(0.);
@Override
+ public final GroupVoteCountingResult votecount(GroupOfVoter group) {
+
+ Set<GroupOfVoter> groups = Sets.newHashSet();
+ voteCount(group, groups);
+
+ GroupVoteCountingResult result = GroupVoteCountingResult.newResult(
+ group, groups);
+ return result;
+ }
+
+ @Override
public String getStrategyName(Locale locale) {
String result = l_(locale, getI18nName());
return result;
@@ -171,6 +184,29 @@
return result;
}
+ protected void voteCount(GroupOfVoter group, Set<GroupOfVoter> groups) {
+
+ groups.add(group);
+
+ // all childs of this group
+ Set<Voter> voters = group.getVoters();
+
+ // treat before all his group childs
+ for (Voter voter : voters) {
+ if (voter instanceof GroupOfVoter) {
+
+ // treat group child before all
+ voteCount((GroupOfVoter) voter, groups);
+ }
+ }
+
+ // once here, all childs has been treated, can votecount this group
+ VoteCountingResult voteCountingResult = votecount(voters);
+
+ // store the result for this group
+ group.setResult(voteCountingResult);
+ }
+
public static class VoteForChoiceComparator implements Comparator<VoteForChoice>, Serializable {
private static final long serialVersionUID = 1L;
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -23,6 +23,8 @@
package org.chorem.pollen.votecounting.strategy;
import org.chorem.pollen.votecounting.model.ChoiceToVoteRenderType;
+import org.chorem.pollen.votecounting.model.GroupOfVoter;
+import org.chorem.pollen.votecounting.model.GroupVoteCountingResult;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
@@ -58,6 +60,8 @@
*/
String getI18nHelp();
+ GroupVoteCountingResult votecount(GroupOfVoter group);
+
/**
* Vote count for the given {@code voter} and return the result of it.
*
Modified: trunk/pollen-votecounting-strategy-borda/src/test/java/org/chorem/pollen/votecounting/strategy/BordaStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-borda/src/test/java/org/chorem/pollen/votecounting/strategy/BordaStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-borda/src/test/java/org/chorem/pollen/votecounting/strategy/BordaStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,9 +26,9 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -81,7 +81,7 @@
// D 17 15 26 42 207 (=17*4+15*3+26*2+42)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("Ville A", 42.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -125,7 +125,7 @@
// 2 (a=3 b=2 c=1) c(3) > b(2) > a(1)
// 3 (a=1 b=null c=2) a(3) > c(2) > b(1)
// Result a = 2*3+1=7, b =2*2+1=5, c = 1*3+1*2+1=6
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -161,7 +161,7 @@
// 3 (a=null b=null c=2) c>a|b
// Result (a=3*2+2=8 b=2*3=6 c=1+2*3=7)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -197,7 +197,7 @@
// 3 (a=null b=null c=1) c(3) > a|c(2)
// Result (a=3+2*2=7 b=3+2*2=7 c=3+2*2=7)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -236,7 +236,7 @@
// 3 (x1) (a=null b=1 c=2) b(3) > c(2) > a(1)
// Result (a=2*3+1*2+1*1=9 b=2*2+1*3+1*3=10 c=2*2+1*2+1*2=8)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -272,7 +272,7 @@
// 3 (x3) (a=null b=2 c=1) c(3) > b(2) > a(1)
// Result (a=1*3*2+1*2+1*1*3=11 b=2*2+1*3+3*2=13 c=2*2+1*2+3*3=15)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pollen-votecounting-strategy-condorcet/src/test/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-condorcet/src/test/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-condorcet/src/test/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,9 +26,9 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -76,7 +76,7 @@
// 3 (a=1 b=null c=2)
// Result (a=6 b=1 c=2)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -112,7 +112,7 @@
// 3 (a=1 b=null c=2)
// Result (a=4 b=2 c=3)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -148,7 +148,7 @@
// 3 (a=null b=null c=2)
// Result (a=3 b=1 c=3)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -186,7 +186,7 @@
// 3 (a=null b=null c=1)
// Result (a=2 b=2 c=2)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -225,7 +225,7 @@
// 3 (x1) (a=null b=1 c=2)
// Result (a=2 b=2 c=1)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -263,7 +263,7 @@
// 3 (x3) (a=null b=2 c=1)
// Result (a=2 b=4 c=3)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pollen-votecounting-strategy-coombs/src/test/java/org/chorem/pollen/votecounting/strategy/CoombsStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-coombs/src/test/java/org/chorem/pollen/votecounting/strategy/CoombsStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-coombs/src/test/java/org/chorem/pollen/votecounting/strategy/CoombsStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,9 +26,9 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -82,7 +82,7 @@
// C 15 43 42 0 15 15
// D 17 15 26 42 17 17
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("Ville A", 42.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -126,7 +126,7 @@
// 2 (a=3 b=2 c=1) b 1
// 3 (a=1 b=null c=2) c -
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -161,7 +161,7 @@
// 2 (a=1 b=2 c=1) b -
// 3 (a=null b=null c=2) c 2
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -198,7 +198,7 @@
// 2 (a=null b=1 c=null) b 1
// 3 (a=null b=null c=1) c 1
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -236,7 +236,7 @@
// 2 (x1) (a=null b=1 c=null) b 2
// 3 (x1) (a=null b=1 c=2) c -
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -273,7 +273,7 @@
// 2 (x1) (a=null b=1 c=null) b 1
// 3 (x3) (a=null b=2 c=1) c 3
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pollen-votecounting-strategy-instant-runoff/src/test/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-instant-runoff/src/test/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-instant-runoff/src/test/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,9 +26,9 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -82,7 +82,7 @@
// C 15 43 42 0 15 - -
// D 17 15 26 42 17 32 58
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("Ville A", 42.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -126,7 +126,7 @@
// 2 (a=3 b=2 c=1) b 1
// 3 (a=1 b=null c=2) c -
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -161,7 +161,7 @@
// 2 (a=1 b=2 c=1) b -
// 3 (a=null b=null c=2) c 2
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -198,7 +198,7 @@
// 2 (a=null b=1 c=null) b 1
// 3 (a=null b=null c=1) c 1
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -236,7 +236,7 @@
// 2 (x1) (a=null b=1 c=null) b 2
// 3 (x1) (a=null b=1 c=2) c -
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -273,7 +273,7 @@
// 2 (x1) (a=null b=1 c=null) b 1
// 3 (x3) (a=null b=2 c=1) c 3
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pollen-votecounting-strategy-normal/src/test/java/org/chorem/pollen/votecounting/strategy/NormalStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-normal/src/test/java/org/chorem/pollen/votecounting/strategy/NormalStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-normal/src/test/java/org/chorem/pollen/votecounting/strategy/NormalStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,12 +26,16 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.GroupOfVoter;
+import org.chorem.pollen.votecounting.model.GroupOfVoterBuilder;
+import org.chorem.pollen.votecounting.model.GroupVoteCountingResult;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import java.math.BigDecimal;
@@ -76,7 +80,7 @@
// 3 (a=null b=1 c=1)
// Result (a=1 b=2 c=1)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -106,7 +110,65 @@
CHOICE_A, CHOICE_C);
}
+ //TODO Finish me
+ @Ignore
@Test
+ public void groupVotecount() throws Exception {
+
+ // Group poll (all weight to 1)
+ // 1 (a=1 b=null c=null)
+ // 2 (a=null b=1 c=null)
+ // 3 (a=null b=1 c=1)
+ // Result (a=1 b=2 c=1)
+
+ GroupOfVoter voters = new GroupOfVoterBuilder().
+ newGroupVoter("G1", 1.).
+ newVoter("G1U1", 1.).
+ addVoteForChoice(CHOICE_A, 1.).
+ addVoteForChoice(CHOICE_B, null).
+ addVoteForChoice(CHOICE_C, null).
+ newVoter("G1U2", 2.).
+ addVoteForChoice(CHOICE_A, null).
+ addVoteForChoice(CHOICE_B, 1.).
+ addVoteForChoice(CHOICE_C, null).
+ newVoter("G1U3", 3.).
+ addVoteForChoice(CHOICE_A, null).
+ addVoteForChoice(CHOICE_B, 1.).
+ addVoteForChoice(CHOICE_C, 1.).
+ newGroupVoter("G2", 1.).
+ newVoter("G2U1", 1.).
+ addVoteForChoice(CHOICE_A, null).
+ addVoteForChoice(CHOICE_B, 2.0).
+ addVoteForChoice(CHOICE_C, null).
+ newVoter("G2U2", 1.).
+ addVoteForChoice(CHOICE_A, 1.0).
+ addVoteForChoice(CHOICE_B, null).
+ addVoteForChoice(CHOICE_C, null).
+ newVoter("G2U3", 1.).
+ addVoteForChoice(CHOICE_A, null).
+ addVoteForChoice(CHOICE_B, 1.).
+ addVoteForChoice(CHOICE_C, 1.).
+ getRoot();
+
+ GroupVoteCountingResult result = strategy.votecount(voters);
+
+ Assert.assertNotNull(result);
+ VoteCountingResult mainResult = result.getMainResult();
+ Assert.assertNotNull(mainResult);
+
+ List<ChoiceScore> scores = mainResult.getScores();
+ Assert.assertNotNull(scores);
+ Assert.assertEquals(3, scores.size());
+
+ assertChoiceScore(scores.get(0), CHOICE_B, BigDecimal.valueOf(2.));
+
+ assertChoiceScoreEquals(BigDecimal.valueOf(1.),
+ Sets.newHashSet(scores.get(1),
+ scores.get(2)),
+ CHOICE_A, CHOICE_C);
+ }
+
+ @Test
public void simpleVotecount2() throws Exception {
// Simple poll (all weight to 1)
@@ -114,7 +176,7 @@
// 2 (a=1 b=1 c=null)
// 3 (a=1 b=1 c=null)
// Result (a=3 b=2 c=null)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -149,7 +211,7 @@
// 2 (a=1 b=1 c=null)
// 3 (a=1 b=1 c=null)
// Result (a=3 b=3 c=null)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 1.).
@@ -186,7 +248,7 @@
// 2 (x1) (a=null b=1 c=null)
// 3 (x1) (a=null b=1 c=1)
// Result (a=2 b=2 c=1)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -223,7 +285,7 @@
// 2 (x1) (a=null b=1 c=null)
// 3 (x3) (a=null b=1 c=1)
// Result (a=2 b=4 c=3)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pollen-votecounting-strategy-number/src/test/java/org/chorem/pollen/votecounting/strategy/NumberStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-number/src/test/java/org/chorem/pollen/votecounting/strategy/NumberStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-number/src/test/java/org/chorem/pollen/votecounting/strategy/NumberStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,9 +26,9 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -76,7 +76,7 @@
// 3 (a=7 b=12 c=20)
// Result (a=10 b=14 c=23)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 2.).
@@ -111,7 +111,7 @@
// 2 (a=1 b=1 c=null)
// 3 (a=1 b=1 c=null)
// Result (a=3 b=2 c=null)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -146,7 +146,7 @@
// 2 (a=1 b=1 c=null)
// 3 (a=1 b=1 c=null)
// Result (a=3 b=3 c=null)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, 1.).
@@ -183,7 +183,7 @@
// 2 (x1) (a=null b=1 c=null)
// 3 (x1) (a=null b=1 c=1)
// Result (a=2 b=2 c=1)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
@@ -220,7 +220,7 @@
// 2 (x1) (a=null b=1 c=null)
// 3 (x3) (a=null b=1 c=1)
// Result (a=2 b=4 c=3)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 1.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pollen-votecounting-strategy-percentage/src/test/java/org/chorem/pollen/votecounting/strategy/PercentageStrategyTest.java
===================================================================
--- trunk/pollen-votecounting-strategy-percentage/src/test/java/org/chorem/pollen/votecounting/strategy/PercentageStrategyTest.java 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pollen-votecounting-strategy-percentage/src/test/java/org/chorem/pollen/votecounting/strategy/PercentageStrategyTest.java 2012-09-23 13:01:38 UTC (rev 3698)
@@ -26,9 +26,9 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.votecounting.model.ChoiceIdAble;
import org.chorem.pollen.votecounting.model.ChoiceScore;
+import org.chorem.pollen.votecounting.model.SimpleVoterBuilder;
import org.chorem.pollen.votecounting.model.VoteCountingResult;
import org.chorem.pollen.votecounting.model.Voter;
-import org.chorem.pollen.votecounting.model.VoterBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -76,7 +76,7 @@
// 3 (a=50 b=50 c=null)
// Result (a=100 b=150 c=null)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 100.).
addVoteForChoice(CHOICE_B, null).
@@ -114,7 +114,7 @@
// 2 (a=50 b=20 c=30)
// 3 (a=10 b=50 c=40)
// Result (a=80 b=100 c=120)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 20.).
addVoteForChoice(CHOICE_B, 30.).
@@ -149,7 +149,7 @@
// 2 (a=50 b=50 c=null)
// 3 (a=50 b=50 c=null)
// Result (a=150 b=150 c=null)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 1.).
addVoteForChoice(CHOICE_A, 50.).
addVoteForChoice(CHOICE_B, 50.).
@@ -186,7 +186,7 @@
// 2 (x1) (a=null b=100 c=null)
// 3 (x1) (a=null b=50 c=50)
// Result (a=200 b=150 c=50)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 100.).
addVoteForChoice(CHOICE_B, null).
@@ -220,7 +220,7 @@
// 2 (x1) (a=null b=100 c=null)
// 3 (x3) (a=null b=50 c=50)
// Result (a=200 b=250 c=150)
- Set<Voter> voters = new VoterBuilder().
+ Set<Voter> voters = new SimpleVoterBuilder().
newVoter("1", 2.).
addVoteForChoice(CHOICE_A, 100.).
addVoteForChoice(CHOICE_B, null).
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
+++ trunk/pom.xml 2012-09-23 13:01:38 UTC (rev 3698)
@@ -20,7 +20,6 @@
<modules>
<module>pollen-votecounting-api</module>
<module>pollen-votecounting-strategy</module>
- <module>pollen-votecounting</module>
<module>pollen-persistence</module>
<module>pollen-services</module>
<module>pollen-ui-struts2</module>
1
0
19 Sep '12
Author: tchemit
Date: 2012-09-19 17:48:36 +0200 (Wed, 19 Sep 2012)
New Revision: 3697
Url: http://chorem.org/repositories/revision/pollen/3697
Log:
remove reporting profile from poms for modules with no site
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-services/pom.xml
trunk/pollen-ui-struts2/pom.xml
trunk/pollen-votecounting-api/pom.xml
trunk/pollen-votecounting-strategy-borda/pom.xml
trunk/pollen-votecounting-strategy-condorcet/pom.xml
trunk/pollen-votecounting-strategy-coombs/pom.xml
trunk/pollen-votecounting-strategy-instant-runoff/pom.xml
trunk/pollen-votecounting-strategy-normal/pom.xml
trunk/pollen-votecounting-strategy-number/pom.xml
trunk/pollen-votecounting-strategy-percentage/pom.xml
trunk/pollen-votecounting-strategy/pom.xml
trunk/pollen-votecounting/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-persistence/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -148,45 +148,5 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
- </profiles>
-
</project>
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-services/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -138,45 +138,5 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
- </profiles>
-
</project>
Modified: trunk/pollen-ui-struts2/pom.xml
===================================================================
--- trunk/pollen-ui-struts2/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-ui-struts2/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -653,43 +653,6 @@
</reporting>
</profile>
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
</profiles>
</project>
Modified: trunk/pollen-votecounting/pom.xml
===================================================================
--- trunk/pollen-votecounting/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -61,45 +61,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-api/pom.xml
===================================================================
--- trunk/pollen-votecounting-api/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-api/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -58,45 +58,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -71,46 +71,5 @@
<packaging>pom</packaging>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-borda/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-borda/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-borda/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -62,45 +62,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-condorcet/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-condorcet/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-condorcet/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -60,45 +60,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-coombs/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-coombs/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-coombs/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -62,45 +62,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-instant-runoff/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-instant-runoff/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-instant-runoff/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -62,45 +62,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-normal/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-normal/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-normal/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -56,45 +56,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-number/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-number/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-number/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -56,45 +56,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
Modified: trunk/pollen-votecounting-strategy-percentage/pom.xml
===================================================================
--- trunk/pollen-votecounting-strategy-percentage/pom.xml 2012-09-19 15:42:53 UTC (rev 3696)
+++ trunk/pollen-votecounting-strategy-percentage/pom.xml 2012-09-19 15:48:36 UTC (rev 3697)
@@ -64,45 +64,4 @@
</plugins>
</build>
- <profiles>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <reportPlugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reports>
- <report>index</report>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependency-convergence</report>
- <report>dependency-management</report>
- </reports>
- </plugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- </profiles>
-
</project>
1
0
r3696 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence
by tchemit@users.chorem.org 19 Sep '12
by tchemit@users.chorem.org 19 Sep '12
19 Sep '12
Author: tchemit
Date: 2012-09-19 17:42:53 +0200 (Wed, 19 Sep 2012)
New Revision: 3696
Url: http://chorem.org/repositories/revision/pollen/3696
Log:
fixes #813: Impossible de consulter une liste de votants
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java
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-09-19 15:42:39 UTC (rev 3695)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java 2012-09-19 15:42:53 UTC (rev 3696)
@@ -31,7 +31,6 @@
import org.nuiton.topia.persistence.pager.TopiaPagerBean;
import org.nuiton.util.PagerBeanUtil;
-import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -122,7 +121,7 @@
mapResult.put(poll, pollAccount);
}
long records = mapResult.size();
- pager.setRecords((int) records);
+ pager.setRecords(records);
PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
List<Map.Entry<Poll, PollAccount>> entries =
Lists.newLinkedList(mapResult.entrySet());
@@ -137,7 +136,7 @@
PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
List<E> subList = PagerBeanUtil.getPage(elements, pager.getPageIndex(), pager.getPageSize());
- List<E> result = new ArrayList<E>(subList);
+ List<E> result = Lists.newArrayList(subList);
return result;
}
1
0
r3695 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence
by tchemit@users.chorem.org 19 Sep '12
by tchemit@users.chorem.org 19 Sep '12
19 Sep '12
Author: tchemit
Date: 2012-09-19 17:42:39 +0200 (Wed, 19 Sep 2012)
New Revision: 3695
Url: http://chorem.org/repositories/revision/pollen/3695
Log:
fixes #812: Impossible de cr?\195?\169er une liste ?\195?\160 la main ou par import CSV
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-09-19 10:07:17 UTC (rev 3694)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-09-19 15:42:39 UTC (rev 3695)
@@ -30,6 +30,7 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.pager.TopiaPagerBean;
+import org.nuiton.util.PagerBeanUtil;
import java.util.List;
@@ -175,6 +176,7 @@
int records = favoriteList.sizePollAccount();
pager.setRecords(records);
+ PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
String hql = createSimpleQuery("e") + " WHERE e.personList = :owner";
@@ -188,7 +190,7 @@
Preconditions.checkNotNull(personListToUpdate);
Preconditions.checkNotNull(pollAccount);
- String hql = createSimpleQuery("e") + " WHERE " +
+ String hql = "SELECT COUNT(*) " + createSimpleQuery("e") + " WHERE " +
"e.personList = :person AND " +
"e.email = :email";
String pollAccountId = pollAccount.getTopiaId();
1
0
r3694 - trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 19 Sep '12
by tchemit@users.chorem.org 19 Sep '12
19 Sep '12
Author: tchemit
Date: 2012-09-19 12:07:17 +0200 (Wed, 19 Sep 2012)
New Revision: 3694
Url: http://chorem.org/repositories/revision/pollen/3694
Log:
remove commented code
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-09-19 10:07:02 UTC (rev 3693)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-09-19 10:07:17 UTC (rev 3694)
@@ -71,52 +71,16 @@
<h1 class="titleVoteCounting"><s:property value="poll.title"/></h1>
-<!-- Informations sur le sondage -->
+<%-- Informations sur le sondage --%>
<s:set name="showVoteUrl" value="true"/>
<s:set name="showResultUrl" value="false"/>
<%@include file="pollInformation.jsp" %>
-<%--<div id="resultTop">--%>
- <%--<div style="white-space:pre-wrap; text-align: start;">--%>
- <%--<s:property value="poll.description"/>--%>
- <%--</div>--%>
- <%--<fieldset>--%>
- <%--<legend><s:text name="pollen.common.aboutPoll"/></legend>--%>
- <%--<div style="float: right">--%>
- <%--<s:if test="creatorOrAdmin">--%>
- <%--<s:a href="%{summaryUrl}">--%>
- <%--<img src="<s:url value='/img/editSmall.png'/>"--%>
- <%--title="<s:text name='pollen.action.summaryPoll'/>"--%>
- <%--alt="<s:text name='pollen.action.summaryPoll'/>"/>--%>
- <%--</s:a>--%>
- <%--</s:if>--%>
- <%--<s:a href='%{voteUrl}'>--%>
- <%--<img src="<s:url value='/img/vote.png'/>"--%>
- <%--title="<s:text name="pollen.common.vote.return-help"/>"--%>
- <%--alt="<s:text name="pollen.common.vote.return"/>"/>--%>
- <%--</s:a>--%>
- <%--<s:if test="feedFileExisting">--%>
- <%--<s:a namespace="/poll" action="getFeed">--%>
- <%--<s:param name="pollId" value="poll.pollId"/>--%>
- <%--<img src="<s:url value='/img/feed.png'/>" title="Atom" alt="Atom"/>--%>
- <%--</s:a>--%>
- <%--</s:if>--%>
- <%--</div>--%>
- <%--<s:label value="%{pollCreatorName}" key='pollen.common.pollCreator'/>--%>
- <%--<s:label value="%{pollBeginDate}" key='pollen.common.beginDate'/>--%>
- <%--<s:label value="%{pollEndDate}" key='pollen.common.endDate'/>--%>
- <%--<s:label value="%{voteCountingTypeName}"--%>
- <%--key='pollen.common.voteCountingType'--%>
- <%--tooltip="%{voteCountingTypeHelp}"--%>
- <%--tooltipIconPath="/img/tooltip.png"/>--%>
- <%--</fieldset>--%>
-<%--</div>--%>
-
<h4>
<s:property value="%{voteSizeMessage}"/>
</h4>
-<!-- Victoire -->
+<%-- Victoire --%>
<s:if test="victoryMessage != ''">
<h4><s:property value="victoryMessage"/>
<br/>
@@ -191,19 +155,19 @@
<img id='chart_normal'/>
</sj:div>
- <!-- Diagramme par choix -->
- <s:if test="choicesResults != null">
- <div id="resultChart">
- <div>
- <s:iterator value="choicesResultNames" var="choicesResultName"
- status="status">
- <img id='chart_<s:property value="#status.index"/>'
- alt="<s:property/>" title="<s:property/>"
- src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>">
- </s:iterator>
- </div>
- </div>
- </s:if>
+ <%-- Diagramme par choix --%>
+ <%--<s:if test="choicesResults != null">--%>
+ <%--<div id="resultChart">--%>
+ <%--<div>--%>
+ <%--<s:iterator value="choicesResultNames" var="choicesResultName"--%>
+ <%--status="status">--%>
+ <%--<img id='chart_<s:property value="#status.index"/>'--%>
+ <%--alt="<s:property/>" title="<s:property/>"--%>
+ <%--src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>">--%>
+ <%--</s:iterator>--%>
+ <%--</div>--%>
+ <%--</div>--%>
+ <%--</s:if>--%>
</div>
<!-- Classement -->
<%--<t:remove>--%>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-09-19 10:07:02 UTC (rev 3693)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-09-19 10:07:17 UTC (rev 3694)
@@ -119,48 +119,6 @@
<s:set name="showResultUrl" value="true"/>
<%@include file="pollInformation.jsp" %>
-<%--<div id="pollTop">--%>
- <%--<div style="white-space:pre-wrap; text-align: start;">--%>
- <%--<s:property value="poll.description"/>--%>
- <%--</div>--%>
- <%--<fieldset>--%>
- <%--<legend><s:text name="pollen.common.aboutPoll"/></legend>--%>
- <%--<div style="float: right">--%>
- <%--<s:if test="creatorOrAdmin">--%>
- <%--<s:a href="%{summaryUrl}">--%>
- <%--<img src="<s:url value='/img/editSmall.png'/>"--%>
- <%--title="<s:text name='pollen.action.summaryPoll'/>"--%>
- <%--alt="<s:text name='pollen.action.summaryPoll'/>"/>--%>
- <%--</s:a>--%>
- <%--</s:if>--%>
- <%--<s:if test="resultAllowed">--%>
- <%--<s:a href="%{resultUrl}">--%>
- <%--<img src="<s:url value='/img/count.png'/>"--%>
- <%--title="<s:text name='pollen.common.vote.results-help'/>"--%>
- <%--alt="<s:text name='pollen.common.vote.results'/>"/>--%>
- <%--</s:a>--%>
- <%--</s:if>--%>
- <%--<s:if test="feedFileExisting">--%>
- <%--<s:a namespace="/poll" action="getFeed">--%>
- <%--<s:param name="pollId" value="poll.pollId"/>--%>
- <%--<img src="<s:url value='/img/feed.png'/>" title="Atom" alt="Atom"/>--%>
- <%--</s:a>--%>
- <%--</s:if>--%>
- <%--</div>--%>
- <%--<s:label value="%{pollCreatorName}" key='pollen.common.pollCreator'/>--%>
- <%--<s:label value="%{pollBeginDate}" key='pollen.common.beginDate'/>--%>
- <%--<s:label value="%{pollEndDate}" key='pollen.common.endDate'/>--%>
- <%--<s:label value="%{voteCountingTypeName}"--%>
- <%--key='pollen.common.voteCountingType'--%>
- <%--tooltip="%{voteCountingTypeHelp}"--%>
- <%--tooltipIconPath="/img/tooltip.png"/>--%>
- <%--<s:label value="%{pollVoteVisibilityName}"--%>
- <%--key='pollen.common.pollVoteVisibility'--%>
- <%--tooltip="%{pollVoteVisibilityHelp}"--%>
- <%--tooltipIconPath="/img/tooltip.png"/>--%>
- <%--</fieldset>--%>
-<%--</div>--%>
-
<div id="pollZone">
<s:if test="pollChoiceOrVoteStarted">
1
0