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
June 2012
- 5 participants
- 163 discussions
r3420 - trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business
by tchemit@users.chorem.org 04 Jun '12
by tchemit@users.chorem.org 04 Jun '12
04 Jun '12
Author: tchemit
Date: 2012-06-04 14:37:46 +0200 (Mon, 04 Jun 2012)
New Revision: 3420
Url: http://chorem.org/repositories/revision/pollen/3420
Log:
fix javadoc
Modified:
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java 2012-06-04 09:06:56 UTC (rev 3419)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java 2012-06-04 12:37:46 UTC (rev 3420)
@@ -72,7 +72,7 @@
}
/**
- * Renvoie un choix de la map
+ * Renvoie un choix de la map.
*
* @param idChoice : identifiant du choix
* @return choix
@@ -121,7 +121,7 @@
/**
* Ajout d'un nouveau choix au contexte
*
- * @param idChoice : identifiant du choix
+ * @param choice identifiant du choix
*/
public void addChoice(PollChoiceDTO choice) {
this.choices.add(new Choice(choice.getIdChoice(), choice.getName()));
@@ -130,7 +130,7 @@
/**
* Ajout d'un nouveau choix au contexte
*
- * @param idChoice : identifiant du choix
+ * @param choice identifiant du choix
*/
public void addHiddenChoice(PollChoiceDTO choice) {
this.hiddenChoices.add(new Choice(choice.getIdChoice(), choice.getName()));
@@ -139,8 +139,8 @@
/**
* Ajout d'un groupe pour l'ensemble des choix du contexte
*
- * @param idGroup : identifiant du groupe
- * @param weight : poids du groupe
+ * @param idGroup identifiant du groupe
+ * @param weight poids du groupe
*/
public void addGroup(String idGroup, double weight) {
for (Choice choice : this.choices) {
@@ -155,22 +155,24 @@
* Test si le choix est un résultat d'après le contexte A utiliser après
* dépouillement sinon aucun résultat
*
- * @param choice : choix à tester
- * @return true si le choix est un résultat, false sinon
+ * @param choice choix à tester
+ * @return {@code true} si le choix est un résultat, {@code false} sinon.
*/
private boolean isChoiceResult(Choice choice) {
+ boolean result = false;
for (Choice res : results) {
if (choice.getIdChoice().equals(res.getIdChoice())) {
- return true;
+ result = true;
+ break;
}
}
- return false;
+ return result;
}
/**
* Execution de la méthode de dépouillement et calcul des choix résultats
*
- * @return liste de choix résultats
+ * @return la liste de choix résultats
*/
public boolean executeCounting() {
1
0
r3419 - trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl
by athimel@users.chorem.org 04 Jun '12
by athimel@users.chorem.org 04 Jun '12
04 Jun '12
Author: athimel
Date: 2012-06-04 11:06:56 +0200 (Mon, 04 Jun 2012)
New Revision: 3419
Url: http://chorem.org/repositories/revision/pollen/3419
Log:
May fail in multiple form submission
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 20:59:00 UTC (rev 3418)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-04 09:06:56 UTC (rev 3419)
@@ -328,7 +328,7 @@
result.setDescription(poll.getDescription());
result.setEndDate(poll.getEndDate());
result.setEndChoiceDate(poll.getEndChoiceDate());
- result.setPollId(poll.getPollId());
+ result.setPollId(poll.getPollId()); // TODO AThimel 04/06/2012 pollId coming from the JSP page ????
result.setPollType(poll.getPollType());
result.setMaxChoiceNb(poll.getMaxChoiceNb());
result.setPublicResults(poll.isPublicResults());
1
0
r3418 - in trunk: pollen-services/src/main/java/org/chorem/pollen/bean pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security pollen-ui-struts2/src/main/resources pollen-ui-struts2/src/main/resources/config pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 22:59:00 +0200 (Sun, 03 Jun 2012)
New Revision: 3418
Url: http://chorem.org/repositories/revision/pollen/3418
Log:
refs #582: Make the resume page bookmarkeable
reuse the AbstractPollUriIdAction action for attachPoll one
Added:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResumePoll.java
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java
trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
trunk/pollen-ui-struts2/src/main/resources/shiro.ini
trunk/pollen-ui-struts2/src/main/resources/struts.xml
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -25,6 +25,7 @@
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.business.persistence.Poll;
import java.io.Serializable;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -193,18 +193,18 @@
return pollType == PollType.GROUP;
}
- public String getPollVoteUrl() {
- return getPollUrlService().getPollVoteUrl(poll, false).getUrl();
- }
+// public String getPollVoteUrl() {
+// return getPollUrlService().getPollVoteUrl(poll, false).getUrl();
+// }
+//
+// public String getPollModerateUrl() {
+// return getPollUrlService().getPollVoteUrl(poll, true).getUrl();
+// }
+//
+// public String getPollEditUrl() {
+// return getPollUrlService().getPollEditUrl(poll).getUrl();
+// }
- public String getPollModerateUrl() {
- return getPollUrlService().getPollVoteUrl(poll, true).getUrl();
- }
-
- public String getPollEditUrl() {
- return getPollUrlService().getPollEditUrl(poll).getUrl();
- }
-
public int getSelectedTab() {
int result = 0;
return result;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -77,11 +77,11 @@
}
public final String getPollId() {
- return pollUri != null ? pollUri.getPollId() : null;
+ return pollUri == null ? null : pollUri.getPollId();
}
public final String getAccountId() {
- return pollUri != null ? pollUri.getAccountId() : null;
+ return pollUri == null ? null : pollUri.getAccountId();
}
protected void preparePollUri(Map<String, String[]> parameters) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -24,12 +24,10 @@
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.ui.actions.PageSkin;
-import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
* To attach a anonymous poll to a connected user account.
@@ -37,25 +35,10 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.4
*/
-public class AttachPoll extends PollenActionSupport {
+public class AttachPoll extends AbstractPollUriIdAction {
private static final long serialVersionUID = 1L;
- /**
- * Id of the poll to attach to connected user account.
- *
- * @since 1.4
- */
- private PollUri pollUri;
-
- public void setPollUri(PollUri pollUri) {
- this.pollUri = pollUri;
- }
-
- public String getPollId() {
- return pollUri == null ? null : pollUri.getPollId();
- }
-
@Override
public PageSkin getSkin() {
return PageSkin.EDITION;
@@ -64,9 +47,9 @@
@Override
public String execute() throws Exception {
- Preconditions.checkNotNull(pollUri);
+ String pollId = getPollId();
- String pollId = pollUri.getPollId();
+ Preconditions.checkNotNull(pollId);
Poll poll = getPollService().getExistingPollByPollId(pollId);
@@ -82,12 +65,11 @@
@Override
public void validate() {
-
- if (pollUri == null || StringUtils.isEmpty(pollUri.getPollId())) {
- addFieldError("pollUri", _("pollen.error.pollId.empty"));
+ if (StringUtils.isEmpty(getPollId())) {
+ addFieldError("uriId", _("pollen.error.pollId.empty"));
} else {
- String pollId = pollUri.getPollId();
+ String pollId = getPollId();
try {
@@ -99,12 +81,12 @@
UserAccount userAccount = poll.getCreator().getUserAccount();
if (userAccount != null) {
- addFieldError("pollUri",
+ addFieldError("uriId",
_("pollen.error.pollAlreadyAttached"));
}
} catch (PollNotFoundException e) {
- addFieldError("pollUri", _("pollen.error.pollNotFound"));
+ addFieldError("uriId", _("pollen.error.pollNotFound"));
}
}
Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResumePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResumePoll.java (rev 0)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResumePoll.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.google.common.base.Preconditions;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.ui.actions.PageSkin;
+
+/**
+ * Action to display all resume link for a given poll.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class ResumePoll extends AbstractPollUriIdAction {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Loade poll.
+ *
+ * @since 1.4
+ */
+ private Poll poll;
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ @Override
+ public PageSkin getSkin() {
+ return PageSkin.EDITION;
+ }
+
+ public String getPollVoteUrl() {
+ return getPollUrlService().getPollVoteUrl(poll, false).getUrl();
+ }
+
+ public String getPollModerateUrl() {
+ return getPollUrlService().getPollVoteUrl(poll, true).getUrl();
+ }
+
+ public String getPollEditUrl() {
+ return getPollUrlService().getPollEditUrl(poll).getUrl();
+ }
+
+ public boolean isFreePoll() {
+ PollType pollType = poll.getPollType();
+ return pollType == PollType.FREE;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(getUriId());
+
+ String pollId = getUriId().getPollId();
+
+ poll = getPollService().getExistingPollByPollId(pollId);
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResumePoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -38,6 +38,7 @@
import org.chorem.pollen.bean.ChoiceHelper;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
+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.PersonToList;
@@ -185,6 +186,10 @@
}
}
+ public PollUri getUriId() {
+ return PollUri.newPollUri(poll.getAdminId());
+ }
+
@Override
public String input() {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorRequired.java 2012-06-03 20:59:00 UTC (rev 3418)
@@ -44,7 +44,6 @@
adminFilter = new AdminUserRequired();
}
-
@Override
protected boolean isAccessAllowed(ServletRequest request,
ServletResponse response,
@@ -54,7 +53,7 @@
if (adminFilter.isAccessAllowed(request, response, mappedValue)) {
- // user is connected ans admin, so
+ // user is connected and admin, so access granted
isAccessAllowed = true;
} else {
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-06-03 20:59:00 UTC (rev 3418)
@@ -33,6 +33,8 @@
<package name="poll" extends="default" namespace="/poll">
<result-types>
+
+
<result-type name="redirectToVote"
class="org.chorem.pollen.ui.results.PollenServletActionRedirectResult">
<param name="namespace">/poll</param>
@@ -47,7 +49,8 @@
</action>
<!-- display * -->
- <action name="display*" class="org.chorem.pollen.ui.actions.poll.Display{1}">
+ <action name="display*"
+ class="org.chorem.pollen.ui.actions.poll.Display{1}">
<result>/WEB-INF/jsp/poll/display{1}.jsp</result>
</action>
@@ -59,8 +62,7 @@
</action>
<!-- clone poll -->
- <action name="clone/*"
- class="org.chorem.pollen.ui.actions.poll.LoadPoll">
+ <action name="clone/*" class="org.chorem.pollen.ui.actions.poll.LoadPoll">
<param name="uriId">{1}</param>
<param name="clone">true</param>
<result>/WEB-INF/jsp/poll/create.jsp</result>
@@ -69,6 +71,16 @@
<!-- save poll -->
<action name="save" class="org.chorem.pollen.ui.actions.poll.SavePoll">
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
+ <result type="pollenRedirectAction">
+ <param name="namespace">/poll</param>
+ <param name="actionName">resume/${uriId}</param>
+ </result>
+ </action>
+
+ <!-- resume poll -->
+ <action name="resume/*" method="execute"
+ class="org.chorem.pollen.ui.actions.poll.ResumePoll">
+ <param name="uriId">{1}</param>
<result>/WEB-INF/jsp/poll/resume.jsp</result>
</action>
@@ -95,8 +107,7 @@
</action>
<!-- close poll -->
- <action name="close/*"
- class="org.chorem.pollen.ui.actions.poll.ClosePoll">
+ <action name="close/*" class="org.chorem.pollen.ui.actions.poll.ClosePoll">
<param name="uriId">{1}</param>
<result type="redirect2"/>
</action>
Modified: trunk/pollen-ui-struts2/src/main/resources/shiro.ini
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-06-03 20:59:00 UTC (rev 3418)
@@ -50,4 +50,5 @@
# is pollCreator (can admin a poll)
/poll/modification/**=poll,pollCreator
/poll/clone/**=poll,pollCreator
-/poll/resultLink/**=poll,pollCreator
\ No newline at end of file
+/poll/resultLink/**=poll,pollCreator
+/poll/resume/**=poll,pollCreator
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/struts.xml 2012-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/resources/struts.xml 2012-06-03 20:59:00 UTC (rev 3418)
@@ -58,6 +58,9 @@
<param name="actionName">home</param>
</result-type>
+ <result-type name="pollenRedirectAction"
+ class="org.chorem.pollen.ui.results.PollenServletActionRedirectResult"/>
+
<result-type name="redirect2"
class="org.apache.struts2.dispatcher.ServletRedirectResult">
<param name="location">${redirectUrl}</param>
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-06-03 19:26:50 UTC (rev 3417)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp 2012-06-03 20:59:00 UTC (rev 3418)
@@ -87,7 +87,7 @@
<s:form namespace="/user" method="POST">
- <s:textfield key="pollUri" label='%{getText("pollen.common.pollId")}'
+ <s:textfield key="uriId" label='%{getText("pollen.common.pollId")}'
required="true" size="80" value='%{pollId}'
tooltip='%{getText("poll.help.pollId")}'
tooltipIconPath="/img/tooltip.png"/>
1
0
Author: tchemit
Date: 2012-06-03 21:26:50 +0200 (Sun, 03 Jun 2012)
New Revision: 3417
Url: http://chorem.org/repositories/revision/pollen/3417
Log:
fixes #530: ajouter ou d?\195?\169placer un sondage sur un compte
fixes #581: Add an edit link for creator or admin on vote and result page
fixes #580: When changing lang, it should redirect to last page and not on home page.
fixes #573: Liens pas clairs apr?\195?\168s cr?\195?\169ation de sondage
- ajout javadocs
Added:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ChangeLang.java
trunk/pollen-ui-struts2/src/main/webapp/css/resume.css
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.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/PollUrlService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractDisplayChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.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/SavePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java
trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/resources/shiro.ini
trunk/pollen-ui-struts2/src/main/resources/struts.xml
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resultLink.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -92,4 +92,9 @@
}
return result;
}
+
+ @Override
+ public String toString() {
+ return getUri();
+ }
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -143,7 +143,7 @@
subject = l_(locale, "pollen.email.createPoll.subject",
pollTitle);
content = l_(locale, "pollen.email.createPoll.content",
- pollTitle, voteURL, moderateUrl, modifURL);
+ pollTitle, poll.getPollId(), voteURL, moderateUrl, modifURL);
} else {
subject = l_(locale, "pollen.email.createRestrictedPoll.subject",
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -774,6 +774,28 @@
commitTransaction("Could not close poll " + poll.getTitle());
}
+ public void attachPoll(Poll poll, UserAccount userAccount) {
+
+ Preconditions.checkNotNull(poll);
+ Preconditions.checkNotNull(userAccount);
+
+ // just link poll creator account to given user account
+ PollAccount creator = poll.getCreator();
+ creator.setUserAccount(userAccount);
+
+ // fill votingId from user account
+ if (StringUtils.isEmpty(creator.getVotingId())) {
+ creator.setVotingId(userAccount.getDisplayName());
+ }
+
+ // fill email from user account
+ if (StringUtils.isEmpty(creator.getEmail())) {
+ creator.setEmail(userAccount.getEmail());
+ }
+ commitTransaction("Could not attach poll " + poll.getTitle() +
+ " to user account " + userAccount.getDisplayName());
+ }
+
public Choice getNewChoice(ChoiceType choiceType) {
Choice result;
switch (choiceType) {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -1,3 +1,25 @@
+/*
+ * #%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.impl;
import com.google.common.base.Preconditions;
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 19:26:50 UTC (rev 3417)
@@ -11,7 +11,7 @@
pollen.common.numberVote-total-votes=Total votes
pollen.common.unauthorized=unauthorized
pollen.common.undefined=undefined
-pollen.email.createPoll.content=You had just created the new poll\: "%s".\nYou can access to this poll by following the links below.\n\nVote page\: \n%s\nModerate votes page\: \n%s\nEdit page\: \n%s
+pollen.email.createPoll.content=You had just created the new poll\: "%s" (id %s).\n\nYou can access to this poll by following the links below.\n\nVote page\: \n%s\nModerate votes page\: \n%s\nEdit page\: \n%s
pollen.email.createPoll.subject=[Pollen] Poll creation (%s)
pollen.email.createRestrictedPoll.content=You had just created the new poll\: "%s".\nYou can access to this poll by following the links below.\n\nModerate votes page\: \n%s\nEdit page\: \n%s
pollen.email.createRestrictedPoll.subject=[Pollen] Restricted poll creation (%s)
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 19:26:50 UTC (rev 3417)
@@ -11,7 +11,7 @@
pollen.common.numberVote-total-votes=Nombre total de votes
pollen.common.unauthorized=Non autorisé
pollen.common.undefined=Non défini
-pollen.email.createPoll.content=Vous venez de créer le sondage "%1$s".\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nPage de vote \: \n%2$s\nModération des votes \: \n%3$s\nPage de modification \: \n%4$s
+pollen.email.createPoll.content=Vous venez de créer le sondage "%1$s" (identifiant %2$s).\n\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nPage de vote \: \n%3$s\nModération des votes \: \n%4$s\nPage de modification \: \n%5$s
pollen.email.createPoll.subject=[Pollen] Création d'un sondage (%1$s)
pollen.email.createRestrictedPoll.content=Vous venez de créer le sondage "%s".\nVous pouvez y accéder en suivant les liens ci-dessous.\n\nModération des votes \: \n%s\nPage de modification \: \n%s
pollen.email.createRestrictedPoll.subject=[Pollen] Création d'un sondage restreint (%s)
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractDisplayChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractDisplayChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractDisplayChoice.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -40,15 +40,25 @@
private static final long serialVersionUID = 1L;
- /** Where to find dynamic data (says choices in this case). */
+ /**
+ * Where to find dynamic data (says choices in this case).
+ *
+ * @since 1.3
+ */
protected String tokenId;
- /** Number of choice to display. */
+ /**
+ * Number of choice to display.
+ *
+ * @since 1.3
+ */
protected int choiceNumber;
/**
* Choice to display in ui (come from dynamic data if exists, or fresh
* created one).
+ *
+ * @since 1.3
*/
protected Choice choice;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -62,30 +62,86 @@
/** Logger. */
private static final Log log = LogFactory.getLog(AbstractVoteAction.class);
+ /**
+ * Loaded poll.
+ *
+ * @since 1.3
+ */
private Poll poll;
+ /**
+ * Is feed existfor this poll ?
+ *
+ * @since 1.3
+ */
private boolean feedFileExisting;
+ /**
+ * Is user the poll's creator ?
+ *
+ * @since 1.3
+ */
private boolean creatorUser;
+ /**
+ * Loaded poll account (from the pollUri).
+ *
+ * @since 1.3
+ */
private PollAccount pollAccount;
+ //TODO-thcemit-2012-06-03 Do we use this ? nobody set it... so always false
private boolean alreadyVoted;
+ /**
+ * Is votr allowed for current user?
+ *
+ * @since 1.3
+ */
private boolean voteAllowed;
+ /**
+ * All votes for the poll.
+ *
+ * @since 1.3
+ */
private List<Vote> votes;
+ /**
+ * Current vote to treat (for create/updatevote action).
+ *
+ * @since 1.3
+ */
private Vote vote;
+ /**
+ * Comment author to display in UI.
+ *
+ * @since 1.3
+ */
private String commentAuthor;
// private String voteSizeMessage;
+ /**
+ * Results of the poll.
+ *
+ * @since 1.3
+ */
private List<PollResult> results;
+ /**
+ * List of comments to display.
+ *
+ * @since 1.3
+ */
private List<Comment> comments;
+ /**
+ * Injected parameters from request.
+ *
+ * @since 1.3
+ */
private Map<String, String[]> parameters;
@Override
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -83,7 +83,7 @@
// create the comment
getPollCommentService().createComment(getPoll(), comment);
- addFlashMessage(_("pollen.info.comment.added"));
+ addFlashMessage(_("pollen.information.comment.added"));
return SUCCESS;
}
}
Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java (rev 0)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -0,0 +1,112 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.UserAccount;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.ui.actions.PageSkin;
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+/**
+ * To attach a anonymous poll to a connected user account.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class AttachPoll extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Id of the poll to attach to connected user account.
+ *
+ * @since 1.4
+ */
+ private PollUri pollUri;
+
+ public void setPollUri(PollUri pollUri) {
+ this.pollUri = pollUri;
+ }
+
+ public String getPollId() {
+ return pollUri == null ? null : pollUri.getPollId();
+ }
+
+ @Override
+ public PageSkin getSkin() {
+ return PageSkin.EDITION;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Preconditions.checkNotNull(pollUri);
+
+ String pollId = pollUri.getPollId();
+
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
+
+ UserAccount userAccount = getPollenSession().getUserAccount();
+
+ getPollService().attachPoll(poll, userAccount);
+
+ addFlashMessage(_("pollen.information.poll.attached", poll.getTitle()));
+
+ return SUCCESS;
+ }
+
+ @Override
+ public void validate() {
+
+
+ if (pollUri == null || StringUtils.isEmpty(pollUri.getPollId())) {
+ addFieldError("pollUri", _("pollen.error.pollId.empty"));
+ } else {
+
+ String pollId = pollUri.getPollId();
+
+ try {
+
+ // check that poll exists
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
+
+ // check that poll is not yet attached to another user account
+
+ UserAccount userAccount = poll.getCreator().getUserAccount();
+ if (userAccount != null) {
+
+ addFieldError("pollUri",
+ _("pollen.error.pollAlreadyAttached"));
+ }
+ } catch (PollNotFoundException e) {
+
+ addFieldError("pollUri", _("pollen.error.pollNotFound"));
+ }
+
+ }
+ }
+}
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AttachPoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -23,6 +23,8 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import org.chorem.pollen.business.persistence.Poll;
+
/**
* Closes an existing poll.
*
@@ -33,6 +35,11 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Redirect url.
+ *
+ * @since 1.3
+ */
protected String redirectUrl;
public String getRedirectUrl() {
@@ -46,11 +53,13 @@
@Override
public String execute() throws Exception {
+ Poll poll = getPollService().getExistingPollByPollId(getPollId());
+
getPollService().closePoll(getPollId(),
getPollenUserAccount(),
getAccountId());
- addFlashMessage(_("pollen.information.poll.closed"));
+ addFlashMessage(_("pollen.information.poll.closed", poll.getTitle()));
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -50,7 +50,7 @@
getPollService().deleteChoice(pollId, choiceId);
- addFlashMessage(_("pollen.info.choice.deleted"));
+ addFlashMessage(_("pollen.information.choice.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -70,7 +70,7 @@
getPollCommentService().deleteComment(poll, commentId, reason);
- addFlashMessage(_("pollen.info.comment.deleted"));
+ addFlashMessage(_("pollen.information.comment.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -68,7 +68,7 @@
getVoteService().deleteVote(poll, voteId, reason);
- addFlashMessage(_("pollen.info.vote.deleted"));
+ addFlashMessage(_("pollen.information.vote.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -38,7 +38,6 @@
import org.chorem.pollen.bean.PollResult;
import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
@@ -67,26 +66,71 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ResultForPoll.class);
+ /**
+ * Is result by group ?
+ *
+ * @since 1.3
+ */
private Boolean byGroup;
- protected boolean userAllowed;
+ /**
+ * Can user be on this page ?
+ * <p/>
+ * TODO-tchemit-2012-06-03 Security is managed by shiro, why doing it here again ?
+ *
+ * @since 1.3
+ */
+ private boolean userAllowed;
/**
+ * Is user is poll(s creator ?
+ *
+ * @since 1.4
+ */
+ private boolean creatorUser;
+
+ /**
* 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. */
+ /**
+ * 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;
+ /**
+ * Top ranking results.
+ *
+ * @since 1.3
+ */
private List<PollResult> topRanking;
+ /**
+ * Url helper (to build new url)
+ *
+ * @since 1.3.1
+ */
@Inject(required = true)
private UrlHelper urlHelper;
@@ -103,6 +147,10 @@
return userAllowed;
}
+ public boolean isCreatorUser() {
+ return creatorUser;
+ }
+
public List<PollResult> getResults() {
return results;
}
@@ -159,37 +207,38 @@
poll = getPollService().getExistingPollByPollId(pollId);
- if (poll == null) {
- addFlashError(_("pollen.error.pollNotFound"));
- } else {
+ if (byGroup == null) {
- if (byGroup == null) {
+ // default byGroup value
+ byGroup = isGroupPoll();
+ }
- // default byGroup value
- byGroup = isGroupPoll();
- }
+ String accountId = getAccountId();
- String accountId = getAccountId();
- if (poll.isPublicResults()) {
- userAllowed = true;
- } else if (StringUtils.isNotEmpty(accountId)) {
+ creatorUser = poll.getCreator().getAccountId().equals(accountId);
- PollAccount creator = poll.getCreator();
- if (accountId.equals(creator.getAccountId())) {
- userAllowed = true;
- }
- }
+ if (poll.isPublicResults()) {
+ userAllowed = true;
+ } else if (StringUtils.isNotEmpty(accountId)) {
- if (!userAllowed) {
- addFlashError(_("pollen.error.userNotAllowed"));
+ // create is allowed to be ther
+ userAllowed = creatorUser;
- } else if (poll.isRunning(serviceContext.getCurrentTime())) {
- addFlashWarning(_("pollen.information.pollRunning"));
- loadResults();
+// PollAccount creator = poll.getCreator();
+// if (accountId.equals(creator.getAccountId())) {
+// userAllowed = true;
+// }
+ }
- } else {
- loadResults();
- }
+ if (!userAllowed) {
+ addFlashError(_("pollen.error.userNotAllowed"));
+
+ } else if (poll.isRunning(serviceContext.getCurrentTime())) {
+ addFlashWarning(_("pollen.information.pollRunning"));
+ loadResults();
+
+ } else {
+ loadResults();
}
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -265,11 +265,11 @@
if (isEdit()) {
getPollService().updatePoll(poll);
- addFlashMessage(_("pollen.information.poll.updated"));
+ addFlashMessage(_("pollen.information.poll.updated", poll.getTitle()));
} else {
getPollService().createPoll(poll);
- addFlashMessage(_("pollen.information.poll.created"));
+ addFlashMessage(_("pollen.information.poll.created", poll.getTitle()));
}
// remove all stuff from session
Added: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ChangeLang.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ChangeLang.java (rev 0)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ChangeLang.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -0,0 +1,67 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.user;
+
+import org.chorem.pollen.ui.actions.PollenActionSupport;
+
+/**
+ * To change lang and redirect to current page.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class ChangeLang extends PollenActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Where to redirect after having chang lang.
+ *
+ * @since 1.4
+ */
+ protected String redirectUrl;
+
+ public String getRedirectUrl() {
+ return redirectUrl;
+ }
+
+ public void setRedirectUrl(String redirectUrl) {
+ this.redirectUrl = redirectUrl;
+ }
+
+ @Override
+ public String execute() throws Exception {
+ String result;
+ if (redirectUrl == null || redirectUrl.contains("/security")) {
+
+ // After security problem, redirect to home
+ result = Login.HOME;
+
+ } else {
+
+ // Stay on the same page identified by redirectUrl
+ result = SUCCESS;
+ }
+ return result;
+ }
+}
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ChangeLang.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java 2012-06-03 19:26:50 UTC (rev 3417)
@@ -39,7 +39,7 @@
private static final long serialVersionUID = 1L;
- private static final String HOME = "home";
+ public static final String HOME = "home";
protected String login;
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-06-03 19:26:50 UTC (rev 3417)
@@ -32,6 +32,20 @@
<package name="user" extends="default" namespace="/user">
+ <!-- change lang-->
+ <action name="changeLang" method="execute"
+ class="org.chorem.pollen.ui.actions.user.ChangeLang">
+
+ <result name="home" type="redirectToHome"/>
+ <result type="redirect2"/>
+
+ <interceptor-ref name="i18nStack"/>
+ <!-- remove the request_locale parameter from request -->
+ <interceptor-ref name="paramRemover">
+ <param name="paramNames">request_locale</param>
+ </interceptor-ref>
+ </action>
+
<!-- login -->
<action name="login" class="org.chorem.pollen.ui.actions.user.Login">
<result name="home" type="redirectToHome"/>
@@ -134,6 +148,16 @@
<result type="redirect2"/>
</action>
+ <!-- attach poll to the connected user account -->
+ <action name="attachPoll"
+ class="org.chorem.pollen.ui.actions.poll.AttachPoll">
+ <result name="input">/WEB-INF/jsp/user/createdList.jsp</result>
+ <result type="redirectAction">
+ <param name="namespace">/user</param>
+ <param name="actionName">createdList</param>
+ </result>
+ </action>
+
<!-- display createds polls -->
<action name="createdList"
class="org.chorem.pollen.ui.actions.poll.CreatedList">
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 19:26:50 UTC (rev 3417)
@@ -1,10 +1,13 @@
email=E-mail
+poll.help.attachPoll=To reattach a poll created anonymously to your user account.
+poll.help.pollId=Poll id can be found at different place\:<br/><br/>- Inside the email send after poll creation (since version 1.4)<br/><br/>- On resume page after poll creation or modification (since version 1.4)<br/><br/>,- On any url to access the poll actions (administration, vote, result).
pollen.action.addChoice=Add choice
pollen.action.addComment=Add a comment
pollen.action.addPersonListFromVotingList=Add voters from a favorite list
pollen.action.addPersonToList=Add a voter
pollen.action.addVotingList=Add a group
pollen.action.addVotingListFromPersonList=Add a group from a favorite list
+pollen.action.attachPoll=Attach poll
pollen.action.backToFavoriteLists=Back to favorite lists
pollen.action.cancel=Cancel
pollen.action.clone=Clone poll
@@ -21,7 +24,7 @@
pollen.action.deleteUser=Delete selected user
pollen.action.deleteVote=Supprimer ce vote
pollen.action.editFavoriteList=Edit a list
-pollen.action.editPoll=Edit the pollLes deux mots de passe saisis non identiques
+pollen.action.editPoll=Edit the poll
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
pollen.action.editVote=Modifier le vote
@@ -98,6 +101,7 @@
pollen.common.personList=Voting lists
pollen.common.personToList=Voter
pollen.common.pollCreator=Creator
+pollen.common.pollId=Poll id
pollen.common.pollOption.anonymous=Anonymous
pollen.common.pollOption.anonymous.help=Voting persons and their votes are anonymous
pollen.common.pollOption.anonymousVoteAllowed=Anonymous vote allowed
@@ -181,7 +185,9 @@
pollen.error.poll.votingList.weight.not.valid=The group's weight is not valid (must be greater than 0)
pollen.error.pollAccount.not.found=Poll account not found
pollen.error.pollAccount.votingId.required=Name mandatory
-pollen.error.pollNotFound=The poll you want to count does not exist.
+pollen.error.pollAlreadyAttached=The poll is already attached to another user account
+pollen.error.pollId.empty=Poll id is mandatory
+pollen.error.pollNotFound=The poll with given id does not exist.
pollen.error.pollTabErrorFound=Some errors were found on this tab, please fix them to finalize the poll creation.
pollen.error.user.alreadyVoted=Someone has already used the name %s to vote.
pollen.error.user.bad.login.or.password=Login or password invalid.
@@ -210,10 +216,9 @@
pollen.fieldset.userInformation.toDelete=User informations to delete
pollen.fieldset.userInformation.toUpdate=User informations to update
pollen.image.not.loaded=Image not loaded
-pollen.info.choice.deleted=Choice deleted
-pollen.info.comment.added=Comment added
-pollen.info.comment.deleted=Comment deleted
-pollen.info.vote.deleted=Vote deleted
+pollen.information.choice.deleted=Choice deleted.
+pollen.information.comment.added=Comment added.
+pollen.information.comment.deleted=Comment deleted.
pollen.information.confirmClonePoll=Confirm clone of poll\:
pollen.information.confirmClosePoll=Confirm close of poll\:
pollen.information.confirmDeleteFavoriteList=Confirm delete of favorite list\:
@@ -228,13 +233,14 @@
pollen.information.lostPassword=You will receive a new password to the given email
pollen.information.lostPassword.success=An e-mail was sent with your new password. You can change it on your user account page.
pollen.information.need.login=You must be logged to access this page. Please fill the form below.
-pollen.information.poll.closed=Poll closed
-pollen.information.poll.created=Poll created
+pollen.information.poll.attached=Poll '%s' attached to your user account.
+pollen.information.poll.closed=Poll '%s' closed.
+pollen.information.poll.created=Poll '%s' created.
pollen.information.poll.form.voteStarted=Votes are started, some options can't be updated.
-pollen.information.poll.updated=Poll modified
-pollen.information.pollAccount.addedTofavoriteList=Member '%s was added to favorite list.
-pollen.information.pollAccount.removedFromFavoriteList=Member %s was removed from favorite list.
-pollen.information.pollAccount.updatedTofavoriteList=Member %s was updated in favorite list.
+pollen.information.poll.updated=Poll '%s' modified.
+pollen.information.pollAccount.addedTofavoriteList=Member '%s' was added to favorite list.
+pollen.information.pollAccount.removedFromFavoriteList=Member '%s' was removed from favorite list.
+pollen.information.pollAccount.updatedTofavoriteList=Member '%s' was updated in favorite list.
pollen.information.pollChoiceRunning=Adding choices is allowed.
pollen.information.pollClosed=This poll is closed. You can not vote anymore.
pollen.information.pollFinished=This poll is finished. You can not vote anymore.
@@ -244,15 +250,17 @@
pollen.information.user.deleted=User %s deleted.
pollen.information.user.updated=User %s updated.
pollen.information.vote.created=Vote saved
-pollen.information.vote.createdWithUpdateUrl=Vote saved, you can modify it using this address \: <br/> <a href\="%1$s">%1$s</a>
+pollen.information.vote.createdWithUpdateUrl=Vote saved, you can modify it using this address\: <br/> <a href\="%1$s">%1$s</a>
pollen.information.vote.creatorUser=You are identified as the poll's creator. You can't vote with this URL.
+pollen.information.vote.deleted=Vote deleted.
pollen.information.your.are.loggued=You are logged.
pollen.label.contact.administrator=Send an email to an administrator
-pollen.label.pollEditPage=The link below leads to the page to modify your poll. Save it to be able to modify your poll later if you need it or to close it \:
-pollen.label.pollModerateVotePage=The link below leads to the page to vote for your poll. This access is available only for you as poll's creator \:
+pollen.label.pollEditPage=<strong>To modify your poll</strong>. Save it to be able to modify your poll later if you need it or to close it\:
+pollen.label.pollModerateVotePage=<strong>To moderate your poll (you can't vote from this url)</strong>. Save it to be able to delete votes and comments\:
pollen.label.pollRegisterPage=If you are a logged user, you can find these links on the page
-pollen.label.pollResultPage=The link below leads to the page to count the votes. Save it to be able to count the vote later \:
-pollen.label.pollVotePage=The link below leads to the page to vote for your poll. Save it and send it to the people that you want to vote \:
+pollen.label.pollResultPage=The link below leads to the page to count the votes. Save it to be able to count the vote later\:
+pollen.label.pollVotePage=<strong>To vote on your poll</strong>. Save it and send it to the people that you want to vote\:
+pollen.legend.attachPoll=Attach an anonymous poll to your user account
pollen.legend.login=Login
pollen.legend.select.favoriteList.to.add=Sélectionner la liste de favoris à ajouter
pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des votant à importer dans le nouveau groupe
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 19:26:50 UTC (rev 3417)
@@ -1,10 +1,13 @@
email=E-mail
+poll.help.attachPoll=Pour rattacher un sondage précedemment créé (sans être connecté) à son compte utilisateur.
+poll.help.pollId=L'identifiant du sondage peut être retrouvé à différents endroits\:<br/><br/>- dans le courriel qui vous a été envoyé suite à la création du sondage (à partir de la version 1.4)<br/><br/>- sur la page de résumé du sondage après sa création ou modification (à partir de la version 1.4)<br/><br/>- Ou encore dans les urls d'accès au sondage (administration, vote, résultat).
pollen.action.addChoice=Ajouter un choix
pollen.action.addComment=Ajouter un commentaire
pollen.action.addPersonListFromVotingList=Ajouter des votants à partir d'une liste de votants
pollen.action.addPersonToList=Ajouter un votant
pollen.action.addVotingList=Ajouter un groupe
pollen.action.addVotingListFromPersonList=Ajouter un groupe à partir d'une liste de votants
+pollen.action.attachPoll=Attacher le sondage
pollen.action.backToFavoriteLists=Retour à la liste des favoris
pollen.action.cancel=Annuler
pollen.action.clone=Cloner le sondage
@@ -98,6 +101,7 @@
pollen.common.personList=Liste de votants
pollen.common.personToList=Votant
pollen.common.pollCreator=Créateur
+pollen.common.pollId=Identifiant du sondage
pollen.common.pollOption.anonymous=Sondage anonyme
pollen.common.pollOption.anonymous.help=Les votants ainsi que leurs votes sont anonymes
pollen.common.pollOption.anonymousVoteAllowed=Autoriser le vote anonyme
@@ -181,7 +185,9 @@
pollen.error.poll.votingList.weight.not.valid=Poids du groupe votant non valide (doit être une nombre supérieur à 0).
pollen.error.pollAccount.not.found=Membre non trouvé
pollen.error.pollAccount.votingId.required=Nom obliqatoire
-pollen.error.pollNotFound=Le sondage que vous voulez dépouiller n'existe pas.
+pollen.error.pollAlreadyAttached=Le sondage est déjà attaché à un autre compte utilisateur
+pollen.error.pollId.empty=L'identifiant du sondage est obligatoire
+pollen.error.pollNotFound=Il n'existe pas de sondage avec cet identifiant.
pollen.error.pollTabErrorFound=Des erreurs ont été detectées dans cet onglet, veuillez les corriger pour valider la création du sondage.
pollen.error.user.alreadyVoted=Une personne a déjà voté sous le nom %s.
pollen.error.user.bad.login.or.password=Mauvais identifiant ou mot de passe.
@@ -210,10 +216,9 @@
pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer
pollen.fieldset.userInformation.toUpdate=Informations de l'utilisateur à mettre à jour
pollen.image.not.loaded=Image non chargée
-pollen.info.choice.deleted=Choix supprimé
-pollen.info.comment.added=Commentaire ajouté
-pollen.info.comment.deleted=Commentaire supprimé
-pollen.info.vote.deleted=Vote supprimé
+pollen.information.choice.deleted=Choix supprimé.
+pollen.information.comment.added=Commentaire ajouté.
+pollen.information.comment.deleted=Commentaire supprimé.
pollen.information.confirmClonePoll=Confirmer le clonage du sondage \:
pollen.information.confirmClosePoll=Confirmer la fermeture du sondage \:
pollen.information.confirmDeleteFavoriteList=Confirmer la suppression de la liste de votants \:
@@ -228,10 +233,11 @@
pollen.information.lostPassword=Vous allez recevoir un nouveau mot de passe sur l'e-mail suivant
pollen.information.lostPassword.success=Un e-mail vous a été envoyé avec votre nouveau mot de passe. Vous pouvez le changer sur la page d'édition de votre compte.
pollen.information.need.login=Vous devez être identifié pour pouvoir accéder à cette page. Veuillez remplir le formulaire ci-dessous.
-pollen.information.poll.closed=Sondage clos
-pollen.information.poll.created=Sondage créé
+pollen.information.poll.attached=Sondage '%s' rattaché à votre compte.
+pollen.information.poll.closed=Sondage '%s' clos.
+pollen.information.poll.created=Sondage '%s' créé.
pollen.information.poll.form.voteStarted=Les votes ont commencé, certaines options ne sont pas modifiables.
-pollen.information.poll.updated=Sondage mise à jour
+pollen.information.poll.updated=Sondage '%s' mise à jour.
pollen.information.pollAccount.addedTofavoriteList=Le membre %s a été ajoutée à la liste des favoris.
pollen.information.pollAccount.removedFromFavoriteList=Le membre %s a été supprimé de la liste des favoris.
pollen.information.pollAccount.updatedTofavoriteList=Le membre %s a été mise à jour dans la liste des favoris.
@@ -246,13 +252,15 @@
pollen.information.vote.created=Vote enregistré
pollen.information.vote.createdWithUpdateUrl=Vote enregistré, vous pourrez le modifier à l'adresse suivante \: <br/> <a href\="%1$s">%1$s</a>
pollen.information.vote.creatorUser=Vous êtes identifié comme le créateur du sondage. Vous ne pouvez pas voter avec cette URL.
+pollen.information.vote.deleted=Vote supprimé.
pollen.information.your.are.loggued=Vous êtes connecté.
pollen.label.contact.administrator=Contacter un administrateur
-pollen.label.pollEditPage=Le lien ci-dessous mène à la page de modification du sondage. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore \:
-pollen.label.pollModerateVotePage=Le lien ci-dessous mène à la page de vote. Cet accès n'est valable que pour vous en tant que créateur du sondage \:
+pollen.label.pollEditPage=<strong>Lien pour configurer le sondage</strong>. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore \:
+pollen.label.pollModerateVotePage=<strong>Lien pour modérer le sondage (ce lien ne permet pas de voter)</strong>. Enregistrez-le pour pouvoir supprimer des votes et commentaires \:
pollen.label.pollRegisterPage=Si vous êtes un utilisateur identifié, vous pouvez retrouver ces liens dans la page
pollen.label.pollResultPage=Le lien ci-dessous mène à la page de dépouillement. Enregistrez-le pour pouvoir accéder au dépouillement plus tard \:
-pollen.label.pollVotePage=Le lien ci-dessous mène à la page de vote. Enregistrez-le et envoyez-le à ceux que vous voulez voir voter \:
+pollen.label.pollVotePage=<strong>Lien pour voter</strong>. Enregistrez-le et envoyez-le à ceux que vous voulez voir voter \:
+pollen.legend.attachPoll=Attacher un sondage anonyme à votre compte
pollen.legend.login=Login
pollen.legend.select.favoriteList.to.add=Sélectionner la liste de favoris à ajouter
pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des votant à importer dans le nouveau groupe
Modified: trunk/pollen-ui-struts2/src/main/resources/shiro.ini
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-06-03 19:26:50 UTC (rev 3417)
@@ -22,6 +22,7 @@
# anon urls
/user/login=anon
+/user/changeLang=anon
/user/register**=anon
/user/lostPassword**=anon
Modified: trunk/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/struts.xml 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/resources/struts.xml 2012-06-03 19:26:50 UTC (rev 3417)
@@ -135,19 +135,6 @@
<interceptor-ref name="basicStack"/>
</action>
- <!-- change lang-->
- <action name="changeLang"
- class="org.chorem.pollen.ui.actions.PollenActionSupport">
-
- <result type="redirectToHome"/>
-
- <interceptor-ref name="i18nStack"/>
- <!-- remove the request_locale parameter from request -->
- <interceptor-ref name="paramRemover">
- <param name="paramNames">request_locale</param>
- </interceptor-ref>
- </action>
-
</package>
<package name="security" extends="default" namespace="/security">
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-06-03 19:26:50 UTC (rev 3417)
@@ -78,11 +78,13 @@
<img src="<s:url value='/img/contact.png' />" alt="Contact"/>
</s:a>
| <%=PollenActionSupport.getCurrentDateTime()%> |
- <s:a action="changeLang" id="localeFr">
+ <s:a action="changeLang" namespace="/user" id="localeFr">
<s:param name="request_locale">fr_FR</s:param>
+ <s:param name="redirectUrl" value="%{currentUrl}"/>
<img src="<s:url value='/img/fr.png' />" alt="Français"/>
- </s:a> | <s:a action="changeLang" id="localeEn">
+ </s:a> | <s:a action="changeLang" namespace="/user" id="localeEn">
<s:param name="request_locale">en_GB</s:param>
+ <s:param name="redirectUrl" value="%{currentUrl}"/>
<img src="<s:url value='/img/en.png' />" alt="English"/>
</s:a>
</div>
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-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-06-03 19:26:50 UTC (rev 3417)
@@ -29,15 +29,8 @@
<script type="text/javascript">
- <%--function displayNormalChartUrl(type) {--%>
- <%--var url = "<s:url value='%{getNormalPollResultChartUrl(400, 300)}' escapeAmp='false'/>&type=" + type;--%>
- <%--$('#normalChartImg').attr('src', url);--%>
- <%--return false;--%>
- <%--}--%>
-
function displayCharts(type) {
$.each(chartUrls, function (key, value) {
- console.info("display url [" + key + "] : " + value);
var url = value + "&type=" + type;
$('#' + key).attr("src", url);
});
@@ -73,6 +66,13 @@
<fieldset>
<legend><s:text name="pollen.common.aboutPoll"/></legend>
<div style="float: right">
+ <s:if test="creatorUser or userAdmin">
+ <s:a namespace="/poll" action="modification/%{uriId}">
+ <img src="<s:url value='/img/editSmall.png'/>"
+ title="<s:text name='pollen.action.editPoll'/>"
+ alt="<s:text name='pollen.action.editPoll'/>"/>
+ </s:a>
+ </s:if>
<s:a namespace="/poll" action="votefor/%{uriId}">
<img src="<s:url value='/img/vote.png'/>"
title="<s:text name="pollen.common.vote.return-help"/>"
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resultLink.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resultLink.jsp 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resultLink.jsp 2012-06-03 19:26:50 UTC (rev 3417)
@@ -34,14 +34,13 @@
style="margin-right: 18px;"/>
<s:text name='pollen.label.pollResultPage'/>
<br/>
- <s:set name="resultUrl" value="%{pollResultUrl}"/>
- <s:a href="%{resultUrl}" cssStyle="margin-left:50px;">
- <s:property value="resultUrl"/>
+ <s:a href="%{pollResultUrl}" cssStyle="margin-left:50px;">
+ <s:property value="%{pollResultUrl}"/>
</s:a>
</div>
<div style="margin-top: 30px;">
<s:text name="pollen.label.pollRegisterPage"/>
- <s:a namespace="/user" action="myPolls">
+ <s:a namespace="/user" action="createdList">
<s:text name="pollen.common.myPolls"/>
</s:a>.
</div>
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp 2012-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp 2012-06-03 19:26:50 UTC (rev 3417)
@@ -23,44 +23,49 @@
--%>
<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
+<link rel="stylesheet" type="text/css" href="<s:url value='/css/resume.css'/>"/>
+
<h1 class="titleCreation"><s:property value="poll.title"/></h1>
<h3><s:property value="poll.title"/> <s:text name="pollen.common.by"/>
<s:property value="poll.creator.votingId"/></h3>
+<div class="ui-widget-content ui-corner-all">
+
+ <s:label key="pollen.common.pollId" value="%{poll.pollId}"/>
+ <br/>
+</div>
+
<s:if test="freePoll">
- <div style="margin-top: 10px;">
+ <div class="ui-widget-content-green ui-corner-all">
<img src="<s:url value='/img/vote.png'/>"
alt="<s:text name='pollen.common.voteAction'/>"
style="margin-right: 18px;"/>
- <s:property value="pollen.label.pollVotePage"/>
+ <s:text name="pollen.label.pollVotePage"/>
<br/>
- <s:set name="voteUrl" value="%{pollVoteUrl}"/>
- <s:a href="%{voteUrl}" cssStyle="margin-left:50px;">
- <s:property value="voteUrl"/>
+ <s:a href="%{pollVoteUrl}" cssStyle="margin-left:50px;">
+ <s:property value="%{pollVoteUrl}"/>
</s:a>
</div>
</s:if>
-<div style="margin-top: 10px;">
+<div class="ui-widget-content-yellow ui-corner-all">
<img src="<s:url value='/img/moderate.png'/>"
alt="<s:text name='pollen.action.pollModerateVote'/>"
style="margin-right: 20px;"/>
<s:text name='pollen.label.pollModerateVotePage'/>
<br/>
- <s:set name="moderateUrl" value="%{pollModerateUrl}"/>
- <s:a href="%{moderateUrl}" cssStyle="margin-left:50px;">
- <s:property value="moderateUrl"/>
+ <s:a href="%{pollModerateUrl}" cssStyle="margin-left:50px;">
+ <s:property value="%{pollModerateUrl}"/>
</s:a>
</div>
-<div style="margin-top: 10px;">
+<div class="ui-widget-content ui-corner-all">
<img src="<s:url value='/img/edit.png'/>"
alt="<s:text name='pollen.common.editAction'/>"
style="margin-right: 20px;"/>
<s:text name='pollen.label.pollEditPage'/>
<br/>
- <s:set name="editUrl" value="%{pollEditUrl}"/>
- <s:a href="%{editUrl}" cssStyle="margin-left:50px;">
- <s:property value="editUrl"/>
+ <s:a href="%{pollEditUrl}" cssStyle="margin-left:50px;">
+ <s:property value="%{pollEditUrl}"/>
</s:a>
</div>
<div style="margin-top: 30px;">
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-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-03 19:26:50 UTC (rev 3417)
@@ -113,12 +113,18 @@
<fieldset>
<legend><s:text name="pollen.common.aboutPoll"/></legend>
<div style="float: right">
+ <s:if test="creatorUser or userAdmin">
+ <s:a namespace="/poll" action="modification/%{uriId}">
+ <img src="<s:url value='/img/editSmall.png'/>"
+ title="<s:text name='pollen.action.editPoll'/>"
+ alt="<s:text name='pollen.action.editPoll'/>"/>
+ </s:a>
+ </s:if>
<s:if test="poll.publicResults">
-
<s:a namespace="/poll" action="results/%{uriId}">
<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"/>"/>
+ 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">
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-06-03 15:40:54 UTC (rev 3416)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp 2012-06-03 19:26:50 UTC (rev 3417)
@@ -25,10 +25,25 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+<link rel="stylesheet" type="text/css" href="<s:url value='/css/tipTip.css'/>"/>
+
+<style type="text/css">
+ legend {
+ color: #727a7e;
+ font-weight: bold;
+ }
+</style>
+<script type="text/javascript"
+ src='<s:url value="/js/jquery.tipTip.minified.js"/>'></script>
+
<script type="text/javascript">
-var redirectUrl = '<s:url namespace="/user" action="createdList"/>';
+ var redirectUrl = '<s:url namespace="/user" action="createdList"/>';
+ $(function(){
+ $('img[src$="tooltip.png"]').addClass('tooltip');
+ $(".tooltip").tipTip();
+ });
</script>
-<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
+<%@include file="/WEB-INF/jsp/pollListHelper.jsp" %>
<title><s:text name="pollen.title.pollsCreatedList"/></title>
@@ -36,7 +51,8 @@
<h4><s:text name="pollen.title.pollsCreatedList.legend"/></h4>
-<s:url id="loadUrl" action="getCreatedPolls" namespace="/json" escapeAmp="false"/>
+<s:url id="loadUrl" action="getCreatedPolls" namespace="/json"
+ escapeAmp="false"/>
<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
sortable="true" pager="true" pagerButtons="true" pagerInput="true"
@@ -49,11 +65,34 @@
rowList="10,15,20,50,100" rowNum="10">
<sjg:gridColumn name="id" title="id" hidden="true"/>
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}'/>
+ <sjg:gridColumn name="description"
+ title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices"
+ title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate"
+ title='%{getText("pollen.common.beginDate")}'/>
<sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
<sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
formatter="pollFunctions" width="200" sortable="false"/>
</sjg:grid>
+
+<br/>
+<fieldset>
+ <legend><s:text name="pollen.legend.attachPoll"/>
+ <img src="<s:url value='/img/tooltip.png'/>"
+ title="<s:text name='poll.help.attachPoll'/>"
+ alt="<s:text name='poll.help.attachPoll'/>"/>
+ </legend>
+
+ <s:form namespace="/user" method="POST">
+
+ <s:textfield key="pollUri" label='%{getText("pollen.common.pollId")}'
+ required="true" size="80" value='%{pollId}'
+ tooltip='%{getText("poll.help.pollId")}'
+ tooltipIconPath="/img/tooltip.png"/>
+
+ <br/>
+ <s:submit action="attachPoll" key="pollen.action.attachPoll"/>
+ </s:form>
+</fieldset>
Added: trunk/pollen-ui-struts2/src/main/webapp/css/resume.css
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/css/resume.css (rev 0)
+++ trunk/pollen-ui-struts2/src/main/webapp/css/resume.css 2012-06-03 19:26:50 UTC (rev 3417)
@@ -0,0 +1,33 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $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%
+ */
+.ui-widget-content-green { border: 1px solid #aaaaaa; background: #b0f580 url(images/ui-bg_flat_75_b0f580_40x100.png) 50% 50% repeat-x; color: #222222; }
+.ui-widget-content-green a { color: #222222; }
+
+.ui-widget-content-yellow { border: 1px solid #aaaaaa; background: #ffffaa url(images/ui-bg_flat_75_ffffaa_40x100.png) 50% 50% repeat-x; color: #222222; }
+.ui-widget-content-yellow a { color: #222222; }
+
+.ui-corner-all {
+ margin-top: 10px;
+ padding: 10px;
+}
+
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/css/resume.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2012-06-03 17:40:54 +0200 (Sun, 03 Jun 2012)
New Revision: 3416
Url: http://chorem.org/repositories/revision/pollen/3416
Log:
- les services sont tous disponibles au niveau de chaque action
- checkup que tous les commits sont bien fait au niveau services et pas dans les actions
- suppression dans le mod?\195?\168le de certaines bi-directions (il en reste encore un peu... mais j'ai plus le courage :()
- fixes #579: Poll creator acts as a admin for his poll
- fixes #575: Impossible de supprimer un vote pour le cr?\195?\169ateur du sondage
- fixes #135: [Vote] D?\195?\169pouillement effectu?\195?\169 ?\195?\160 chaque chargement de la page des votes
Added:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/pom.xml 2012-06-03 15:40:54 UTC (rev 3416)
@@ -95,8 +95,7 @@
<defaultPackage>org.chorem.pollen.entities</defaultPackage>
<templates>
org.nuiton.topia.generator.TopiaMetaTransformer,
- org.nuiton.topia.generator.BinderHelperTransformer,
- org.nuiton.topia.generator.QueryHelperTransformer
+ org.nuiton.topia.generator.BinderHelperTransformer
</templates>
</configuration>
<goals>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/CommentDAOImpl.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -39,8 +39,9 @@
Preconditions.checkNotNull(pollId);
TopiaQuery countQuery = createQuery("e").
- addWhere("e." + Comment.PROPERTY_POLL + ".pollId",
- TopiaQuery.Op.EQ, pollId);
+ addFrom(Poll.class, "p").
+ addWhere("p." + Poll.PROPERTY_POLL_ID, TopiaQuery.Op.EQ, pollId).
+ addWhere("e in elements(p." + Poll.PROPERTY_COMMENT + ")");
long records = countByQuery(countQuery);
pager.setRecords((int) records);
@@ -56,8 +57,9 @@
Preconditions.checkNotNull(pollId);
TopiaQuery query = createQuery("e").
- addWhere("e." + Comment.PROPERTY_POLL + ".pollId",
- TopiaQuery.Op.EQ, pollId);
+ addFrom(Poll.class, "p").
+ addWhere("p." + Poll.PROPERTY_POLL_ID, TopiaQuery.Op.EQ, pollId).
+ addWhere("e in elements(p." + Poll.PROPERTY_COMMENT + ")");
query.addOrderDesc(Comment.PROPERTY_POST_DATE);
List<E> result = findAllByQuery(query);
return result;
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollDAOImpl.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -106,7 +106,9 @@
VoteDAO voteDao = PollenDAOHelper.getVoteDAO(context);
TopiaQuery query = voteDao.createQuery("e").
- setSelect("e." + Vote.PROPERTY_POLL, "e." + Vote.PROPERTY_POLL_ACCOUNT).
+ addFrom(Poll.class, "p").
+ addWhere("e in elements(p." + Poll.PROPERTY_VOTE + ")").
+ setSelect("p", "e." + Vote.PROPERTY_POLL_ACCOUNT).
addWhere("e." + Vote.PROPERTY_POLL_ACCOUNT + "." +
PollAccount.PROPERTY_USER_ACCOUNT,
TopiaQuery.Op.EQ, userToUse);
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -66,62 +66,38 @@
// Order the results by creation date (the last vote done will be
// at the end of the list)
TopiaQuery query = createQuery("e").
- addWhere("e.poll", TopiaQuery.Op.EQ, poll).
+ addFrom(Poll.class, "p").
+ addWhere("p", TopiaQuery.Op.EQ, poll).
+ addWhere("e in elements (p." + Poll.PROPERTY_VOTE + ")").
addOrder("topiaCreateDate");
TopiaFilterPagerUtil.addPagerToQuery(query, pager);
results = findAllByQuery(query);
-
-//
-// List<E> votes = find(
-// "FROM " + Vote.class.getName() +
-// " WHERE poll.pollId = :pollUId" +
-// " ORDER BY topiaCreateDate",
-// startIndex, endIndex,
-// new Object[]{"pollUId", poll.getPollId()});
-
-// if (log.isDebugEnabled()) {
-// log.debug("Nb votes found : " + votes.size());
-// }
-//
-// results = Lists.newArrayList(results);
}
return results;
}
- public boolean hasAlreadyVoted(String votingId, Poll poll) throws TopiaException {
+ public boolean hasAlreadyVoted(Poll poll, String votingId) throws TopiaException {
// Test using a count(*) on votes
TopiaQuery query = createQuery("e").
- addWhere("e.poll", TopiaQuery.Op.EQ, poll).
+ addFrom(Poll.class, "p").
+ addWhere("p", TopiaQuery.Op.EQ, poll).
+ addWhere("e in elements(p." + Poll.PROPERTY_VOTE + ")").
addWhere("e.pollAccount.votingId", TopiaQuery.Op.EQ, votingId).
addOrder("topiaCreateDate");
boolean result = existByQuery(query);
return result;
-// List<Long> tmp = transaction.find(
-// "SELECT COUNT(*)" +
-// " FROM " + Vote.class.getName() +
-// " WHERE poll.pollId = :pollUId" +
-// " AND pollAccount.votingId = :votingId",
-// "pollUId", poll.getPollId(),
-// "votingId", votingId);
-//
-// int count = tmp.get(0).intValue();
-//
-// // If the count is greater than 0, there is an existing votingId
-// // who has already voted for the poll
-// result = count > 0;
-
}
-
+
public Vote findByAccountId(String accountId) throws TopiaException {
-
- String accountIdProperty =
+
+ String accountIdProperty =
TopiaQuery.getProperty("e", Vote.PROPERTY_POLL_ACCOUNT, PollAccount.PROPERTY_ACCOUNT_ID);
TopiaQuery query = createQuery("e").addEquals(accountIdProperty, accountId);
Vote result = findByQuery(query);
return result;
}
-
-
+
+
} //VoteDAOImpl<E extends Vote>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.entities.migration;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceImpl;
import org.nuiton.topia.TopiaException;
@@ -61,8 +62,17 @@
// see http://chorem.org/issues/574
// see http://chorem.org/issues/576
removeAllCondorcetNullVotes(tx, queries);
+
+ // add a flag to not generate results each time (http://chorem.org/issues/135)
+ addResultUptodateToPoll(queries);
}
+ private void addResultUptodateToPoll(List<String> queries) {
+ queries.add("ALTER TABLE poll ADD COLUMN " +
+ Poll.PROPERTY_RESULT_UPTODATE + " boolean default false;");
+
+ }
+
private void removeAllCondorcetNullVotes(TopiaContextImplementor tx,
List<String> queries) throws TopiaException {
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -29,6 +29,7 @@
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.services.impl.PollUrlService;
import org.chorem.pollen.services.impl.PreventRuleService;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -80,6 +81,8 @@
try {
serviceContext.setTransaction(transaction);
+ PollUrlService pollUrlService =
+ serviceContext.newService(PollUrlService.class);
PollService pollService =
serviceContext.newService(PollService.class);
PreventRuleService preventRuleService =
@@ -90,7 +93,8 @@
for (Poll poll : polls) {
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+ PollUrl pollVoteUrl =
+ pollUrlService.getPollVoteUrl(poll, false);
preventRuleService.onPollToRemind(poll, pollVoteUrl);
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceFunctions.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -27,15 +27,19 @@
import com.google.common.collect.Lists;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
+import org.chorem.pollen.bean.PollResult;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceImpl;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.PersonToListImpl;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountImpl;
+import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListImpl;
import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.votecounting.business.NumberMethod;
import org.nuiton.topia.persistence.TopiaEntity;
import java.util.Date;
@@ -223,4 +227,26 @@
return result;
}
}
+
+ public static Function<Result, PollResult> newResultToBeanFunction(final Poll poll) {
+ return new Function<Result, PollResult>() {
+
+ @Override
+ public PollResult apply(Result res) {
+ PollResult dto = new PollResult();
+ dto.setId(res.getTopiaId());
+ dto.setPollId(poll.getPollId());
+ String resName = res.getName();
+ dto.setName(resName);
+ dto.setHidden(resName != null &&
+ resName.startsWith(NumberMethod.HIDDEN_PREFIX));
+ dto.setValue(res.getResultValue());
+ dto.setByGroup(res.isByGroup());
+ dto.setChoiceType(poll.getChoiceType());
+ dto.setVoteCountingType(poll.getVoteCountingType());
+ return dto;
+ }
+ };
+ }
+
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,8 +25,6 @@
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PersonListDAO;
@@ -49,9 +47,6 @@
public class FavoriteService extends PollenServiceSupport {
- /** Logger. */
- private static final Log log = LogFactory.getLog(FavoriteService.class);
-
public List<PersonList> getFavoriteLists(UserAccount user,
TopiaFilterPagerUtil.FilterPagerBean pager) {
@@ -198,6 +193,8 @@
}
dao.delete(favoriteListToDelete);
+
+ commitTransaction("Could not delete favorite list");
return favoriteListToDelete;
} catch (TopiaException e) {
@@ -245,6 +242,7 @@
pollAccountCreated.setEmail(pollAccount.getEmail());
personListToUpdate.addPollAccount(pollAccountCreated);
+ commitTransaction("Could not add poll account to favorite list");
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
@@ -291,6 +289,7 @@
pollAccountToUpdate.setVotingId(pollAccount.getVotingId());
pollAccountToUpdate.setEmail(pollAccount.getEmail());
+ commitTransaction("Could not edit poll account favorite list");
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
@@ -333,6 +332,7 @@
personListToUpdate.removePollAccount(pollAccountToRemove);
+ commitTransaction("Could not remove pollaccount to favorite list");
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.CommentDAO;
import org.chorem.pollen.business.persistence.Poll;
@@ -47,6 +46,14 @@
*/
public class PollCommentService extends PollenServiceSupport {
+ public Comment getExistingPollComment(String commentId) throws PollCommentNotFound {
+ Comment result = getEntityById(Comment.class, commentId);
+ if (result == null) {
+ throw new PollCommentNotFound();
+ }
+ return result;
+ }
+
public Comment createComment(Poll poll, Comment comment) {
Preconditions.checkNotNull(poll);
@@ -61,7 +68,7 @@
// creates the poll comment
Comment commentCreated = dao.create(
- Comment.PROPERTY_POLL, pollToUpdate,
+// Comment.PROPERTY_POLL, pollToUpdate,
Comment.PROPERTY_POST_DATE, comment.getPostDate(),
Comment.PROPERTY_AUTHOR, comment.getAuthor(),
Comment.PROPERTY_TEXT, comment.getText()
@@ -90,11 +97,8 @@
// feed notification
- PollService pollService = newService(PollService.class);
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
-
PollFeedService pollFeedService = newService(PollFeedService.class);
- pollFeedService.onAddComment(commentCreated, pollVoteUrl);
+ pollFeedService.onAddComment(poll, commentCreated);
return commentCreated;
} catch (TopiaException e) {
@@ -109,27 +113,20 @@
Preconditions.checkNotNull(poll);
Preconditions.checkNotNull(commentId);
+ Comment comment = getExistingPollComment(commentId);
+
CommentDAO dao = getDAO(Comment.class);
try {
- Comment comment = dao.findByTopiaId(commentId);
-
- if (comment == null) {
- throw new PollCommentNotFound();
- }
-
dao.delete(comment);
commitTransaction("Could not delete comment " + comment.getText());
// feed notification
- PollService pollService = newService(PollService.class);
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
-
PollFeedService pollFeedService = newService(PollFeedService.class);
- pollFeedService.onDeleteComment(comment, pollVoteUrl, reason);
+ pollFeedService.onDeleteComment(poll, comment, reason);
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
@@ -152,26 +149,31 @@
public boolean isCanDeleteComment(Comment comment,
PollAccount pollAccount,
- UserAccount userAccount) {
+ UserAccount userAccount,
+ boolean isPollCreator) {
- boolean result;
+ boolean result = false;
PollAccount commentAccount = comment.getPollAccount();
- // loggued
- if (userAccount != null) {
+ if (isPollCreator) {
+ // poll creator has admin rights on his poll
+ result = true;
+ } else if (userAccount != null) {
+
+ // loggued
boolean isAdmin = userAccount.isAdministrator();
- boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
+// boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
- result = isAdmin || isCommentAccount;
+ // pollen admin or comment owner (linked by user account)
+ result = isAdmin ||
+ userAccount.equals(commentAccount.getUserAccount());
} else if (pollAccount != null) {
+ // comment owner (linked by poll account)
result = pollAccount.equals(commentAccount);
-
- } else {
- result = false;
}
return result;
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -40,6 +40,7 @@
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.services.PollenServiceSupport;
@@ -116,37 +117,50 @@
}
}
- public void onAddComment(Comment comment, PollUrl pollVoteUrl) {
+ public void onAddComment(Poll poll, Comment comment) {
+ PollUrlService pollService = newService(PollUrlService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+
+
String title = _("pollen.feed.addCommentTitle",
comment.getAuthor());
String content = _("pollen.feed.addCommentContent",
comment.getText());
- addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
- public void onDeleteComment(Comment comment,
- PollUrl pollVoteUrl,
- String reason) {
+ public void onDeleteComment(Poll poll, Comment comment, String reason) {
+ PollUrlService pollService = newService(PollUrlService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+
String title = _("pollen.feed.deleteCommentTitle",
- comment.getAuthor());
+ comment.getAuthor(), reason);
- String content = _("pollen.feed.deleteCommentContent",
- comment.getText(), reason);
+ String content =
+ _("pollen.feed.deleteCommentContent", comment.getText());
- addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
- public void onAddVote(Vote vote,
- boolean anonymousVote,
- String pollResult,
- PollUrl pollVoteUrl) {
+ public void onAddVote(Poll poll, Vote vote) {
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ PollResultsService pollResultsService =
+ newService(PollResultsService.class);
+
+ String pollResult = pollResultsService.getResultsAsString(poll);
+
String userId;
- if (anonymousVote) {
+
+ if (vote.isAnonymous()) {
+
userId = _("pollen.common.anonymous");
} else {
userId = vote.getPollAccount().getVotingId();
@@ -156,9 +170,62 @@
String content = _("pollen.feed.addVoteContent", pollResult);
- addFeedEntry(vote.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
+ public void onUpdateVote(Poll poll,
+ Vote vote) {
+
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ PollResultsService pollResultsService =
+ newService(PollResultsService.class);
+
+ String pollResult = pollResultsService.getResultsAsString(poll);
+
+ String userId;
+
+ if (vote.isAnonymous()) {
+
+ userId = _("pollen.common.anonymous");
+ } else {
+ userId = vote.getPollAccount().getVotingId();
+
+ }
+ String title = _("pollen.feed.updateVoteTitle", userId);
+
+ String content = _("pollen.feed.updateVoteContent", pollResult);
+
+ addFeedEntry(poll, title, content, pollVoteUrl);
+ }
+
+ public void onDeleteVote(Poll poll, Vote vote, PollAccount voteAccount, String reason) {
+
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ PollResultsService pollResultsService =
+ newService(PollResultsService.class);
+
+ String pollResult = pollResultsService.getResultsAsString(poll);
+
+ String userId;
+ if (vote.isAnonymous()) {
+ userId = _("pollen.common.anonymous");
+ } else {
+ userId = voteAccount.getVotingId();
+
+ }
+ String title = _("pollen.feed.deleteVoteTitle", userId, reason);
+
+ String content = _("pollen.feed.deleteVoteContent", pollResult);
+
+ addFeedEntry(poll, title, content, pollVoteUrl);
+ }
+
public void onAddChoice(Poll poll, Choice choice, PollUrl pollVoteUrl) {
String title = _("pollen.feed.addChoiceTitle", choice.getName());
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollResultsService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -39,6 +39,7 @@
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.services.PollenServiceFunctions;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.votecounting.business.NumberMethod;
@@ -72,91 +73,53 @@
/** log. */
private static final Log log = LogFactory.getLog(PollResultsService.class);
- public PollResultList getResults(String pollId) throws PollNotFoundException {
-
- PollService pollService = newService(PollService.class);
- Poll poll = pollService.getPollByPollId(pollId);
-
- if (poll == null) {
- throw new PollNotFoundException();
- }
- PollResultList result;
- if (poll.getPollType() == PollType.GROUP) {
- result = generateResults(poll, null, true, true);
- } else {
- result = generateResults(poll, null, true, false);
- }
- return result;
- }
-
/**
- * Génère les résultats d'un sondage (= un dépouillement).
+ * Récurpération des résultats d'un sondage sous forme de
+ * {@link PollResultList}.
+ * <p/>
+ * Si les résultats ne sont pas à jour ({@link Poll#isResultUptodate()},
+ * alors ils seront regénérés.
*
- * @param poll le sondage
- * @param voteCounting type de dépouillement
- * @param byGroup résultats par groupe
- * @param groupOnly résultats uniquement par groupe
- * @return les résultats du sondage
+ * @param poll le sondage à traiter
+ * @return les résultats du sondage.
*/
- private PollResultList generateResults(Poll poll,
- VoteCountingType voteCounting,
- boolean byGroup,
- boolean groupOnly) {
+ public PollResultList getResults(Poll poll) {
+ Preconditions.checkNotNull(poll);
- if (log.isDebugEnabled()) {
- log.debug(poll.getPollId() + " (" + voteCounting
- + ") has results: " + hasResults(poll, voteCounting));
- }
- // Dépouillement du sondage.
- // S'il n'existe pas de résultats ou si le sondage est encore ouvert.
- //if (!hasResults(ePoll, voteCounting) || !ePoll.getIsClosed()) {
- PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
+ VoteCountingResultDTO result;
+ if (!poll.isResultUptodate()) {
- if (voteCounting != null) {
- dto.setVoteCounting(voteCounting);
- }
+ //must regenerate results
- // clear result (they will be regenerated ! (a big shame))
- poll.clearResult();
+ result = generateResult(poll);
- VoteCountingService service = new VoteCountingService();
+ commitTransaction("Could not generate poll result");
+ } else {
- VoteCountingResultDTO result = service.execute(dto);
+ result = getResultDTO(poll);
- ResultDAO daoResult = getDAO(Result.class);
+ }
- for (ChoiceDTO choice : result.getChoices()) {
+ boolean byGroup = poll.getPollType() == PollType.GROUP;
- Result eResult = create(daoResult);
+ VoteCountingType voteCountingType = poll.getVoteCountingType();
- Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+ // Conversion des résultats
+ List<PollResult> list = Lists.transform(
+ poll.getResult(),
+ PollenServiceFunctions.newResultToBeanFunction(poll));
- poll.addResult(eResult);
+ // Filtrage des résultats que l'on veut retourner
- eResult.setName(eChoice.getName());
- eResult.setByGroup(result.isByGroup());
- eResult.setPoll(poll);
- eResult.setResultValue(String.valueOf(choice.getValue()));
- eResult.setVoteCountingType(result.getTypeVoteCounting());
- }
-
- commitTransaction("Could not generate poll result");
-
- // Conversion et trie des résultats
- List<PollResult> list = createPollResults(poll);
-
- VoteCountingType voteCountingType = poll.getVoteCountingType();
-
Iterator<PollResult> it = list.iterator();
while (it.hasNext()) {
PollResult currentResult = it.next();
// Cas d'un dépouillement particulier
// Suppression des resultats qui ne sont pas de se dépouillement
- if (voteCounting != null
- && currentResult.getVoteCountingType() != voteCounting) {
+ if (currentResult.getVoteCountingType() != voteCountingType) {
it.remove();
}
@@ -164,15 +127,10 @@
if (byGroup) {
// Filtre group : Suppression resultats non group
- if (groupOnly && !currentResult.isByGroup()) {
+ if (!currentResult.isByGroup()) {
it.remove();
}
- // Filtre non group : Suppression resultats group
- else if (!groupOnly && currentResult.isByGroup()) {
- it.remove();
- }
-
// Suppression des autres resultats de depouillements differents
if (currentResult.getVoteCountingType() != voteCountingType) {
it.remove();
@@ -186,18 +144,60 @@
return resultList;
}
+ /**
+ * Génère les résultats d'un sondage (= un dépouillement) et les stoque en
+ * base.
+ * <p/>
+ * <strong>Note importante :</strong> Le commite n'est pas effectuée dans
+ * cette méthode car d'autres services vont appeller cette méthode au sein
+ * d'une transaction et on ne veut pas faire deux commits.
+ *
+ * @param poll le sondage à dépouiller
+ * @since 1.4
+ */
+ public VoteCountingResultDTO generateResult(Poll poll) {
+
+ Preconditions.checkNotNull(poll);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will regenerate results for poll " + poll.getPollId());
+ }
+
+ VoteCountingResultDTO result = getResultDTO(poll);
+
+ // clear result
+ poll.clearResult();
+
+ ResultDAO daoResult = getDAO(Result.class);
+
+ for (ChoiceDTO choice : result.getChoices()) {
+
+ Result eResult = create(daoResult);
+
+ Choice eChoice = poll.getChoiceByTopiaId(choice.getIdChoice());
+
+ eResult.setName(eChoice.getName());
+ eResult.setByGroup(result.isByGroup());
+// eResult.setPoll(poll);
+ eResult.setResultValue(String.valueOf(choice.getValue()));
+ eResult.setVoteCountingType(result.getTypeVoteCounting());
+
+ poll.addResult(eResult);
+ }
+
+ poll.setResultUptodate(true);
+
+ return result;
+ }
+
public String exportPolltoXml(String pollId) throws PollNotFoundException {
// Recherche du sondage
PollService pollService = newService(PollService.class);
- Poll poll = pollService.getPollByPollId(pollId);
+ Poll poll = pollService.getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
VoteCountingService service = new VoteCountingService();
@@ -216,7 +216,7 @@
// Transformation du sondage
PollExportDTO pollExport = new PollExportDTO();
- pollExport.setPollId(dto.getPollId());
+ pollExport.setPollId(pollId);
pollExport.setPoll(dto);
pollExport.setVoteCountingResults(results);
@@ -227,31 +227,6 @@
return content;
}
- /**
- * Retourne la liste des résultats d'un sondage sous forme de DTOs.
- *
- * @param poll le sondage (entitée Poll)
- * @return la liste des DTO Result
- */
- protected List<PollResult> createPollResults(Poll poll) {
- List<PollResult> results = Lists.newArrayList();
- for (Result res : poll.getResult()) {
- PollResult dto = new PollResult();
- dto.setId(res.getTopiaId());
- dto.setPollId(poll.getPollId());
- String resName = res.getName();
- dto.setName(resName);
- dto.setHidden(resName != null &&
- resName.startsWith(NumberMethod.HIDDEN_PREFIX));
- dto.setValue(res.getResultValue());
- dto.setByGroup(res.isByGroup());
- dto.setChoiceType(poll.getChoiceType());
- dto.setVoteCountingType(poll.getVoteCountingType());
- results.add(dto);
- }
- return results;
- }
-
public String getResultValue(Choice choice,
Collection<PollResult> results) {
@@ -398,7 +373,33 @@
return val;
}
+
// /**
+// * Retourne la liste des résultats d'un sondage sous forme de DTOs.
+// *
+// * @param poll le sondage (entitée Poll)
+// * @return la liste des DTO Result
+// */
+// protected List<PollResult> createPollResults(Poll poll) {
+// List<PollResult> results = Lists.newArrayList();
+// for (Result res : poll.getResult()) {
+// PollResult dto = new PollResult();
+// dto.setId(res.getTopiaId());
+// dto.setPollId(poll.getPollId());
+// String resName = res.getName();
+// dto.setName(resName);
+// dto.setHidden(resName != null &&
+// resName.startsWith(NumberMethod.HIDDEN_PREFIX));
+// dto.setValue(res.getResultValue());
+// dto.setByGroup(res.isByGroup());
+// dto.setChoiceType(poll.getChoiceType());
+// dto.setVoteCountingType(poll.getVoteCountingType());
+// results.add(dto);
+// }
+// return results;
+// }
+
+// /**
// * Création des résultats de sondage à partir d'un dto de résultats de
// * sondage.
// *
@@ -424,32 +425,32 @@
// }
// }
- /**
- * Retourne vrai si le sondage a des résultats.
- *
- * @param poll le sondage
- * @param type type de dépouillement
- * @return vrai si le sondage a des résultats
- */
- protected boolean hasResults(Poll poll, VoteCountingType type) {
- boolean hasresult = false;
+// /**
+// * Retourne vrai si le sondage a des résultats.
+// *
+// * @param poll le sondage
+// * @param type type de dépouillement
+// * @return vrai si le sondage a des résultats
+// */
+// protected boolean hasResults(Poll poll, VoteCountingType type) {
+// boolean hasresult = false;
+//
+// if (!poll.isResultEmpty()) {
+//
+// if (type == null) {
+// hasresult = true;
+// } else {
+// for (Result result : poll.getResult()) {
+// if (type.equals(result.getVoteCountingType())) {
+// hasresult = true;
+// break;
+// }
+// }
+// }
+// }
+// return hasresult;
+// }
- if (!poll.isResultEmpty()) {
-
- if (type == null) {
- hasresult = true;
- } else {
- for (Result result : poll.getResult()) {
- if (type.equals(result.getVoteCountingType())) {
- hasresult = true;
- break;
- }
- }
- }
- }
- return hasresult;
- }
-
// public String importPoll(String filePath) {
// return importPoll(filePath, null);
// }
@@ -483,15 +484,14 @@
/**
* Retourne une chaîne contenant les résultats du sondage.
*
- * @param poll le sondage
- * @param results les résultats du sondage
+ * @param poll le sondage
* @return les résultats sous forme de chaine de caractères
*/
- public String getResultsAsString(Poll poll, Collection<Result> results) {
+ public String getResultsAsString(Poll poll) {
- DateFormat dateFormat = new SimpleDateFormat();
+ DateFormat dateFormat = new SimpleDateFormat(getDateTimePattern());
StringBuilder res = new StringBuilder("");
- Iterator<Result> it = results.iterator();
+ Iterator<Result> it = poll.getResult().iterator();
while (it.hasNext()) {
Result result = it.next();
if (poll.getChoiceType() == ChoiceType.DATE) {
@@ -507,4 +507,16 @@
}
return res.toString();
}
+
+ protected VoteCountingResultDTO getResultDTO(Poll poll) {
+
+ PollDTO dto = PollenFunctions.POLL_TO_BEAN.apply(poll);
+
+ dto.setVoteCounting(poll.getVoteCountingType());
+
+ VoteCountingService service = new VoteCountingService();
+
+ VoteCountingResultDTO result = service.execute(dto);
+ return result;
+ }
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -50,7 +50,6 @@
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.business.persistence.PreventRuleDAO;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.common.ChoiceType;
@@ -74,7 +73,6 @@
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
-import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -371,10 +369,12 @@
commitTransaction("Could not create poll " + poll.getTitle());
- PollUrl pollVoteUrl = getPollVoteUrl(poll, false);
- PollUrl pollModerateUrl = getPollVoteUrl(poll, true);
- PollUrl pollEditUrl = getPollEditUrl(poll);
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+ PollUrl pollModerateUrl = pollUrlService.getPollVoteUrl(poll, true);
+ PollUrl pollEditUrl = pollUrlService.getPollEditUrl(poll);
+
// email notification
EmailService emailService = newService(EmailService.class);
emailService.onPollCreated(result, pollVoteUrl, pollModerateUrl, pollEditUrl);
@@ -448,45 +448,59 @@
commitTransaction("Could not update poll [" + poll.getTopiaId() + "]");
}
- public PollUrl getPollVoteUrl(Poll poll, boolean moderate) {
- URL applicationUrl = serviceContext.getApplicationURL();
- String baseUrl = applicationUrl + "/poll/votefor/";
- PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+// public PollUrl getPollVoteUrl(Poll poll, boolean moderate) {
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/votefor/";
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+//
+// if (moderate) {
+// String creatorId = poll.getCreator().getAccountId();
+// pollUri.setAccountId(creatorId);
+// }
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- if (moderate) {
- String creatorId = poll.getCreator().getAccountId();
- pollUri.setAccountId(creatorId);
- }
+// public PollUrl getPollUpdateVoteUrl(Poll poll) {
+// Preconditions.checkNotNull(poll);
+//
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/votefor/";
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+//
+// String creatorId = poll.getCreator().getAccountId();
+// pollUri.setAccountId(creatorId);
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
- return result;
- }
+// public PollUrl getPollEditUrl(Poll poll) {
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/modification/";
+//
+// String creatorId = poll.getCreator().getAccountId();
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- public PollUrl getPollEditUrl(Poll poll) {
- URL applicationUrl = serviceContext.getApplicationURL();
- String baseUrl = applicationUrl + "/poll/modification/";
+// public PollUrl getPollResultUrl(Poll poll) {
+// URL applicationUrl = serviceContext.getApplicationURL();
+// String baseUrl = applicationUrl + "/poll/results/";
+// PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+//
+// if (!poll.isPublicResults()) {
+// String creatorId = poll.getCreator().getAccountId();
+// pollUri.setAccountId(creatorId);
+// }
+//
+// PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+// return result;
+// }
- String creatorId = poll.getCreator().getAccountId();
- PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
-
- PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
- return result;
- }
-
- public PollUrl getPollResultUrl(Poll poll) {
- URL applicationUrl = serviceContext.getApplicationURL();
- String baseUrl = applicationUrl + "/poll/results/";
- PollUri pollUri = PollUri.newPollUri(poll.getPollId());
-
- if (!poll.isPublicResults()) {
- String creatorId = poll.getCreator().getAccountId();
- pollUri.setAccountId(creatorId);
- }
-
- PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
- return result;
- }
-
public List<Poll> getPolls(TopiaFilterPagerUtil.FilterPagerBean pager) {
Preconditions.checkNotNull(pager);
@@ -581,6 +595,22 @@
}
}
+ public Poll getExistingPollByPollId(String pollId) throws PollNotFoundException {
+
+ Preconditions.checkNotNull(pollId);
+ try {
+ PollDAO dao = getDAO(Poll.class);
+ Poll result = dao.findByPollId(pollId);
+
+ if (result == null) {
+ throw new PollNotFoundException();
+ }
+ return result;
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not find poll with pollId '" + pollId + "'", e);
+ }
+ }
+
/**
* Retrieve a pollAccount with {@code accountId}. This pollAccount will be
* attached to the given {@code userAccount} (only if not already attached).
@@ -691,12 +721,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(accountId);
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
if (userAccount == null || userAccount.isAdministrator()) {
// must check that accountId matches the poll creator id
@@ -721,12 +747,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(accountId);
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
if (userAccount == null || userAccount.isAdministrator()) {
// must check that accountId matches the poll creator id
@@ -777,12 +799,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choice);
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
saveChoice(poll, choice);
commitTransaction("Can't create new choice [" +
@@ -839,11 +857,8 @@
public void deleteChoice(String pollId, String choiceId)
throws PollNotFoundException, PollChoiceNotFoundException {
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
Choice choice = poll.getChoiceByTopiaId(choiceId);
if (choice == null) {
@@ -862,23 +877,15 @@
String pollId = uri.getPollId();
- Poll poll = getPollByPollId(pollId);
-
- if (poll == null) {
- throw new PollNotFoundException();
- }
+ getExistingPollByPollId(pollId);
}
public void checkPollResult(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
String pollId = uri.getPollId();
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
if (!poll.isPublicResults()) {
throw new UnauthorizedPollAccessException();
}
@@ -889,12 +896,8 @@
String pollId = uri.getPollId();
String accountId = uri.getAccountId();
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
PollAccountDAO dao = getDAO(PollAccount.class);
if (poll.getPollType() != PollType.FREE) {
@@ -936,12 +939,8 @@
String pollId = uri.getPollId();
String accountId = uri.getAccountId();
- Poll poll = getPollByPollId(pollId);
+ Poll poll = getExistingPollByPollId(pollId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
String creatorId = poll.getCreator().getAccountId();
if (!creatorId.equals(accountId)) {
@@ -987,32 +986,32 @@
createThumbnail(pollChoiceImage, pollChoiceImageThumb, 100);
}
- public void addVoteToPoll(Poll poll, Vote vote) {
+// public void addVoteToPoll(Poll poll, Vote vote) {
+//
+// String pollId = poll.getTopiaId();
+// String voteId = vote.getTopiaId();
+//
+// Poll pollToUpdate = getEntityById(Poll.class, pollId);
+// Vote voteToAdd = getEntityById(Vote.class, voteId);
+//
+// pollToUpdate.addVote(voteToAdd);
+//
+// // Update hasVoted flag for RESTRICTED/GROUP poll
+// if (PollType.FREE != poll.getPollType()) {
+//
+// PersonToList personToList = pollToUpdate.getPersonToListByVote(voteToAdd);
+// personToList.setHasVoted(true);
+// }
+//
+// commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]");
+//
+// // Send notification if necessary
+// PreventRuleService preventRuleService = newService(PreventRuleService.class);
+// PollUrl pollVoteUrl = getPollVoteUrl(pollToUpdate, false);
+// PollUrl modifUrl = getPollEditUrl(pollToUpdate);
+// preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
+// }
- String pollId = poll.getTopiaId();
- String voteId = vote.getTopiaId();
-
- Poll pollToUpdate = getEntityById(Poll.class, pollId);
- Vote voteToAdd = getEntityById(Vote.class, voteId);
-
- pollToUpdate.addVote(voteToAdd);
-
- // Update hasVoted flag for RESTRICTED/GROUP poll
- if (PollType.FREE != poll.getPollType()) {
-
- PersonToList personToList = pollToUpdate.getPersonToListByVote(voteToAdd);
- personToList.setHasVoted(true);
- }
-
- commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]");
-
- // Send notification if necessary
- PreventRuleService preventRuleService = newService(PreventRuleService.class);
- PollUrl pollVoteUrl = getPollVoteUrl(pollToUpdate, false);
- PollUrl modifUrl = getPollEditUrl(pollToUpdate);
- preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
- }
-
public PersonToList getNewPersonToList(PollAccount pollAccount) {
PersonToList result = newInstance(getDAO(PersonToList.class));
result.setWeight(1);
@@ -1051,8 +1050,10 @@
result.setName(votingList.getName());
result.setWeight(votingList.getWeight());
- PollUrl voteURL = getPollVoteUrl(poll, false);
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+ PollUrl voteURL = pollUrlService.getPollVoteUrl(poll, false);
+
// Merge PersonToList
List<PersonToList> personToListsUpdated = Lists.newArrayList();
for (PersonToList personToList : votingList.getPollAccountPersonToList()) {
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollUrlService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -0,0 +1,66 @@
+package org.chorem.pollen.services.impl;
+
+import com.google.common.base.Preconditions;
+import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.services.PollenServiceSupport;
+
+import java.net.URL;
+
+/**
+ * Service to deal with url used by application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class PollUrlService extends PollenServiceSupport {
+
+ public PollUrl getPollVoteUrl(Poll poll, boolean moderate) {
+
+ Preconditions.checkNotNull(poll);
+
+ URL applicationUrl = serviceContext.getApplicationURL();
+ String baseUrl = applicationUrl + "/poll/votefor/";
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+
+ if (moderate) {
+ String creatorId = poll.getCreator().getAccountId();
+ pollUri.setAccountId(creatorId);
+ }
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
+ }
+
+ public PollUrl getPollEditUrl(Poll poll) {
+
+ Preconditions.checkNotNull(poll);
+
+ URL applicationUrl = serviceContext.getApplicationURL();
+ String baseUrl = applicationUrl + "/poll/modification/";
+
+ String creatorId = poll.getCreator().getAccountId();
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
+ }
+
+ public PollUrl getPollResultUrl(Poll poll) {
+
+ Preconditions.checkNotNull(poll);
+
+ URL applicationUrl = serviceContext.getApplicationURL();
+ String baseUrl = applicationUrl + "/poll/results/";
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+
+ if (!poll.isPublicResults()) {
+ String creatorId = poll.getCreator().getAccountId();
+ pollUri.setAccountId(creatorId);
+ }
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
+ }
+}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -183,6 +183,8 @@
}
copyUserAccount(user, userToUpdate);
+
+ commitTransaction("Could not update user");
return userToUpdate;
} catch (TopiaException e) {
@@ -250,6 +252,8 @@
throw new UserNotFoundException();
}
dao.delete(user);
+
+ commitTransaction("Could not delete user "+id);
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -29,7 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.PersonToListDAO;
@@ -51,7 +51,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaFilterPagerUtil;
-import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -140,21 +139,21 @@
return result;
}
- /**
- * Retrieve the URL to update a vote based on {@link PollUri}.
- *
- * @param pollUri Uri with pollId and accountId
- * @return the URL that allow the voting person to update his vote
- */
- public String getUpdateVoteUrl(PollUri pollUri) {
- Preconditions.checkNotNull(pollUri.getAccountId());
- URL baseUrl = serviceContext.getApplicationURL();
- String result =
- String.format("%s/poll/votefor/%s", baseUrl, pollUri.getUri());
- return result;
- }
+// /**
+// * Retrieve the URL to update a vote based on {@link PollUri}.
+// *
+// * @param pollUri Uri with pollId and accountId
+// * @return the URL that allow the voting person to update his vote
+// */
+// public String getUpdateVoteUrl(PollUri pollUri) {
+// Preconditions.checkNotNull(pollUri.getAccountId());
+// URL baseUrl = serviceContext.getApplicationURL();
+// String result =
+// String.format("%s/poll/votefor/%s", baseUrl, pollUri.getUri());
+// return result;
+// }
- public Vote createVote(Vote vote) throws PollAccountNotFound {
+ public Vote createVote(Poll poll, Vote vote) throws PollAccountNotFound {
VoteDAO voteDAO = getDAO(Vote.class);
@@ -206,12 +205,41 @@
log.debug("Entity created: " + result.getTopiaId());
}
+ Poll pollToUpdate = getEntityById(Poll.class, poll.getTopiaId());
+
+ pollToUpdate.addVote(result);
+
+ // Update hasVoted flag for RESTRICTED/GROUP poll
+ if (PollType.FREE != poll.getPollType()) {
+
+ PersonToList personToList = pollToUpdate.getPersonToListByVote(result);
+ personToList.setHasVoted(true);
+ }
+
+ // regnenerate poll results
+
+ generatePollResult(pollToUpdate);
+
commitTransaction("Could not create vote");
+ PollUrlService pollUrlService = newService(PollUrlService.class);
+
+ PollUrl pollVoteUrl = pollUrlService.getPollVoteUrl(poll, false);
+
+ // Send notification if necessary
+ PreventRuleService preventRuleService = newService(PreventRuleService.class);
+ PollUrl modifUrl = pollUrlService.getPollEditUrl(poll);
+ preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
+
+ // feed notification
+
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onAddVote(pollToUpdate, result);
+
return result;
}
- public Vote updateVote(Vote vote) throws VoteNotFoundException {
+ public Vote updateVote(Poll poll, Vote vote) throws VoteNotFoundException {
Vote result = getEntityById(Vote.class, vote.getTopiaId());
@@ -234,6 +262,8 @@
}
result.setAnonymous(vote.isAnonymous());
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+
// -- List of VoteToChoice -- //
for (VoteToChoice input : vote.getChoiceVoteToChoice()) {
@@ -250,7 +280,8 @@
}
} else if (voteToChoiceEntity != null) {
- deleteVoteToChoice(result, voteToChoiceEntity);
+ result.removeChoiceVoteToChoice(voteToChoiceEntity);
+ delete(voteToChoiceDao, voteToChoiceEntity);
}
}
@@ -258,35 +289,17 @@
log.debug("Entity updated: " + result.getTopiaId());
}
+ generatePollResult(poll);
+
commitTransaction("Could not update vote");
- return result;
- }
+ // feed notification
- protected VoteToChoice createVoteToChoice(Vote vote, VoteToChoice source) {
-
- VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
- VoteToChoice result = create(voteToChoiceDao);
-
- String choiceId = source.getChoice().getTopiaId();
- Choice choiceLoaded = getEntityById(Choice.class, choiceId);
- result.setChoice(choiceLoaded);
-
- result.setVote(vote);
- result.setVoteValue(source.getVoteValue());
-
- vote.addChoiceVoteToChoice(result);
-
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onUpdateVote(poll, result);
return result;
}
- protected void deleteVoteToChoice(Vote vote, VoteToChoice entity) {
-
- VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
- vote.removeChoiceVoteToChoice(entity);
- delete(voteToChoiceDao, entity);
- }
-
/**
* Delete vote referenced by {@code voteId}. This will also delete all
* associated {@link VoteToChoice}. The {@link PollAccount} could also be
@@ -295,10 +308,16 @@
* is activated.
*
* @param voteId TopiaId of the vote
+ * @param reason reason to delete this vote
* @throws VoteNotFoundException if vote doesn't exist
*/
- public void deleteVote(String voteId) throws VoteNotFoundException {
+ public void deleteVote(Poll poll,
+ String voteId,
+ String reason) throws VoteNotFoundException {
+ Preconditions.checkNotNull(poll);
+ Preconditions.checkNotNull(voteId);
+
Vote entityToDelete = getEntityById(Vote.class, voteId);
if (entityToDelete == null) {
@@ -315,12 +334,12 @@
delete(voteToChoiceDao, voteToChoice);
}
- Poll poll = entityToDelete.getPoll();
+// Poll poll = entityToDelete.getPoll();
+ PollAccount voteAccount = entityToDelete.getPollAccount();
if (PollType.FREE == poll.getPollType()) {
// Delete vote PollAccount if the Poll is free and account is not the creator
- PollAccount voteAccount = entityToDelete.getPollAccount();
if (!voteAccount.equals(poll.getCreator())) {
PollAccountDAO accountDAO = getDAO(PollAccount.class);
delete(accountDAO, voteAccount);
@@ -335,13 +354,18 @@
poll.removeVote(entityToDelete);
delete(dao, entityToDelete);
- // TODO calculate results if continuous
-
if (log.isDebugEnabled()) {
log.debug("Entity deleted: " + voteId);
}
+ generatePollResult(poll);
+
commitTransaction("Could not delete vote");
+
+ // feed notification
+
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onDeleteVote(poll, entityToDelete, voteAccount, reason);
}
public List<Vote> getVotesByPoll(Poll poll,
@@ -423,10 +447,10 @@
return result;
}
- public boolean hasAlreadyVoted(String votingId, Poll poll) {
+ public boolean hasAlreadyVoted(Poll poll, String votingId) {
try {
VoteDAO dao = getDAO(Vote.class);
- boolean result = dao.hasAlreadyVoted(votingId, poll);
+ boolean result = dao.hasAlreadyVoted(poll, votingId);
return result;
} catch (Exception e) {
throw new PollenTechnicalException(
@@ -464,4 +488,26 @@
}
}
+ protected VoteToChoice createVoteToChoice(Vote vote, VoteToChoice source) {
+
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ VoteToChoice result = create(voteToChoiceDao);
+
+ String choiceId = source.getChoice().getTopiaId();
+ Choice choiceLoaded = getEntityById(Choice.class, choiceId);
+ result.setChoice(choiceLoaded);
+
+ result.setVote(vote);
+ result.setVoteValue(source.getVoteValue());
+
+ vote.addChoiceVoteToChoice(result);
+
+ return result;
+ }
+
+ protected void generatePollResult(Poll poll) {
+ PollResultsService pollResultsService = newService(PollResultsService.class);
+ pollResultsService.generateResult(poll);
+ }
+
} //voteservice
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -2,7 +2,7 @@
pollen.common.addingChoicesContent=From %s to %s
pollen.common.addingChoicesFrom=From %s
pollen.common.addingChoicesTo=Until %s
-pollen.common.anonymous=Anonymous vote
+pollen.common.anonymous=Anonymous voter
pollen.common.datePattern=MM/dd/yyyy
pollen.common.dateTimePattern=MM/dd/yyyy HH\:mm
pollen.common.numberVote-average=Average of numbers
@@ -31,12 +31,16 @@
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
pollen.feed.addCommentTitle=New comment of %s
-pollen.feed.addVoteContent=
-pollen.feed.addVoteTitle=
+pollen.feed.addVoteContent=Poll result\: %s
+pollen.feed.addVoteTitle=New vote from '%s'
pollen.feed.createPollContent=
pollen.feed.deleteCommentContent=%s
-pollen.feed.deleteCommentTitle=Delete comment of %s for reason '%s'
+pollen.feed.deleteCommentTitle=Delete comment of '%s' for reason '%s'
+pollen.feed.deleteVoteContent=Poll result\: %s
+pollen.feed.deleteVoteTitle=Delete vote of '%s' for reason '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
+pollen.feed.updateVoteContent=Poll result\: %s
+pollen.feed.updateVoteTitle=Vote modified for '%s'
pollen.info.admin.created=Super admin was created with login %1$s
pollen.info.admin.exists=Super admin already exists
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -2,7 +2,7 @@
pollen.common.addingChoicesContent=Du %s au %s
pollen.common.addingChoicesFrom=Depuis le %s
pollen.common.addingChoicesTo=Jusqu'au %s
-pollen.common.anonymous=Vote anonyme
+pollen.common.anonymous=votant anonyme
pollen.common.datePattern=dd/MM/yyyy
pollen.common.dateTimePattern=dd/MM/yyyy HH\:mm
pollen.common.numberVote-average=Moyenne des nombres
@@ -31,12 +31,16 @@
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
pollen.feed.addCommentTitle=Nouveau commentaire de %s
-pollen.feed.addVoteContent=
-pollen.feed.addVoteTitle=
+pollen.feed.addVoteContent=Résultat du sondage \: %s
+pollen.feed.addVoteTitle=Nouveau vote de '%s'
pollen.feed.createPollContent=
pollen.feed.deleteCommentContent=%s
-pollen.feed.deleteCommentTitle=Suppression du commentaire de %s pour la raison '%s'
+pollen.feed.deleteCommentTitle=Suppression du commentaire de '%s' pour la raison '%s'
+pollen.feed.deleteVoteContent=Résultat du sondage \: %s
+pollen.feed.deleteVoteTitle=Suppression du vote de '%s' pour la raison '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
+pollen.feed.updateVoteContent=Résultat du sondage \: %s
+pollen.feed.updateVoteTitle=Vote modifié de '%s'
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
pollen.info.admin.exists=Le super admin existe déjà
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -35,6 +35,15 @@
import org.chorem.pollen.services.PollenService;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.PollenServiceFactory;
+import org.chorem.pollen.services.impl.FavoriteService;
+import org.chorem.pollen.services.impl.PollCommentService;
+import org.chorem.pollen.services.impl.PollFeedService;
+import org.chorem.pollen.services.impl.PollResultsService;
+import org.chorem.pollen.services.impl.PollService;
+import org.chorem.pollen.services.impl.PollUrlService;
+import org.chorem.pollen.services.impl.PreventRuleService;
+import org.chorem.pollen.services.impl.UserService;
+import org.chorem.pollen.services.impl.VoteService;
import org.chorem.pollen.ui.PollenApplicationContext;
import org.chorem.pollen.ui.PollenSession;
import org.nuiton.topia.TopiaContext;
@@ -88,6 +97,24 @@
protected transient TopiaContext transaction;
+ private transient PollService pollService;
+
+ private transient PollUrlService pollUrlService;
+
+ private transient PollResultsService pollResultsService;
+
+ private transient VoteService voteService;
+
+ private transient PollCommentService pollCommentService;
+
+ private transient PollFeedService pollFeedService;
+
+ private transient UserService userService;
+
+ private transient FavoriteService favoriteService;
+
+ private transient PreventRuleService preventRuleService;
+
public PageSkin getSkin() {
return PageSkin.INDEX;
}
@@ -246,31 +273,16 @@
public Collection<String> getFlashMessages() {
List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
-// if (result == null) {
-// result = Collections.emptyList();
-// } else {
-// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
-// }
return result;
}
public Collection<String> getFlashErrors() {
List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
-// if (result == null) {
-// result = Collections.emptyList();
-// } else {
-// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
-// }
return result;
}
public Collection<String> getFlashWarnings() {
List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_WARNINGS);
-// if (result == null) {
-// result = Collections.emptyList();
-// } else {
-// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
-// }
return result;
}
@@ -307,4 +319,67 @@
boolean result = super.hasErrors();
return result || hasFlashErrors();
}
+
+ protected final PollService getPollService() {
+ if (pollService == null) {
+ pollService = newService(PollService.class);
+ }
+ return pollService;
+ }
+
+ protected final PollUrlService getPollUrlService() {
+ if (pollUrlService == null) {
+ pollUrlService = newService(PollUrlService.class);
+ }
+ return pollUrlService;
+ }
+
+ protected final PollResultsService getPollResultsService() {
+ if (pollResultsService == null) {
+ pollResultsService = newService(PollResultsService.class);
+ }
+ return pollResultsService;
+ }
+
+ protected final VoteService getVoteService() {
+ if (voteService == null) {
+ voteService = newService(VoteService.class);
+ }
+ return voteService;
+ }
+
+ protected final PollCommentService getPollCommentService() {
+ if (pollCommentService == null) {
+ pollCommentService = newService(PollCommentService.class);
+ }
+ return pollCommentService;
+ }
+
+ protected final PollFeedService getPollFeedService() {
+ if (pollFeedService == null) {
+ pollFeedService = newService(PollFeedService.class);
+ }
+ return pollFeedService;
+ }
+
+ protected final UserService getUserService() {
+ if (userService == null) {
+ userService = newService(UserService.class);
+ }
+ return userService;
+ }
+
+ protected final FavoriteService getFavoriteService() {
+ if (favoriteService == null) {
+ favoriteService = newService(FavoriteService.class);
+ }
+ return favoriteService;
+ }
+
+ protected final PreventRuleService getPreventRuleService() {
+ if (preventRuleService == null) {
+ preventRuleService = newService(PreventRuleService.class);
+ }
+ return preventRuleService;
+ }
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,8 +26,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.services.impl.PollService;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -80,17 +78,13 @@
if (StringUtils.isNotEmpty(userId)) {
// load user
- UserService service = newService(UserService.class);
-
- user = service.getEntityById(UserAccount.class, userId);
+ user = getUserService().getEntityById(UserAccount.class, userId);
}
if (StringUtils.isNotEmpty(pollId)) {
// load poll
- PollService servcie = newService(PollService.class);
-
- poll = servcie.getPollByPollId(pollId);
+ poll = getPollService().getExistingPollByPollId(pollId);
}
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -59,7 +59,7 @@
Preconditions.checkNotNull(userId);
- UserService service = newService(UserService.class);
+ UserService service = getUserService();
String result = INPUT;
@@ -68,7 +68,6 @@
service.getEntityById(UserAccount.class, userId);
service.deleteUser(userId);
- getTransaction().commitTransaction();
addFlashMessage(
_("pollen.information.user.deleted", user.getDisplayName()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -28,7 +28,6 @@
import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException;
import org.chorem.pollen.services.exceptions.UserInvalidPasswordException;
import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -45,8 +44,7 @@
public UserAccount getUser() {
if (user == null) {
- UserService service = newService(UserService.class);
- user = service.getNewUser();
+ user = getUserService().getNewUser();
}
return user;
}
@@ -77,7 +75,7 @@
String result = INPUT;
try {
- newService(UserService.class).createUser(user, true);
+ getUserService().createUser(user, true);
addFlashMessage(
_("pollen.information.user.created",
@@ -102,13 +100,10 @@
Preconditions.checkNotNull(user);
- UserService service = newService(UserService.class);
-
String result = INPUT;
try {
- service.updateUser(user, null, true);
- getTransaction().commitTransaction();
+ getUserService().updateUser(user, null, true);
addFlashMessage(
_("pollen.information.user.updated",
user.getDisplayName()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -78,10 +78,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- PollService service = newService(PollService.class);
+ File file = getPollService().getPollChoiceImageFile(pollId, choiceId, thumb);
- File file = service.getPollChoiceImageFile(pollId, choiceId, thumb);
-
MimetypesFileTypeMap mimes = new MimetypesFileTypeMap();
contentType = mimes.getContentType(file);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetCreatedPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -73,7 +73,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Poll> pollList = pollService.getCreatedPolls(pager,
getPollenUserAccount());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.collect.Maps;
import org.chorem.pollen.business.persistence.PersonList;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import java.util.Map;
@@ -59,10 +58,8 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
-
PersonList personList =
- service.getEntityById(PersonList.class, favoriteListId);
+ getFavoriteService().getEntityById(PersonList.class, favoriteListId);
favoriteList = Maps.newHashMap();
favoriteList.put("id", personList.getTopiaId());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccount.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.beans.Binder;
@@ -60,10 +59,8 @@
@Override
public String execute() throws Exception {
- UserService userService = newService(UserService.class);
-
PollAccount userAccount =
- userService.getEntityById(PollAccount.class, pollAccountId);
+ getUserService().getEntityById(PollAccount.class, pollAccountId);
Binder<PollAccount, PollAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteListPollAccounts.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -81,7 +81,7 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
+ FavoriteService service = getFavoriteService();
PersonList favoriteList =
service.getEntityById(PersonList.class, favoriteListId);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetFavoriteLists.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.collect.Maps;
import org.chorem.pollen.business.persistence.PersonList;
-import org.chorem.pollen.services.impl.FavoriteService;
import java.util.List;
import java.util.Map;
@@ -69,9 +68,7 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
-
- List<PersonList> allFavoriteLists = service.getFavoriteLists(
+ List<PersonList> allFavoriteLists = getFavoriteService().getFavoriteLists(
getPollenUserAccount(),
pager);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetInvitedPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -75,7 +75,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Pair<Poll, PollAccount>> invitedPolls = pollService.getInvitedPolls(pager,
getPollenUserAccount());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetParticipatedPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -76,7 +76,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Pair<Poll, PollAccount>> participatedPolls =
pollService.getParticipatedPolls(pager, getPollenUserAccount());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -28,7 +28,6 @@
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.PollCommentService;
import org.nuiton.util.beans.Binder;
import java.util.List;
@@ -82,10 +81,9 @@
Preconditions.checkNotNull(pollId);
- PollCommentService pollService = newService(PollCommentService.class);
+ List<Comment> commentList = getPollCommentService().getComments(
+ pager, pollId);
- List<Comment> commentList = pollService.getComments(pager, pollId);
-
UserAccount userAccount = getPollenUserAccount();
comments = new Map[commentList.size()];
@@ -101,22 +99,21 @@
Comment.PROPERTY_AUTHOR
);
map.put("id", comment.getTopiaId());
- Set<String> functions = getCommentFunctions(pollService,
- comment,
- userAccount);
+ Set<String> functions = getCommentFunctions(
+ comment,
+ userAccount);
map.put("functions", functions);
comments[index++] = map;
}
return SUCCESS;
}
- private Set<String> getCommentFunctions(PollCommentService pollService,
- Comment comment,
+ private Set<String> getCommentFunctions(Comment comment,
UserAccount userAccount) {
Set<String> result = Sets.newHashSet();
- boolean canDelete = pollService.isCanDeleteComment(comment,
- null,
- userAccount);
+ //TODO-tchemit-2012-06-03 Should use also pollAccountId (if specified in url)...
+ boolean canDelete = getPollCommentService().isCanDeleteComment(
+ comment, null, userAccount, false);
if (canDelete) {
result.add("delete");
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPolls.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -72,7 +72,7 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
List<Poll> pollList = pollService.getPolls(pager);
@@ -84,15 +84,6 @@
Map<String, Object> map = pollService.pollToMap(poll, binder);
-// Map<String, Object> map = binder.obtainProperties(
-// poll,
-// Poll.PROPERTY_TITLE,
-// Poll.PROPERTY_POLL_ID,
-// Poll.PROPERTY_DESCRIPTION,
-// Poll.PROPERTY_BEGIN_DATE,
-// Poll.PROPERTY_END_DATE
-// );
-// map.put("id", poll.getTopiaId());
map.put("moderateId", poll.getAdminId());
map.put("resultId", poll.getAdminId());
map.put("adminId", poll.getAdminId());
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.beans.Binder;
@@ -60,10 +59,9 @@
@Override
public String execute() throws Exception {
- UserService userService = newService(UserService.class);
+ UserAccount userAccount = getUserService().getEntityById(
+ UserAccount.class, userId);
- UserAccount userAccount = userService.getEntityById(UserAccount.class, userId);
-
Binder<UserAccount, UserAccount> binder =
PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class);
user = binder.obtainProperties(
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import com.google.common.collect.Sets;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.entities.PollenBinderHelper;
-import org.chorem.pollen.services.impl.UserService;
import org.nuiton.util.beans.Binder;
import java.util.List;
@@ -72,10 +71,8 @@
@Override
public String execute() throws Exception {
- UserService userService = newService(UserService.class);
+ List<UserAccount> allUsers = getUserService().getUsers(pager);
- List<UserAccount> allUsers = userService.getUsers(pager);
-
UserAccount userAccount = getPollenUserAccount();
users = new Map[allUsers.size()];
Binder<UserAccount, UserAccount> binder =
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -39,7 +39,6 @@
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.PollenServiceFunctions;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -88,8 +87,6 @@
private int reminderHourCountdown = 2;
- private transient PollService pollService;
-
/** To create a new personToList. */
private transient Function<PersonToList, PersonToList> persontoListCreator;
@@ -110,13 +107,6 @@
return PageSkin.EDITION;
}
- protected PollService getPollService() {
- if (pollService == null) {
- pollService = newService(PollService.class);
- }
- return pollService;
- }
-
public Poll getPoll() {
return poll;
}
@@ -204,15 +194,15 @@
}
public String getPollVoteUrl() {
- return getPollService().getPollVoteUrl(poll, false).getUrl();
+ return getPollUrlService().getPollVoteUrl(poll, false).getUrl();
}
public String getPollModerateUrl() {
- return getPollService().getPollVoteUrl(poll, true).getUrl();
+ return getPollUrlService().getPollVoteUrl(poll, true).getUrl();
}
public String getPollEditUrl() {
- return getPollService().getPollEditUrl(poll).getUrl();
+ return getPollUrlService().getPollEditUrl(poll).getUrl();
}
public int getSelectedTab() {
@@ -234,18 +224,6 @@
return isEdit() && poll.sizeVote() > 0;
}
-// public boolean isPersonEditable(PersonToList personToList) {
-// boolean result;
-// // If vote is started, the person is editable if he hasn't vote yet
-// if (isVoteStarted()) {
-// result = !personToList.isHasVoted();
-//
-// } else {
-// result = true;
-// }
-// return result;
-// }
-
public boolean isCreatorUserAccountDefined() {
PollAccount creator = poll.getCreator();
return creator.getUserAccount() != null;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -59,8 +59,8 @@
}
public final void setUriId(PollUri pollUri) {
- if (log.isInfoEnabled()) {
- log.info("PollUri : " + pollUri.getUri());
+ if (log.isDebugEnabled()) {
+ log.debug("PollUri : " + pollUri.getUri());
}
this.pollUri = pollUri;
}
@@ -70,8 +70,8 @@
}
public final void setPage(int page) {
- if (log.isInfoEnabled()) {
- log.info("Page number : " + page);
+ if (log.isDebugEnabled()) {
+ log.debug("Page number : " + page);
}
this.page = page;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -42,11 +42,6 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.PollCommentService;
-import org.chorem.pollen.services.impl.PollFeedService;
-import org.chorem.pollen.services.impl.PollResultsService;
-import org.chorem.pollen.services.impl.PollService;
-import org.chorem.pollen.services.impl.VoteService;
import org.chorem.pollen.ui.actions.PageSkin;
import java.util.Date;
@@ -67,14 +62,6 @@
/** Logger. */
private static final Log log = LogFactory.getLog(AbstractVoteAction.class);
- private transient PollResultsService pollResultsService;
-
- private transient PollService pollService;
-
- private transient VoteService voteService;
-
- private transient PollCommentService pollCommentService;
-
private Poll poll;
private boolean feedFileExisting;
@@ -106,34 +93,6 @@
return PageSkin.VOTE;
}
- protected PollResultsService getPollResultsService() {
- if (pollResultsService == null) {
- pollResultsService = newService(PollResultsService.class);
- }
- return pollResultsService;
- }
-
- protected PollService getPollService() {
- if (pollService == null) {
- pollService = newService(PollService.class);
- }
- return pollService;
- }
-
- protected VoteService getVoteService() {
- if (voteService == null) {
- voteService = newService(VoteService.class);
- }
- return voteService;
- }
-
- protected PollCommentService getPollCommentService() {
- if (pollCommentService == null) {
- pollCommentService = newService(PollCommentService.class);
- }
- return pollCommentService;
- }
-
@Override
public void setParameters(Map<String, String[]> parameters) {
this.parameters = parameters;
@@ -298,8 +257,7 @@
loadPollResults();
loadPollComments();
- PollFeedService pollFeedService = newService(PollFeedService.class);
- feedFileExisting = pollFeedService.isFeedExists(poll);
+ feedFileExisting = getPollFeedService().isFeedExists(poll);
PollAccount pollCreator = poll.getCreator();
if (getPollenUserAccount() == null) {
@@ -372,7 +330,11 @@
}
public boolean isModifAllowed(Vote vote) {
- return getVoteService().isUpdateAllowed(getPoll(), vote.getTopiaId(), getAccountId(), getPollenUserAccount());
+ return getVoteService().isUpdateAllowed(
+ getPoll(),
+ vote.getTopiaId(),
+ getAccountId(),
+ getPollenUserAccount());
}
public boolean isVoteAllowed() {
@@ -380,11 +342,16 @@
}
public boolean isDeleteCommentAllowed(Comment comment) {
- return getPollCommentService().isCanDeleteComment(comment, getPollAccount(), getPollenUserAccount());
+ return getPollCommentService().isCanDeleteComment(
+ comment,
+ getPollAccount(),
+ getPollenUserAccount(),
+ isCreatorUser());
}
public boolean isDeleteVoteAllowed(Vote vote) {
- return isUserAdmin();
+ // can delete a vote if admin or poll creator
+ return isUserAdmin() || isCreatorUser();
}
public String escapeLineBreak(String text) {
@@ -398,7 +365,8 @@
protected void loadPollAccount() throws PollAccountNotFound {
// Current poll account
- pollAccount = getPollService().getPollAccountEditable(getAccountId(), getPollenUserAccount(), poll);
+ pollAccount = getPollService().getPollAccountEditable(
+ getAccountId(), getPollenUserAccount(), poll);
}
protected void loadPoll() throws PollNotFoundException {
@@ -408,9 +376,10 @@
String pollId = getPollId();
if (StringUtils.isNotEmpty(pollId)) {
- poll = getPollService().getPollByPollId(pollId);
+ poll = getPollService().getExistingPollByPollId(pollId);
}
- Preconditions.checkNotNull(poll, "Can't load poll with id = [" + pollId + "]");
+ Preconditions.checkNotNull(poll,
+ "Can't load poll with id = [" + pollId + "]");
if (log.isDebugEnabled()) {
log.debug("Poll TopiaId: " + poll.getTopiaId());
@@ -419,17 +388,14 @@
protected void loadPollComments() {
- PollCommentService service = newService(PollCommentService.class);
-
- comments = service.getAllComments(poll.getPollId());
+ comments = getPollCommentService().getAllComments(poll.getPollId());
}
protected void loadPollResults() throws PollNotFoundException {
- PollResultsService service = getPollResultsService();
+ PollResultList pollResultList =
+ getPollResultsService().getResults(poll);
- PollResultList pollResultList = service.getResults(poll.getPollId());
-
results = pollResultList.getPollResults();
if (log.isDebugEnabled()) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -101,14 +101,16 @@
Object value = ChoiceHelper.toValue(choice, choiceType);
// -- Validate value notEmpty
- if (value == null || (value instanceof String && StringUtils.isBlank((String) value))) {
+ if (value == null ||
+ (value instanceof String && StringUtils.isBlank((String) value))) {
String typeLabel = getText(choiceType.getI18nKey());
addFieldError("choice." + propName,
_("pollen.error.choice.empty", typeLabel));
} else {
// Retrieve existing values to check if the new choice not already exists
- Iterable<Object> pollChoiceValues = ChoiceHelper.toValues(getPoll().getChoice(), choiceType);
+ Iterable<Object> pollChoiceValues = ChoiceHelper.toValues(
+ getPoll().getChoice(), choiceType);
// -- Validate value notExists
if (Iterables.contains(pollChoiceValues, value)) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -38,6 +38,11 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Text of the comment to add.
+ *
+ * @since 1.3
+ */
private String commentText;
public void setCommentText(String commentText) {
@@ -78,6 +83,7 @@
// create the comment
getPollCommentService().createComment(getPoll(), comment);
+ addFlashMessage(_("pollen.info.comment.added"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClosePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,8 +23,6 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.services.impl.PollService;
-
/**
* Closes an existing poll.
*
@@ -48,10 +46,10 @@
@Override
public String execute() throws Exception {
- PollService service = newService(PollService.class);
+ getPollService().closePoll(getPollId(),
+ getPollenUserAccount(),
+ getAccountId());
- service.closePoll(getPollId(), getPollenUserAccount(), getAccountId());
-
addFlashMessage(_("pollen.information.poll.closed"));
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm delete of a poll choice.
@@ -57,10 +56,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- PollService service = newService(PollService.class);
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
- Poll poll = service.getPollByPollId(pollId);
-
choice = poll.getChoiceByTopiaId(choiceId);
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,11 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Comment;
-import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.exceptions.PollCommentNotFound;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.PollCommentService;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm a comment delete.
@@ -41,10 +36,18 @@
private static final long serialVersionUID = 1L;
- /** Id of the comment. */
+ /**
+ * Id of the comment.
+ *
+ * @since 1.3
+ */
protected String commentId;
- /** Comment to delete. */
+ /**
+ * Loaded comment to delete.
+ *
+ * @since 1.3
+ */
protected Comment comment;
public void setCommentId(String commentId) {
@@ -62,22 +65,10 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
- PollService pollService = newService(PollService.class);
+ getPollService().getExistingPollByPollId(pollId);
- Poll poll = pollService.getPollByPollId(getPollId());
+ comment = getPollCommentService().getExistingPollComment(commentId);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
- PollCommentService service = newService(PollCommentService.class);
-
- comment = service.getEntityById(Comment.class, commentId);
-
- if (comment == null) {
- throw new PollCommentNotFound();
- }
-
return SUCCESS;
}
}
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteVote.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.Vote;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm delete of a poll vote
@@ -38,8 +37,18 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Id of the vote to delete.
+ *
+ * @since 1.3
+ */
protected String voteId;
+ /**
+ * Loaded vote to delete.
+ *
+ * @since 1.3
+ */
protected Vote vote;
public void setVoteId(String voteId) {
@@ -57,10 +66,8 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(voteId);
- PollService service = newService(PollService.class);
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
- Poll poll = service.getPollByPollId(pollId);
-
vote = poll.getVoteByTopiaId(voteId);
return SUCCESS;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmPollAction.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.impl.PollService;
/**
* To confirm a poll action (such as delete or close).
@@ -57,7 +56,8 @@
public String execute() throws Exception {
String pollId = getPollId();
Preconditions.checkNotNull(pollId);
- poll = newService(PollService.class).getPollByPollId(pollId);
+
+ poll = getPollService().getExistingPollByPollId(pollId);
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteChoice.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -24,7 +24,6 @@
package org.chorem.pollen.ui.actions.poll;
import com.google.common.base.Preconditions;
-import org.chorem.pollen.services.impl.PollService;
/**
* To delete a poll choice
@@ -49,10 +48,9 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choiceId);
- PollService service = newService(PollService.class);
+ getPollService().deleteChoice(pollId, choiceId);
- service.deleteChoice(pollId, choiceId);
-
+ addFlashMessage(_("pollen.info.choice.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,12 +25,7 @@
import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
-import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.exceptions.PollCommentNotFound;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.PollCommentService;
-import org.chorem.pollen.services.impl.PollService;
/**
* To delete a poll comment.
@@ -42,7 +37,11 @@
private static final long serialVersionUID = 1L;
- /** Id of the comment to delete. */
+ /**
+ * Id of the comment to delete.
+ *
+ * @since 1.3
+ */
protected String commentId;
/**
@@ -64,26 +63,14 @@
@Override
public String execute() throws Exception {
- PollService pollService = newService(PollService.class);
-
- Poll poll = pollService.getPollByPollId(getPollId());
-
- if (poll==null) {
- throw new PollNotFoundException();
- }
-
+ Preconditions.checkNotNull(getPollId());
Preconditions.checkNotNull(commentId);
- PollCommentService service = newService(PollCommentService.class);
+ Poll poll = getPollService().getExistingPollByPollId(getPollId());
- Comment comment = service.getEntityById(Comment.class, commentId);
+ getPollCommentService().deleteComment(poll, commentId, reason);
- if (comment == null) {
- throw new PollCommentNotFound();
- }
-
- service.deleteComment(poll, commentId, reason);
-
+ addFlashMessage(_("pollen.info.comment.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeletePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,8 +23,6 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.services.impl.PollService;
-
/**
* Deletes an existing poll.
*
@@ -48,9 +46,10 @@
@Override
public String execute() throws Exception {
- PollService service = newService(PollService.class);
- service.deletePoll(getPollId(), getPollenUserAccount(), getAccountId());
+ getPollService().deletePoll(getPollId(),
+ getPollenUserAccount(),
+ getAccountId());
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -24,7 +24,7 @@
package org.chorem.pollen.ui.actions.poll;
import com.google.common.base.Preconditions;
-import org.chorem.pollen.services.impl.VoteService;
+import org.chorem.pollen.business.persistence.Poll;
/**
* To delete a poll vote.
@@ -36,21 +36,39 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Id of the vote to delete.
+ *
+ * @since 1.3
+ */
protected String voteId;
+ /**
+ * Reason for deleting this vote (if any).
+ *
+ * @since 1.4
+ */
+ protected String reason;
+
public void setVoteId(String voteId) {
this.voteId = voteId;
}
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
@Override
public String execute() throws Exception {
+ Preconditions.checkNotNull(getPollId());
Preconditions.checkNotNull(voteId);
- VoteService service = newService(VoteService.class);
+ Poll poll = getPollService().getExistingPollByPollId(getPollId());
- service.deleteVote(voteId);
+ getVoteService().deleteVote(poll, voteId, reason);
+ addFlashMessage(_("pollen.info.vote.deleted"));
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DisplayPersonToList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.persistence.PersonToList;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -103,24 +102,8 @@
public String execute() throws Exception {
if (personToList == null) {
- personToList = newService(PollService.class).getNewPersonToList(null);
+ personToList = getPollService().getNewPersonToList(null);
}
-
-// // consume personToList errors
-// String token = getPersonToListErrorTokenId(tokenId, personToListNumber);
-// Map<String, String> errors = getPollenSession().getDynamicData(token);
-// if (MapUtils.isNotEmpty(errors)) {
-// // transmit them as field errors
-// for (Map.Entry<String, String> e : errors.entrySet()) {
-// String fieldName = e.getKey();
-// String errorMessage = e.getValue();
-// if (log.isInfoEnabled()) {
-// log.info("Transmit error on " + fieldName + " [" + errorMessage + "]");
-// }
-// addFieldError(fieldName, errorMessage);
-// }
-// }
-// getPollenSession().removeDynamicData(token);
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ExportPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import com.google.common.base.Preconditions;
import org.apache.commons.io.IOUtils;
-import org.chorem.pollen.services.impl.PollResultsService;
import java.io.InputStream;
@@ -63,10 +62,8 @@
String pollId = getPollId();
Preconditions.checkNotNull(pollId);
- PollResultsService service = newService(PollResultsService.class);
+ String exportContent = getPollResultsService().exportPolltoXml(pollId);
- String exportContent = service.exportPolltoXml(pollId);
-
filename = "exportPoll-" + pollId + ".xml";
contentLength = exportContent.length() * 2;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetPollFeed.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,9 +25,6 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.PollFeedService;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import java.io.File;
@@ -67,18 +64,10 @@
Preconditions.checkNotNull(pollId);
- PollService service = newService(PollService.class);
+ Poll poll = getPollService().getExistingPollByPollId(pollId);
- Poll poll = service.getPollByPollId(pollId);
+ File feedLocation = getPollFeedService().getFeedLocation(poll);
- if (poll == null) {
- throw new PollNotFoundException();
- }
-
- PollFeedService pollFeedService = newService(PollFeedService.class);
-
- File feedLocation = pollFeedService.getFeedLocation(poll);
-
contentLength = feedLocation.length();
inputStream = new FileInputStream(feedLocation);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ImportPersonListToVotingList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -29,7 +29,6 @@
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.services.PollenServiceFunctions;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -91,9 +90,8 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
PersonList favoriteList =
- service.getFavoriteList(getPollenUserAccount(), personListId);
+ getFavoriteService().getFavoriteList(getPollenUserAccount(), personListId);
Function<PersonToList, PersonToList> persontoListCreator =
PollenServiceFunctions.newPersonToListCreator();
@@ -103,7 +101,7 @@
votingList = votingListCreator.apply(null);
- PollService pollService = newService(PollService.class);
+ PollService pollService = getPollService();
for (PollAccount pollAccount : favoriteList.getPollAccount()) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -44,7 +44,6 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollResultsService;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.converters.DateConverter;
import org.nuiton.util.StringUtil;
@@ -158,10 +157,8 @@
String pollId = getPollId();
Preconditions.checkNotNull(pollId);
- PollService service = newService(PollService.class);
+ poll = getPollService().getExistingPollByPollId(pollId);
- poll = service.getPollByPollId(pollId);
-
if (poll == null) {
addFlashError(_("pollen.error.pollNotFound"));
} else {
@@ -252,10 +249,9 @@
protected void loadResults() throws PollNotFoundException {
- PollResultsService service = newService(PollResultsService.class);
+ PollResultsService service = getPollResultsService();
- PollResultList resultListDTO =
- service.getResults(poll.getPollId());
+ PollResultList resultListDTO = service.getResults(poll);
results = resultListDTO.getPollResults();
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultLink.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -23,8 +23,8 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.actions.PageSkin;
/**
@@ -37,19 +37,10 @@
private static final long serialVersionUID = 1L;
- protected PollService pollService;
-
protected Poll poll;
protected String pollResultUrl;
- protected PollService getPollService() {
- if (pollService == null) {
- pollService = newService(PollService.class);
- }
- return pollService;
- }
-
@Override
public PageSkin getSkin() {
return PageSkin.EDITION;
@@ -67,10 +58,11 @@
public String execute() throws Exception {
String pollUid = getPollId();
+ Preconditions.checkNotNull(pollUid);
- poll = getPollService().getPollByPollId(pollUid);
+ poll = getPollService().getExistingPollByPollId(pollUid);
- pollResultUrl = getPollService().getPollResultUrl(poll).getUrl();
+ pollResultUrl = getPollUrlService().getPollResultUrl(poll).getUrl();
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -243,8 +243,7 @@
poll.clearPreventRule();
- PreventRuleService preventRuleService =
- newService(PreventRuleService.class);
+ PreventRuleService preventRuleService = getPreventRuleService();
if (isNotification()) {
// add a notification rule
@@ -752,7 +751,7 @@
// add personToList maps to session (but just now, since votingList
// could have been reindex)
for (Map.Entry<Integer, VotingList> entry : result.entrySet()) {
- Integer votingListNumber = entry.getKey();
+// Integer votingListNumber = entry.getKey();
VotingList votingList = entry.getValue();
if (!votingList.isPollAccountPersonToListEmpty()) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SelectPersonListToVotingList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -27,7 +27,6 @@
import org.chorem.pollen.PollenFunctions;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import java.util.List;
@@ -82,9 +81,9 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
UserAccount userAccount = getPollenUserAccount();
- List<PersonList> personLists = service.getFavoriteLists(userAccount);
+ List<PersonList> personLists =
+ getFavoriteService().getFavoriteLists(userAccount);
personList = Maps.uniqueIndex(personLists, PollenFunctions.ENTITY_BY_ID);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -28,12 +28,13 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.services.impl.VoteService;
/**
* Votes to a poll.
@@ -75,7 +76,7 @@
// check if the new pollAccount (topiaId = null) has already voted
if (pollAccount.getTopiaId() == null &&
- getVoteService().hasAlreadyVoted(name, poll)) {
+ getVoteService().hasAlreadyVoted(poll, name)) {
addFieldError("pollAccount.votingId",
_("pollen.error.user.alreadyVoted"));
}
@@ -131,25 +132,33 @@
// - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
// - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
- if (getVote().getTopiaId() != null) {
- getVoteService().updateVote(getVote());
+ Poll poll = getPoll();
+ Vote vote = getVote();
+
+ VoteService voteService = getVoteService();
+
+ if (vote.getTopiaId() == null) {
+
+ // create a new vote
+ voteService.createVote(poll, vote);
} else {
- Vote voteCreated = getVoteService().createVote(getVote());
- getPollService().addVoteToPoll(getPoll(), voteCreated);
+
+ // update existing vote
+ voteService.updateVote(poll, vote);
}
//TODO tchemit-2012-05-18 Why clean messages and just messages here ?
clearFlashMessages();
// For free Poll, display the update Url (useless if user is logged)
- if (PollType.FREE == getPoll().getPollType() && !isUserLoggued()) {
+ if (PollType.FREE == poll.getPollType() && !isUserLoggued()) {
- String pollId = getPoll().getPollId();
+ String pollId = poll.getPollId();
String accountId = getPollAccount().getAccountId();
- PollUri pollUri = PollUri.newPollUri(pollId, accountId);
+// PollUri pollUri = PollUri.newPollUri(pollId, accountId);
- String updateUrl = getVoteService().getUpdateVoteUrl(pollUri);
+ PollUrl updateUrl = getPollUrlService().getPollVoteUrl(poll, true);
if (log.isDebugEnabled()) {
log.debug(String.format(
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -76,20 +75,18 @@
@Override
public String execute() throws Exception {
- FavoriteService service = newService(FavoriteService.class);
-
if (StringUtils.isNotEmpty(favoriteListId)) {
// load favorite list
- favoriteList = service.getEntityById(PersonList.class,
- favoriteListId);
+ favoriteList = getFavoriteService().getEntityById(PersonList.class,
+ favoriteListId);
}
if (StringUtils.isNotEmpty(pollAccountId)) {
// load poll account
- pollAccount = service.getEntityById(PollAccount.class,
- pollAccountId);
+ pollAccount = getFavoriteService().getEntityById(PollAccount.class,
+ pollAccountId);
}
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -62,7 +62,7 @@
String result = INPUT;
try {
- FavoriteService service = newService(FavoriteService.class);
+ FavoriteService service = getFavoriteService();
PersonList favoriteList = service.getEntityById(
PersonList.class, favoriteListId);
@@ -70,8 +70,6 @@
PersonList deletedFavoritedList = service.deleteFavoriteList(
getPollenUserAccount(), favoriteList);
- getTransaction().commitTransaction();
-
addFlashMessage(_("pollen.information.favoriteList.deleted",
deletedFavoritedList.getName()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -65,7 +65,7 @@
Preconditions.checkNotNull(pollAccountId);
- FavoriteService service = newService(FavoriteService.class);
+ FavoriteService service = getFavoriteService();
PersonList favoriteList = service.getEntityById(PersonList.class,
favoriteListId);
@@ -75,8 +75,6 @@
service.removePollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
-
addFlashMessage(
_("pollen.information.pollAccount.removedFromFavoriteList",
pollAccount.getVotingId()));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Edit.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException;
import org.chorem.pollen.services.exceptions.UserInvalidPasswordException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -53,8 +52,7 @@
public UserAccount getUser() {
if (user == null) {
- UserService service = newService(UserService.class);
- user = service.getNewUser();
+ user = getUserService().getNewUser();
}
return user;
}
@@ -77,8 +75,8 @@
public String input() throws Exception {
UserAccount userAccount = getPollenUserAccount();
- UserService userService = newService(UserService.class);
- user = userService.getEntityById(UserAccount.class, userAccount.getTopiaId());
+ user = getUserService().getEntityById(UserAccount.class,
+ userAccount.getTopiaId());
return INPUT;
}
@@ -89,13 +87,10 @@
user.setAdministrator(
getPollenUserAccount().isAdministrator());
- UserService service = newService(UserService.class);
-
String result = INPUT;
try {
UserAccount updatedUser =
- service.updateUser(user, newPassword, false);
- getTransaction().commitTransaction();
+ getUserService().updateUser(user, newPassword, false);
// push back user to session
getPollenSession().setUserAccount(updatedUser);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Login.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -27,7 +27,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.UserInvalidPasswordException;
import org.chorem.pollen.services.exceptions.UserNotFoundException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
/**
@@ -75,14 +74,13 @@
@Override
public String execute() throws Exception {
- UserService service = newService(UserService.class);
-
if (StringUtils.isBlank(login) || StringUtils.isBlank(password)) {
addFlashError(_("pollen.error.user.bad.login.or.password"));
} else {
try {
- UserAccount userAccount = service.connect(login, password);
+ UserAccount userAccount =
+ getUserService().connect(login, password);
getPollenSession().setUserAccount(userAccount);
addFlashMessage(_("pollen.information.your.are.loggued"));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/LostPassword.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.services.exceptions.UserNotFoundException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PollenActionSupport;
import org.nuiton.util.StringUtil;
@@ -57,9 +56,8 @@
} else {
- UserService service = newService(UserService.class);
try {
- service.lostPassword(email);
+ getUserService().lostPassword(email);
addFlashMessage(_("pollen.information.lostPassword.success"));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -99,10 +99,8 @@
action = actions[0];
}
- FavoriteService service = newService(FavoriteService.class);
-
try {
- favoriteList = service.getFavoriteList(
+ favoriteList = getFavoriteService().getFavoriteList(
getPollenUserAccount(), favoriteListId);
} catch (FavoriteListNotFoundException e) {
addFlashError(_("pollen.error.favoriteList.not.found"));
@@ -118,12 +116,10 @@
String result = INPUT;
- FavoriteService service = newService(FavoriteService.class);
-
try {
- service.addPollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
+ getFavoriteService().addPollAccountToFavoriteList(
+ favoriteList, pollAccount);
addFlashMessage(
_("pollen.information.pollAccount.addedTofavoriteList",
@@ -146,12 +142,10 @@
String result = INPUT;
- FavoriteService service = newService(FavoriteService.class);
-
try {
- service.editPollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
+ getFavoriteService().editPollAccountToFavoriteList(
+ favoriteList, pollAccount);
addFlashMessage(
_("pollen.information.pollAccount.updatedTofavoriteList",
@@ -173,11 +167,9 @@
Preconditions.checkNotNull(pollAccount);
Preconditions.checkNotNull(pollAccount.getTopiaId());
- FavoriteService service = newService(FavoriteService.class);
+ getFavoriteService().removePollAccountToFavoriteList(
+ favoriteList, pollAccount);
- service.removePollAccountToFavoriteList(favoriteList, pollAccount);
- getTransaction().commitTransaction();
-
addFlashMessage(
_("pollen.information.pollAccount.removedFromFavoriteList",
pollAccount.getVotingId()));
@@ -190,8 +182,7 @@
protected PollAccount getPollAccount() {
if (pollAccount == null) {
- FavoriteService service = newService(FavoriteService.class);
- pollAccount = service.newPollAccountForFavoriteList();
+ pollAccount = getFavoriteService().newPollAccountForFavoriteList();
}
return pollAccount;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -34,7 +34,6 @@
import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException;
import org.chorem.pollen.services.impl.FavoriteListImportCSV;
import org.chorem.pollen.services.impl.FavoriteListImportLDAP;
-import org.chorem.pollen.services.impl.FavoriteService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -63,15 +62,6 @@
protected String action;
- private FavoriteService favoriteService;
-
- public FavoriteService getFavoriteService() {
- if (favoriteService == null) {
- favoriteService = newService(FavoriteService.class);
- }
- return favoriteService;
- }
-
public void setCsvImport(File csvImport) {
this.csvImport = csvImport;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-06-03 15:40:54 UTC (rev 3416)
@@ -26,7 +26,6 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException;
import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException;
-import org.chorem.pollen.services.impl.UserService;
import org.chorem.pollen.ui.actions.PageSkin;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -46,8 +45,7 @@
public UserAccount getUser() {
if (user == null) {
- UserService service = newService(UserService.class);
- user = service.getNewUser();
+ user = getUserService().getNewUser();
}
return user;
}
@@ -70,8 +68,7 @@
String result = INPUT;
try {
- UserAccount createdUser =
- newService(UserService.class).createUser(user, false);
+ UserAccount createdUser = getUserService().createUser(user, false);
getPollenSession().setUserAccount(createdUser);
addFlashMessage(_("pollen.information.your.are.loggued"));
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -25,7 +25,6 @@
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
pollen.action.editVote=Modifier le vote
-pollen.common.deleteReason=Reason for delete
pollen.action.importPersonListToExistingVotingList=Add selected voting list
pollen.action.importPersonListToNewVotingList=Create a new group from the selected voting list
pollen.action.login=Log me In
@@ -70,6 +69,7 @@
pollen.common.datePattern=
pollen.common.datePickerPattern=mm/dd/yy
pollen.common.dateTimePattern=
+pollen.common.deleteReason=Reason for delete
pollen.common.description=Description
pollen.common.displayType-group=Results by groups
pollen.common.displayType-normal=Results
@@ -210,6 +210,10 @@
pollen.fieldset.userInformation.toDelete=User informations to delete
pollen.fieldset.userInformation.toUpdate=User informations to update
pollen.image.not.loaded=Image not loaded
+pollen.info.choice.deleted=Choice deleted
+pollen.info.comment.added=Comment added
+pollen.info.comment.deleted=Comment deleted
+pollen.info.vote.deleted=Vote deleted
pollen.information.confirmClonePoll=Confirm clone of poll\:
pollen.information.confirmClosePoll=Confirm close of poll\:
pollen.information.confirmDeleteFavoriteList=Confirm delete of favorite list\:
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 15:40:54 UTC (rev 3416)
@@ -24,7 +24,6 @@
pollen.action.editPoll=Modifier le sondage
pollen.action.editPollAccount=Editer le membre sélectionné
pollen.action.editUser=Editer un utilisateur sélectionné
-pollen.common.deleteReason=Raison de suppression
pollen.action.editVote=Modifier le vote
pollen.action.importPersonListToExistingVotingList=Ajouter la liste sélectionnée de votants
pollen.action.importPersonListToNewVotingList=Créer un groupe à partir de la liste sélectionnée
@@ -70,6 +69,7 @@
pollen.common.datePattern=
pollen.common.datePickerPattern=dd/mm/yy
pollen.common.dateTimePattern=
+pollen.common.deleteReason=Raison de suppression
pollen.common.description=Description
pollen.common.displayType-group=Résultats par groupes
pollen.common.displayType-normal=Résultats
@@ -210,6 +210,10 @@
pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer
pollen.fieldset.userInformation.toUpdate=Informations de l'utilisateur à mettre à jour
pollen.image.not.loaded=Image non chargée
+pollen.info.choice.deleted=Choix supprimé
+pollen.info.comment.added=Commentaire ajouté
+pollen.info.comment.deleted=Commentaire supprimé
+pollen.info.vote.deleted=Vote supprimé
pollen.information.confirmClonePoll=Confirmer le clonage du sondage \:
pollen.information.confirmClosePoll=Confirmer la fermeture du sondage \:
pollen.information.confirmDeleteFavoriteList=Confirmer la suppression de la liste de votants \:
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-06-03 11:15:13 UTC (rev 3415)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-06-03 15:40:54 UTC (rev 3416)
@@ -35,6 +35,9 @@
</s:param>
</s:text>.
+ <s:textarea key='reason' rows="3" required="true"
+ label="%{getText('pollen.common.deleteReason')}"/>
+
<hr/>
<div align="right">
1
0
r3415 - trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 13:15:13 +0200 (Sun, 03 Jun 2012)
New Revision: 3415
Url: http://chorem.org/repositories/revision/pollen/3415
Log:
fix format code + usage of for-each
Modified:
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2012-06-03 09:40:52 UTC (rev 3414)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2012-06-03 11:15:13 UTC (rev 3415)
@@ -23,12 +23,6 @@
*/
package org.chorem.pollen.votecounting.services;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.common.ChoiceType;
@@ -50,6 +44,11 @@
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Implémentation du service d'export.
*
@@ -57,7 +56,6 @@
* @author rannou
* @version $Id$
*/
-@SuppressWarnings("unchecked")
public class ServiceExportImpl implements ServiceExport {
private PollDTO poll;
@@ -71,9 +69,7 @@
/** log. */
private static final Log log = LogFactory.getLog(ServiceExportImpl.class);
- /**
- * Constructor
- */
+ /** Constructor */
public ServiceExportImpl() {
}
@@ -121,8 +117,7 @@
/**
* Construction du document XML à partir du sondage.
*
- * @param le chemin du fichier à créer
- * @return le fichier créé
+ * @param filePath le chemin du fichier à créer
*/
private void savePoll(String filePath) {
@@ -138,16 +133,16 @@
pollElm.setAttribute("voteCounting", poll.getVoteCounting().name());
pollElm.setAttribute("closed", poll.isClosed() ? "true" : "false");
pollElm.setAttribute("choiceAddAllowed",
- poll.isChoiceAddAllowed() ? "true" : "false");
+ poll.isChoiceAddAllowed() ? "true" : "false");
pollElm.setAttribute("anonymousVoteAllowed", poll
- .isAnonymousVoteAllowed() ? "true" : "false");
+ .isAnonymousVoteAllowed() ? "true" : "false");
pollElm
.setAttribute("anonymous", poll.isAnonymous() ? "true"
- : "false");
+ : "false");
pollElm.setAttribute("publicResults", poll.isPublicResults() ? "true"
- : "false");
+ : "false");
pollElm.setAttribute("continuousResults",
- poll.isContinuousResults() ? "true" : "false");
+ poll.isContinuousResults() ? "true" : "false");
Element titleElm = new Element("title");
titleElm.setText(poll.getTitle());
@@ -172,9 +167,8 @@
// Création des commentaires
Element commentsElm = new Element("comments");
- Iterator iteratorComment = poll.getComments().listIterator();
- while (iteratorComment.hasNext()) {
- Element commentElm = save((CommentDTO) iteratorComment.next());
+ for (CommentDTO commentDTO : poll.getComments()) {
+ Element commentElm = save(commentDTO);
commentsElm.addContent(commentElm);
}
@@ -183,9 +177,8 @@
// Création des groupes de votants
Element groupsElm = new Element("groups");
- Iterator iteratorGroup = poll.getVotingGroups().listIterator();
- while (iteratorGroup.hasNext()) {
- Element groupElm = save((VotingGroupDTO) iteratorGroup.next());
+ for (VotingGroupDTO votingGroupDTO : poll.getVotingGroups()) {
+ Element groupElm = save(votingGroupDTO);
groupsElm.addContent(groupElm);
}
@@ -194,9 +187,8 @@
// Création des choix
Element pollChoicesElm = new Element("pollChoices");
- Iterator itPollChoices = poll.getChoices().listIterator();
- while (itPollChoices.hasNext()) {
- Element pollChoiceElm = save((PollChoiceDTO) itPollChoices.next());
+ for (PollChoiceDTO pollChoiceDTO : poll.getChoices()) {
+ Element pollChoiceElm = save(pollChoiceDTO);
pollChoicesElm.addContent(pollChoiceElm);
}
pollElm.addContent(pollChoicesElm);
@@ -204,11 +196,8 @@
// Création des résultats
Element voteCountingResultsElm = new Element("voteCountingResults");
- Iterator iteratorvoteCountingResults = voteCountingResults
- .listIterator();
- while (iteratorvoteCountingResults.hasNext()) {
- Element voteCountingResult = save((VoteCountingResultDTO) iteratorvoteCountingResults
- .next());
+ for (VoteCountingResultDTO voteCountingResult1 : voteCountingResults) {
+ Element voteCountingResult = save(voteCountingResult1);
voteCountingResultsElm.addContent(voteCountingResult);
}
@@ -242,11 +231,8 @@
Element votingPersonsElm = new Element("votingPersons");
- Iterator iteratorVotingPersons = group.getVotingPersons()
- .listIterator();
- while (iteratorVotingPersons.hasNext()) {
- Element votingPersonElm = save((VotingPersonDTO) iteratorVotingPersons
- .next());
+ for (VotingPersonDTO votingPersonDTO : group.getVotingPersons()) {
+ Element votingPersonElm = save(votingPersonDTO);
votingPersonsElm.addContent(votingPersonElm);
}
groupElm.addContent(votingPersonsElm);
@@ -259,7 +245,7 @@
votingPersonElm.setAttribute("votingId", votingPerson.getVotingId());
votingPersonElm.setAttribute("weight", Double.toString(votingPerson
- .getWeight()));
+ .getWeight()));
Element emailElm = new Element("email");
emailElm.setText(votingPerson.getEmail());
@@ -271,14 +257,11 @@
Element choicesElm = new Element("choices");
- Iterator iteratorChoices = votingPerson.getChoices().listIterator();
- while (iteratorChoices.hasNext()) {
- VoteToChoiceDTO voteToChoice = (VoteToChoiceDTO) iteratorChoices
- .next();
+ for (VoteToChoiceDTO voteToChoice : votingPerson.getChoices()) {
Element choiceElm = new Element("choice");
choiceElm.setAttribute("idChoice", voteToChoice.getIdChoice());
choiceElm.setAttribute("value", Double.toString(voteToChoice
- .getValue()));
+ .getValue()));
choicesElm.addContent(choiceElm);
}
@@ -323,10 +306,8 @@
Element choicesElm = new Element("choices");
- Iterator iteratorChoices = voteCountingResults.getChoices()
- .listIterator();
- while (iteratorChoices.hasNext()) {
- Element choiceElm = save((ChoiceDTO) iteratorChoices.next());
+ for (ChoiceDTO choiceDTO : voteCountingResults.getChoices()) {
+ Element choiceElm = save(choiceDTO);
choicesElm.addContent(choiceElm);
}
@@ -371,7 +352,7 @@
sortie.output(document, new FileOutputStream(file));
} catch (java.io.IOException e) {
log.error("Erreur lors de l'enregistrement du document : "
- + filePath, e);
+ + filePath, e);
}
}
@@ -391,25 +372,25 @@
poll.setCreatorId(pollElm.getChild("creatorId").getText());
poll.setCreatorEmail(pollElm.getChild("creatorEmail").getText());
poll.setMaxChoiceNb(Integer.parseInt(pollElm.getChild("maxChoiceNb")
- .getText()));
+ .getText()));
poll.setPollType(PollType
- .valueOf(pollElm.getAttributeValue("pollType")));
+ .valueOf(pollElm.getAttributeValue("pollType")));
poll.setChoiceType(ChoiceType.valueOf(pollElm
- .getAttributeValue("choiceType")));
+ .getAttributeValue("choiceType")));
poll.setVoteCounting(VoteCountingType.valueOf(pollElm
- .getAttributeValue("voteCounting")));
+ .getAttributeValue("voteCounting")));
poll.setClosed(Boolean.valueOf(pollElm.getAttributeValue("closed")));
poll.setChoiceAddAllowed(Boolean.valueOf(pollElm
- .getAttributeValue("choiceAddAllowed")));
+ .getAttributeValue("choiceAddAllowed")));
poll.setAnonymousVoteAllowed(Boolean.valueOf(pollElm
- .getAttributeValue("anonymousVoteAllowed")));
+ .getAttributeValue("anonymousVoteAllowed")));
poll.setAnonymous(Boolean.valueOf(pollElm
- .getAttributeValue("anonymous")));
+ .getAttributeValue("anonymous")));
poll.setPublicResults(Boolean.valueOf(pollElm
- .getAttributeValue("publicResults")));
+ .getAttributeValue("publicResults")));
poll.setContinuousResults(Boolean.valueOf(pollElm
- .getAttributeValue("continuousResults")));
+ .getAttributeValue("continuousResults")));
// Ajout des commentaires
Element commentsElm = pollElm.getChild("comments");
@@ -451,11 +432,10 @@
private List loadComments(List<Element> listComments) {
List vectorComments = new ArrayList<CommentDTO>();
- Iterator i = listComments.listIterator();
- while (i.hasNext()) {
- Element commentElm = (Element) i.next();
- CommentDTO comment = new CommentDTO(commentElm
- .getAttributeValue("votingId"), commentElm.getText());
+ for (Element commentElm : listComments) {
+ CommentDTO comment = new CommentDTO(
+ commentElm.getAttributeValue("votingId"),
+ commentElm.getText());
vectorComments.add(comment);
}
@@ -465,12 +445,10 @@
private List loadGroups(List<Element> listGroups) {
List vectorGroups = new ArrayList<VotingGroupDTO>();
- Iterator i = listGroups.listIterator();
- while (i.hasNext()) {
- Element groupElm = (Element) i.next();
- VotingGroupDTO group = new VotingGroupDTO(groupElm
- .getAttributeValue("idGroup"), Double.parseDouble((groupElm
- .getAttributeValue("weight"))));
+ for (Element groupElm : listGroups) {
+ VotingGroupDTO group = new VotingGroupDTO(
+ groupElm.getAttributeValue("idGroup"),
+ Double.parseDouble((groupElm.getAttributeValue("weight"))));
group.setName(groupElm.getAttributeValue("name"));
@@ -490,16 +468,14 @@
private List loadVotingPersons(List<Element> listVotingPersons) {
List vectorVotingPersons = new ArrayList<VotingPersonDTO>();
- Iterator i = listVotingPersons.listIterator();
- while (i.hasNext()) {
- Element votingPersonElm = (Element) i.next();
- VotingPersonDTO votingPerson = new VotingPersonDTO(votingPersonElm
- .getAttributeValue("votingId"), Double
+ for (Element votingPersonElm : listVotingPersons) {
+ VotingPersonDTO votingPerson = new VotingPersonDTO(
+ votingPersonElm.getAttributeValue("votingId"), Double
.parseDouble((votingPersonElm.getAttributeValue("weight"))));
votingPerson.setEmail(votingPersonElm.getChild("email").getValue());
- votingPerson.setComment(votingPersonElm.getChild("comment")
- .getValue());
+ votingPerson.setComment(
+ votingPersonElm.getChild("comment").getValue());
Element choicesElm = votingPersonElm.getChild("choices");
@@ -516,12 +492,9 @@
private List loadVoteToChoices(List<Element> listVoteToChoices) {
List vectorVoteToChoices = new ArrayList<VotingPersonDTO>();
- Iterator i = listVoteToChoices.listIterator();
- while (i.hasNext()) {
- Element voteToChoiceElm = (Element) i.next();
-
- VoteToChoiceDTO voteToChoice = new VoteToChoiceDTO(voteToChoiceElm
- .getAttributeValue("idChoice"), Double
+ for (Element voteToChoiceElm : listVoteToChoices) {
+ VoteToChoiceDTO voteToChoice = new VoteToChoiceDTO(
+ voteToChoiceElm.getAttributeValue("idChoice"), Double
.parseDouble(voteToChoiceElm.getAttributeValue("value")));
vectorVoteToChoices.add(voteToChoice);
}
@@ -532,19 +505,17 @@
private List loadPollChoices(List<Element> listPollChoices) {
List vectorPollChoices = new ArrayList<PollChoiceDTO>();
- Iterator i = listPollChoices.listIterator();
- while (i.hasNext()) {
- Element pollChoiceElm = (Element) i.next();
- PollChoiceDTO pollChoice = new PollChoiceDTO(pollChoiceElm
- .getAttributeValue("idChoice"));
+ for (Element pollChoiceElm : listPollChoices) {
+ PollChoiceDTO pollChoice = new PollChoiceDTO(
+ pollChoiceElm.getAttributeValue("idChoice"));
String pollChoiceName = pollChoiceElm.getChild("name").getValue();
pollChoice.setName(pollChoiceName);
pollChoice.setHidden(pollChoiceName != null
- && pollChoiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
+ && pollChoiceName.startsWith(NumberMethod.HIDDEN_PREFIX));
- pollChoice.setDescription(pollChoiceElm.getChild("description")
- .getValue());
+ pollChoice.setDescription(
+ pollChoiceElm.getChild("description").getValue());
vectorPollChoices.add(pollChoice);
}
@@ -555,20 +526,18 @@
private List loadVoteCountingResults(List<Element> listVoteCountingResults) {
List vectorVoteCountingResults = new ArrayList<VoteCountingResultDTO>();
- Iterator i = listVoteCountingResults.listIterator();
- while (i.hasNext()) {
- Element voteCountingResultElm = (Element) i.next();
+ for (Element voteCountingResultElm : listVoteCountingResults) {
VoteCountingResultDTO voteCountingResult = new VoteCountingResultDTO();
- voteCountingResult.setIdPoll(voteCountingResultElm
- .getAttributeValue("idPoll"));
- voteCountingResult.setNbVotes(Integer
- .parseInt(voteCountingResultElm.getChild("nbVotes")
- .getValue()));
+ voteCountingResult.setIdPoll(
+ voteCountingResultElm.getAttributeValue("idPoll"));
+ voteCountingResult.setNbVotes(
+ Integer.parseInt(voteCountingResultElm.getChild("nbVotes")
+ .getValue()));
voteCountingResult.setChoiceResult(voteCountingResultElm.getChild(
"choiceResult").getValue());
- voteCountingResult.setByGroup(Boolean
- .parseBoolean((voteCountingResultElm.getChild("isByGroup")
- .getValue())));
+ voteCountingResult.setByGroup(
+ Boolean.parseBoolean(
+ voteCountingResultElm.getChild("isByGroup").getValue()));
Element choicesElm = voteCountingResultElm.getChild("choices");
List<Element> listChoices = choicesElm.getChildren("choice");
@@ -583,14 +552,12 @@
private List loadChoices(List<Element> listChoices) {
List vectorChoices = new ArrayList<ChoiceDTO>();
- Iterator i = listChoices.listIterator();
- while (i.hasNext()) {
- Element choiceElm = (Element) i.next();
- ChoiceDTO choice = new ChoiceDTO(choiceElm.getAttribute("idChoice")
- .getName(), Double.parseDouble(choiceElm.getAttribute(
- "value").getValue()), Double.parseDouble(choiceElm
- .getChild("percentage").getValue()), Integer
- .parseInt((choiceElm.getChild("nbVotes").getValue())));
+ for (Element choiceElm : listChoices) {
+ ChoiceDTO choice = new ChoiceDTO(
+ choiceElm.getAttribute("idChoice").getName(),
+ Double.parseDouble(choiceElm.getAttribute("value").getValue()),
+ Double.parseDouble(choiceElm.getChild("percentage").getValue()),
+ Integer.parseInt((choiceElm.getChild("nbVotes").getValue())));
vectorChoices.add(choice);
}
1
0
r3414 - in trunk: pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-services/src/main/resources/i18n pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/i18n pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 11:40:52 +0200 (Sun, 03 Jun 2012)
New Revision: 3414
Url: http://chorem.org/repositories/revision/pollen/3414
Log:
fixes #578: Add a feed entry when a comment is removed + ask user a reason for this deletion
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -91,8 +91,8 @@
// feed notification
PollService pollService = newService(PollService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
- PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
PollFeedService pollFeedService = newService(PollFeedService.class);
pollFeedService.onAddComment(commentCreated, pollVoteUrl);
@@ -102,8 +102,11 @@
}
}
- public void deleteComment(String commentId) throws PollCommentNotFound {
+ public void deleteComment(Poll poll,
+ String commentId,
+ String reason) throws PollCommentNotFound {
+ Preconditions.checkNotNull(poll);
Preconditions.checkNotNull(commentId);
CommentDAO dao = getDAO(Comment.class);
@@ -120,6 +123,14 @@
commitTransaction("Could not delete comment " + comment.getText());
+ // feed notification
+
+ PollService pollService = newService(PollService.class);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll, false);
+
+ PollFeedService pollFeedService = newService(PollFeedService.class);
+ pollFeedService.onDeleteComment(comment, pollVoteUrl, reason);
+
} catch (TopiaException e) {
throw new PollenTechnicalException(e);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -127,6 +127,19 @@
addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
}
+ public void onDeleteComment(Comment comment,
+ PollUrl pollVoteUrl,
+ String reason) {
+
+ String title = _("pollen.feed.deleteCommentTitle",
+ comment.getAuthor());
+
+ String content = _("pollen.feed.deleteCommentContent",
+ comment.getText(), reason);
+
+ addFeedEntry(comment.getPoll(), title, content, pollVoteUrl);
+ }
+
public void onAddVote(Vote vote,
boolean anonymousVote,
String pollResult,
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -34,6 +34,8 @@
pollen.feed.addVoteContent=
pollen.feed.addVoteTitle=
pollen.feed.createPollContent=
+pollen.feed.deleteCommentContent=%s
+pollen.feed.deleteCommentTitle=Delete comment of %s for reason '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Super admin was created with login %1$s
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -34,6 +34,8 @@
pollen.feed.addVoteContent=
pollen.feed.addVoteTitle=
pollen.feed.createPollContent=
+pollen.feed.deleteCommentContent=%s
+pollen.feed.deleteCommentTitle=Suppression du commentaire de %s pour la raison '%s'
pollen.feed.pollDescription=%s
pollen.feed.pollTitle=Pollen \: %s
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -25,8 +25,11 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Comment;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.services.exceptions.PollCommentNotFound;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollCommentService;
+import org.chorem.pollen.services.impl.PollService;
/**
* To confirm a comment delete.
@@ -59,6 +62,14 @@
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(commentId);
+ PollService pollService = newService(PollService.class);
+
+ Poll poll = pollService.getPollByPollId(getPollId());
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+
PollCommentService service = newService(PollCommentService.class);
comment = service.getEntityById(Comment.class, commentId);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-06-03 09:40:52 UTC (rev 3414)
@@ -26,8 +26,11 @@
import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.chorem.pollen.business.persistence.Comment;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.services.exceptions.PollCommentNotFound;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
import org.chorem.pollen.services.impl.PollCommentService;
+import org.chorem.pollen.services.impl.PollService;
/**
* To delete a poll comment.
@@ -42,14 +45,33 @@
/** Id of the comment to delete. */
protected String commentId;
+ /**
+ * Reason for deleting this comment (if any).
+ *
+ * @since 1.4
+ */
+ protected String reason;
+
public void setCommentId(String commentId) {
this.commentId = commentId;
}
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
@InputConfig(methodName = "prepareVotePage")
@Override
public String execute() throws Exception {
+ PollService pollService = newService(PollService.class);
+
+ Poll poll = pollService.getPollByPollId(getPollId());
+
+ if (poll==null) {
+ throw new PollNotFoundException();
+ }
+
Preconditions.checkNotNull(commentId);
PollCommentService service = newService(PollCommentService.class);
@@ -60,10 +82,8 @@
throw new PollCommentNotFound();
}
- setUriId(getUriId());
+ service.deleteComment(poll, commentId, reason);
- service.deleteComment(commentId);
-
return SUCCESS;
}
}
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -25,6 +25,7 @@
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
pollen.action.editVote=Modifier le vote
+pollen.common.deleteReason=Reason for delete
pollen.action.importPersonListToExistingVotingList=Add selected voting list
pollen.action.importPersonListToNewVotingList=Create a new group from the selected voting list
pollen.action.login=Log me In
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-03 09:40:52 UTC (rev 3414)
@@ -24,6 +24,7 @@
pollen.action.editPoll=Modifier le sondage
pollen.action.editPollAccount=Editer le membre sélectionné
pollen.action.editUser=Editer un utilisateur sélectionné
+pollen.common.deleteReason=Raison de suppression
pollen.action.editVote=Modifier le vote
pollen.action.importPersonListToExistingVotingList=Ajouter la liste sélectionnée de votants
pollen.action.importPersonListToNewVotingList=Créer un groupe à partir de la liste sélectionnée
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-06-03 09:15:13 UTC (rev 3413)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-06-03 09:40:52 UTC (rev 3414)
@@ -38,6 +38,9 @@
<s:textarea key='comment.text' readonly="true" rows="3"
label="%{getText('pollen.common.commentText')}"/>
+ <s:textarea key='reason' rows="3" required="true"
+ label="%{getText('pollen.common.deleteReason')}"/>
+
<hr/>
<div align="right">
1
0
r3413 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 11:15:13 +0200 (Sun, 03 Jun 2012)
New Revision: 3413
Url: http://chorem.org/repositories/revision/pollen/3413
Log:
refs #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 null (migration failed)
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 09:06:20 UTC (rev 3412)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 09:15:13 UTC (rev 3413)
@@ -86,14 +86,18 @@
for (String voteId : voteIds) {
// get voteToChoice for this vote
- VoteToChoice voteToChoice =
- new GetVoteToChoiceSQLQuery(voteId).findSingleResult(tx);
+ List<VoteToChoice> voteToChoices =
+ new GetVoteToChoiceSQLQuery(voteId).findMultipleResult(tx);
- if (voteToChoice!=null && voteToChoice.getVoteValue() <= 0) {
+ for (VoteToChoice voteToChoice : voteToChoices) {
- // delete this vote
+ if (voteToChoice != null && voteToChoice.getVoteValue() <= 0) {
- queries.add("DELETE FROM votetochoice where topiaid ='" + voteToChoice.getTopiaId() + "';");
+ // delete this vote
+
+ queries.add("DELETE FROM votetochoice where topiaid ='" +
+ voteToChoice.getTopiaId() + "';");
+ }
}
}
}
1
0
r3412 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration
by tchemit@users.chorem.org 03 Jun '12
by tchemit@users.chorem.org 03 Jun '12
03 Jun '12
Author: tchemit
Date: 2012-06-03 11:06:20 +0200 (Sun, 03 Jun 2012)
New Revision: 3412
Url: http://chorem.org/repositories/revision/pollen/3412
Log:
refs #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 null (migration failed)
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 08:42:32 UTC (rev 3411)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 09:06:20 UTC (rev 3412)
@@ -89,7 +89,7 @@
VoteToChoice voteToChoice =
new GetVoteToChoiceSQLQuery(voteId).findSingleResult(tx);
- if (voteToChoice.getVoteValue() <= 0) {
+ if (voteToChoice!=null && voteToChoice.getVoteValue() <= 0) {
// delete this vote
1
0
Author: tchemit
Date: 2012-06-03 10:42:32 +0200 (Sun, 03 Jun 2012)
New Revision: 3411
Url: http://chorem.org/repositories/revision/pollen/3411
Log:
fixes #574: Mauvais d?\195?\169pouillement Vote Condorcet
fixes #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 "null"
Added:
trunk/pollen-ui-struts2/src/test/
trunk/pollen-ui-struts2/src/test/java/
trunk/pollen-ui-struts2/src/test/java/org/
trunk/pollen-ui-struts2/src/test/java/org/chorem/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
trunk/pollen-ui-struts2/pom.xml
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -1,9 +1,9 @@
/*
* #%L
* Pollen :: Persistence
- *
- * $Id: PollenMigrationCallbackV1_3_1.java 3407 2012-05-28 17:06:39Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org… $
+ * *
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
* %%
@@ -11,12 +11,12 @@
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
@@ -72,7 +72,7 @@
@Override
protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
- PreparedStatement ps = connection.prepareStatement("select topiaid from vote where topiaid in (select topiaid from poll where votecountingtype=2);");
+ PreparedStatement ps = connection.prepareStatement("select topiaid from vote where poll in (select topiaid from poll where votecountingtype=2);");
return ps;
}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/pom.xml
===================================================================
--- trunk/pollen-ui-struts2/pom.xml 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-ui-struts2/pom.xml 2012-06-03 08:42:32 UTC (rev 3411)
@@ -179,6 +179,11 @@
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -34,7 +34,6 @@
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.common.PollType;
-import org.chorem.pollen.common.VoteCountingType;
/**
* Votes to a poll.
@@ -100,6 +99,10 @@
// see http://chorem.org/issues/576
nbVotes++;
totalValues += value;
+ } else {
+
+ // otherwise does not take account of this choice
+ voteToChoice.setVoteValue(null);
}
// for other vote type, value must be > 0
} else if (value != 0) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java 2012-06-01 10:04:08 UTC (rev 3410)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.ui.converters;
+import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.util.StrutsTypeConverter;
import java.util.Map;
@@ -48,7 +49,9 @@
protected Integer parseValue(String value) {
Integer result;
- if ("true".equals(value)) {
+ if (StringUtils.isEmpty(value)) {
+ result = null;
+ } else if ("true".equals(value)) {
result = 1;
} else if ("false".equals(value)) {
Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java (rev 0)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java 2012-06-03 08:42:32 UTC (rev 3411)
@@ -0,0 +1,57 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.converters;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+/**
+ * Tests the {@link BooleanIntegerConverter}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class BooleanIntegerConverterTest {
+
+ @Test
+ public void testConvertFromString() throws Exception {
+
+ BooleanIntegerConverter converter = new BooleanIntegerConverter();
+
+ convertFromString(null, null, converter);
+ convertFromString("", null, converter);
+ convertFromString("0", 0, converter);
+ convertFromString("1", 1, converter);
+ convertFromString("-1", -1, converter);
+ convertFromString("false", 0, converter);
+ convertFromString("true", 1, converter);
+ }
+
+ protected void convertFromString(String valueToConvert,
+ Integer expected,
+ BooleanIntegerConverter converter) {
+ Integer actual = converter.convertFromString(
+ null, new String[]{valueToConvert}, Integer.class);
+ Assert.assertEquals(expected, actual);
+ }
+}
Property changes on: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0