Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
r3015 - trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll
by fdesbois@users.chorem.org 26 May '10
by fdesbois@users.chorem.org 26 May '10
26 May '10
Author: fdesbois
Date: 2010-05-26 12:08:22 +0200 (Wed, 26 May 2010)
New Revision: 3015
Url: http://chorem.org/repositories/revision/pollen/3015
Log:
Repare broken build
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-26 09:17:43 UTC (rev 3014)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-26 10:08:22 UTC (rev 3015)
@@ -586,7 +586,7 @@
// percentage : check total = 100
getPollAccount().setChoiceVote(getEditedVotes());
try {
- serviceVote.saveVote(getPollAccount());
+ serviceVote.saveVote(getPoll(), getPollAccount());
} catch (PollenBusinessException eee) {
// record error
}
1
0
Author: fdesbois
Date: 2010-05-26 11:17:43 +0200 (Wed, 26 May 2010)
New Revision: 3014
Url: http://chorem.org/repositories/revision/pollen/3014
Log:
- Use evo from ToPIA to extend DAO. (remove QueryBuilder, put temporarly methods in PollenUtils, maybe will be put in TopiaDAO)
- Resolve choice image in UI
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantDAOImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountDAOImpl.java
Removed:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -54,7 +54,7 @@
protected String propertyJoin;
/** class of the entity * */
- protected Class<? extends TopiaEntity> entityClass;
+ protected Class<?> entityClass;
/**
* Default constructor. mainAlias, propertyJoin and entityClass are null.
@@ -76,13 +76,13 @@
/**
* Constructor with mainAlias and entityClass.
*
+ * @param entityClass class of the entity corresponding to this
+ * EntityQueryProperty
* @param mainAlias alias of the entity corresponding to this
* EntityQueryProperty
- * @param entityClass class of the entity corresponding to this
- * EntityQueryProperty
*/
- public EntityQueryProperty(String mainAlias,
- Class<? extends TopiaEntity> entityClass) {
+ public EntityQueryProperty(Class<?> entityClass,
+ String mainAlias) {
this(mainAlias);
setEntityClass(entityClass);
}
@@ -112,7 +112,7 @@
* @param entityClass class of the entity corresponding to this
* EntityQueryProperty
*/
- public void setEntityClass(Class<? extends TopiaEntity> entityClass) {
+ public void setEntityClass(Class<?> entityClass) {
this.entityClass = entityClass;
}
@@ -176,7 +176,7 @@
*
* @return the entity class corresponding to this EntityQueryProperty.
*/
- public Class<? extends TopiaEntity> getEntityClass() {
+ public Class<?> getEntityClass() {
if (entityClass == null) {
throw new NullPointerException("entitClass is not set");
}
@@ -192,7 +192,7 @@
* provides it.
*/
public TopiaQuery newQuery() {
- return new TopiaQuery(getEntityClass(), name());
+ return new TopiaQuery((Class<? extends TopiaEntity>)getEntityClass(), name());
}
/**
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -123,7 +123,4 @@
*/
void closeTransaction(TopiaContext transaction);
- PollenQueryBuilder newQueryBuilder(TopiaQuery query);
-
-
} //PollenContext
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -391,13 +391,4 @@
return null;
}
- @Override
- public PollenQueryBuilder newQueryBuilder(TopiaQuery query) {
- PollenQueryBuilder builder = new PollenQueryBuilder();
- if (query != null) {
- builder.setQuery(query);
- }
- return builder;
- }
-
}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -1,79 +0,0 @@
-
-package org.chorem.pollen;
-
-import org.chorem.pollen.bean.Filter;
-import org.chorem.pollen.entity.FavoriteList;
-import org.chorem.pollen.entity.FavoriteParticipant;
-import org.chorem.pollen.entity.Poll;
-import org.chorem.pollen.entity.PollAccount;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.persistence.TopiaDAO;
-
-/**
- * PollenQueryBuilder
- *
- * Created: 28 avr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class PollenQueryBuilder extends TopiaQueryBuilder {
-
- protected PollenQueryBuilder() {
- super();
- }
-
- public EntityQueryProperty getFavoriteListProperty(String alias) {
- return getEntityProperty(FavoriteList.class, alias);
- }
-
- public EntityQueryProperty getFavoriteParticipantProperty(
- String alias) {
- return getEntityProperty(FavoriteParticipant.class, alias);
- }
-
- public EntityQueryProperty getPollAccountProperty(
- String alias) {
- return getEntityProperty(PollAccount.class, alias);
- }
-
- public EntityQueryProperty getPollProperty(String alias) {
- return getEntityProperty(Poll.class, alias);
- }
-
- public TopiaQuery createQueryFindFavoriteParticipantsByFavoriteList(
- Filter filter) {
-
- EntityQueryProperty participantProperty =
- getFavoriteParticipantProperty("P");
-
- EntityQueryProperty listProperty =
- getFavoriteListProperty("L");
-
- listProperty.setPropertyJoin(FavoriteList.FAVORITE_PARTICIPANT);
-
- createQueryFindElementsByCollection(
- participantProperty, listProperty, filter);
-
- return query;
- }
-
- public TopiaQuery createQueryFindVotesByPoll(Filter filter) {
-
- EntityQueryProperty accountProperty = getPollAccountProperty("A");
-
- EntityQueryProperty pollProperty = getPollProperty("P");
- pollProperty.setPropertyJoin(Poll.POLL_ACCOUNT);
-
- createQueryFindElementsByCollection(
- accountProperty, pollProperty, filter);
-
- query.addNotNull(accountProperty.nameProperty(PollAccount.VOTE_DATE));
-
- return query;
- }
-
-}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -1,6 +1,15 @@
package org.chorem.pollen;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.Filter;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
/**
* Created: 21 mai 2010
@@ -10,6 +19,8 @@
*/
public class PollenUtils {
+ private static final Log log = LogFactory.getLog(PollenUtils.class);
+
private static PollenContext context;
public static void setContext(PollenContext context) {
@@ -19,4 +30,114 @@
public static Date getCurrentDate() {
return context.getCurrentDate();
}
+
+ // TEMP METHOD
+ public static EntityQueryProperty getEntityQueryProperty(String alias) {
+ return new EntityQueryProperty(alias);
+ }
+
+ public static EntityQueryProperty getEntityQueryProperty(
+ Class<? extends TopiaEntity> entityClass, String alias) {
+ return new EntityQueryProperty(entityClass, alias);
+ }
+
+ /**
+ * Create a TopiaQuery to find all participants of a list with
+ * {@code filter} constraints (order, limit indexes, listId).
+ *
+ * @param filter used to add constraint in the query
+ * @param element
+ * @param collection
+ * @return the TopiaQuery created
+ * @see #prepareQuery(TopiaQuery, Filter, EntityQueryProperty)
+ */
+ public static TopiaQuery createQueryFindElementsByCollection(
+ EntityQueryProperty element,
+ EntityQueryProperty collection,
+ Filter filter) {
+
+ // Instanciate a new query based on element
+ TopiaQuery query = element.newQuery();
+
+ // Add the collection in the From of the query
+ query.addFrom((Class<? extends TopiaEntity>)collection.getEntityClass(),
+ collection.name());
+
+ // Add the link between the collection and the element
+ query.addInElements(element.name(), collection.namePropertyJoin());
+
+ if (filter != null) {
+ // Add constraints from filter, the collection is given to provide
+ // the name of its ID property.
+ prepareQuery(query, filter, collection);
+ }
+
+ return query;
+ }
+
+ /**
+ * Prepare a query with filter : adding startIndex and endIndex as limit
+ * and orderBy if defined. Need an existing query in builder.
+ *
+ * @param filter Filter to add in the query
+ * @see #prepareQuery(TopiaQuery, Filter, EntityQueryProperty)
+ */
+ public static void prepareQuery(TopiaQuery query, Filter filter) {
+ prepareQuery(query, filter, null);
+ }
+
+ /**
+ * Prepare a query with filter. The {@code reference} is used
+ * to retrieve the name of ID property in case of filter using referenceId.
+ * Need an existing query in builder.
+ *
+ * @param filter Filter to add in the query
+ * @param reference used to filter on referenceId
+ */
+ public static void prepareQuery(TopiaQuery query, Filter filter,
+ EntityQueryProperty reference) {
+
+ Integer startIndex = filter.getStartIndex();
+ Integer endIndex = filter.getEndIndex();
+ String orderBy = filter.getOrderBy();
+ String referenceId = filter.getReferenceId();
+
+ EntityQueryProperty mainProperty =
+ getEntityQueryProperty(query.getMainAlias());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Filter added to the query : " +
+ "startIndex = " + startIndex +
+ " _ endIndex = " + endIndex +
+ " _ orderBy = " + orderBy +
+ " _ referenceId = " + referenceId);
+ }
+
+ // Add limits. Only startIndex do nothing.
+ // startIndex + endIndex provides the limit
+ if (filter.getStartIndex() != null && endIndex != null) {
+ query.setLimit(startIndex, endIndex);
+
+ // endIndex only provides the maxResults wanted
+ } else if (endIndex != null) {
+ query.setMaxResults(endIndex);
+ }
+
+ // Add order to the main entity in the query, splitted by comma
+ if (orderBy != null) {
+ List<String> order = new ArrayList<String>();
+ for (String elmt : orderBy.split(",")) {
+ order.add(mainProperty.nameProperty(elmt.trim()));
+ }
+ query.addOrder(order.toArray(new String[order.size()]));
+
+ // Default order by creation date
+ } else {
+ query.addOrderDesc(mainProperty.namePropertyCreateDate());
+ }
+
+ if (StringUtils.isNotEmpty(referenceId) && reference != null) {
+ query.add(reference.namePropertyId(), referenceId);
+ }
+ }
}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -1,158 +0,0 @@
-
-package org.chorem.pollen;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.bean.Filter;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * TopiaQueryBuilder is used to build a TopiaQuery. <br />
- * Convention rules :
- * <ul>
- * <li>method with prefix {@code prepare} will modify the current query</li>
- * <li>method with prefix {@code create} will instantiate a new query</li>
- * </ul>
- * <br />
- * To use directly {@code prepare} methods, you have to set the query using
- * {@link #setQuery(TopiaQuery)}.
- *
- * Created: 28 avr. 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- */
-public class TopiaQueryBuilder {
-
- private static final Log log = LogFactory.getLog(TopiaQueryBuilder.class);
-
- protected TopiaQuery query;
-
- protected TopiaQueryBuilder() {
- }
-
- public static TopiaQueryBuilder newInstance() {
- return new TopiaQueryBuilder();
- }
-
- public void setQuery(TopiaQuery query) {
- this.query = query;
- }
-
- public TopiaQuery getQuery() {
- return query;
- }
-
- public EntityQueryProperty getEntityProperty(String alias) {
- return new EntityQueryProperty(alias);
- }
-
- public EntityQueryProperty getEntityProperty(
- Class<? extends TopiaEntity> entityClass, String alias) {
- return new EntityQueryProperty(alias, entityClass);
- }
-
- public EntityQueryProperty getMainProperty() {
- return getEntityProperty(query.getMainAlias());
- }
-
- /**
- * Create a TopiaQuery to find all participants of a list with
- * {@code filter} constraints (order, limit indexes, listId).
- *
- * @param filter used to add constraint in the query
- * @param element
- * @param collection
- * @return the TopiaQuery created
- * @see #prepareQuery(Filter, EntityQueryProperty)
- */
- public TopiaQuery createQueryFindElementsByCollection(
- EntityQueryProperty element,
- EntityQueryProperty collection,
- Filter filter) {
-
- // Instanciate a new query based on element
- query = element.newQuery();
-
- // Add the collection in the From of the query
- query.addFrom(collection.getEntityClass(), collection.name());
-
- // Add the link between the collection and the element
- query.addInElements(element.name(), collection.namePropertyJoin());
-
- if (filter != null) {
- // Add constraints from filter, the collection is given to provide
- // the name of its ID property.
- prepareQuery(filter, collection);
- }
-
- return query;
- }
-
- /**
- * Prepare a query with filter : adding startIndex and endIndex as limit
- * and orderBy if defined. Need an existing query in builder.
- *
- * @param filter Filter to add in the query
- * @see #prepareQuery(Filter filter, EntityQueryProperty)
- */
- public void prepareQuery(Filter filter) {
- prepareQuery(filter, null);
- }
-
- /**
- * Prepare a query with filter. The {@code reference} is used
- * to retrieve the name of ID property in case of filter using referenceId.
- * Need an existing query in builder.
- *
- * @param filter Filter to add in the query
- * @param reference used to filter on referenceId
- */
- public void prepareQuery(Filter filter,
- EntityQueryProperty reference) {
-
- Integer startIndex = filter.getStartIndex();
- Integer endIndex = filter.getEndIndex();
- String orderBy = filter.getOrderBy();
- String referenceId = filter.getReferenceId();
-
- if (log.isDebugEnabled()) {
- log.debug("Filter added to the query : " +
- "startIndex = " + startIndex +
- " _ endIndex = " + endIndex +
- " _ orderBy = " + orderBy +
- " _ referenceId = " + referenceId);
- }
-
- // Add limits. Only startIndex do nothing.
- // startIndex + endIndex provides the limit
- if (filter.getStartIndex() != null && endIndex != null) {
- query.setLimit(startIndex, endIndex);
-
- // endIndex only provides the maxResults wanted
- } else if (endIndex != null) {
- query.setMaxResults(endIndex);
- }
-
- // Add order to the main entity in the query, splitted by comma
- if (orderBy != null) {
- List<String> order = new ArrayList<String>();
- for (String elmt : orderBy.split(",")) {
- order.add(getMainProperty().nameProperty(elmt.trim()));
- }
- query.addOrder(order.toArray(new String[order.size()]));
-
- // Default order by creation date
- } else {
- query.addOrderDesc(getMainProperty().namePropertyCreateDate());
- }
-
- if (StringUtils.isNotEmpty(referenceId) && reference != null) {
- query.add(reference.namePropertyId(), referenceId);
- }
- }
-}
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantDAOImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantDAOImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantDAOImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.entity;
+
+import org.chorem.pollen.EntityQueryProperty;
+import org.chorem.pollen.PollenUtils;
+import org.chorem.pollen.bean.Filter;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+
+/**
+ * Created: 26 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class FavoriteParticipantDAOImpl<E extends FavoriteParticipant>
+ extends FavoriteParticipantDAOAbstract<E> {
+
+ @Override
+ public TopiaQuery createQueryFindAllByFavoriteList(Filter filter) {
+
+ EntityQueryProperty participantProperty =
+ PollenUtils.getEntityQueryProperty(FavoriteParticipant.class, "P");
+
+ EntityQueryProperty listProperty =
+ PollenUtils.getEntityQueryProperty(FavoriteList.class, "L");
+
+ listProperty.setPropertyJoin(FavoriteList.FAVORITE_PARTICIPANT);
+
+ TopiaQuery query = PollenUtils.createQueryFindElementsByCollection(
+ participantProperty, listProperty, filter);
+
+ return query;
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountDAOImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountDAOImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountDAOImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -0,0 +1,35 @@
+package org.chorem.pollen.entity;
+
+import org.chorem.pollen.EntityQueryProperty;
+import org.chorem.pollen.PollenUtils;
+import org.chorem.pollen.bean.Filter;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+
+/**
+ * Created: 26 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class PollAccountDAOImpl<E extends PollAccount> extends PollAccountDAOAbstract<E> {
+
+ @Override
+ public TopiaQuery createQueryFindAllByPoll(Filter filter) {
+
+ EntityQueryProperty accountProperty =
+ PollenUtils.getEntityQueryProperty(PollAccount.class, "A");
+
+ EntityQueryProperty pollProperty =
+ PollenUtils.getEntityQueryProperty(Poll.class, "P");
+
+ pollProperty.setPropertyJoin(Poll.POLL_ACCOUNT);
+
+ TopiaQuery query = PollenUtils.createQueryFindElementsByCollection(
+ accountProperty, pollProperty, filter);
+
+ query.addNotNull(accountProperty.nameProperty(PollAccount.VOTE_DATE));
+
+ return query;
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -8,7 +8,6 @@
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
-import org.chorem.pollen.PollenQueryBuilder;
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteListDAO;
@@ -244,14 +243,11 @@
protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants(
TopiaContext transaction, Filter filter) throws TopiaException {
- PollenQueryBuilder builder = context.newQueryBuilder(null);
-
- TopiaQuery query =
- builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
-
FavoriteParticipantDAO dao =
PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+ TopiaQuery query = dao.createQueryFindAllByFavoriteList(filter);
+
if (log.isDebugEnabled()) {
log.debug("Query : " + query);
}
@@ -268,12 +264,12 @@
protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
Filter filter) throws TopiaException {
- PollenQueryBuilder builder = context.newQueryBuilder(null);
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- TopiaQuery query =
- builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
+ TopiaQuery query = dao.createQueryFindAllByFavoriteList(filter);
- int result = query.executeCount(transaction);
+ int result = dao.countByQuery(query);
return result;
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -7,8 +7,6 @@
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
-import org.chorem.pollen.PollenQueryBuilder;
-import org.chorem.pollen.TopiaQueryBuilder;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -12,6 +12,7 @@
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
+import org.chorem.pollen.PollenUtils;
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteListDAO;
@@ -19,8 +20,6 @@
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.FavoriteParticipantDAO;
import org.chorem.pollen.entity.FavoriteParticipantImpl;
-import org.chorem.pollen.PollenQueryBuilder;
-import org.chorem.pollen.TopiaQueryBuilder;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
@@ -269,7 +268,7 @@
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
TopiaQuery query = dao.createQuery();
- context.newQueryBuilder(query).prepareQuery(filter);
+ PollenUtils.prepareQuery(query, filter);
Map<String, UserAccount> results = dao.findAllMappedByQuery(
query, UserAccount.LOGIN, String.class);
@@ -283,7 +282,7 @@
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
TopiaQuery query = dao.createQuery();
- context.newQueryBuilder(query).prepareQuery(filter);
+ PollenUtils.prepareQuery(query, filter);
int result = query.executeCount();
return result;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -1,17 +1,20 @@
package org.chorem.pollen.service;
import org.chorem.pollen.EntityQueryProperty;
+import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
-import org.chorem.pollen.PollenQueryBuilder;
import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.entity.PollAccount;
import org.chorem.pollen.entity.PollAccountDAO;
import org.chorem.pollen.entity.PollAccountImpl;
import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.Vote;
import org.chorem.pollen.entity.VoteDAO;
+import org.chorem.pollen.entity.VoteImpl;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -49,7 +52,8 @@
}
@Override
- protected boolean executeCanVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception {
+ protected boolean executeCanVote(TopiaContext transaction, Poll poll,
+ PollAccount participant) throws Exception {
return false;
}
@@ -69,15 +73,14 @@
Filter filter)
throws Exception {
- PollenQueryBuilder builder = context.newQueryBuilder(null);
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
- TopiaQuery query = builder.createQueryFindVotesByPoll(filter);
+ TopiaQuery query = dao.createQueryFindAllByPoll(filter);
- PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
-
query.addLoad(PollAccount.CHOICE_VOTE);
List<PollAccount> results = dao.findAllByQuery(query);
+
return results;
}
@@ -85,15 +88,44 @@
protected int executeGetNbVotes(TopiaContext transaction, Filter filter)
throws TopiaException {
- PollenQueryBuilder builder = context.newQueryBuilder(null);
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
- TopiaQuery query = builder.createQueryFindVotesByPoll(filter);
+ TopiaQuery query = dao.createQueryFindAllByPoll(filter);
- int result = query.executeCount(transaction);
+ int result = dao.countByQuery(query);
return result;
}
@Override
protected void executeDeleteVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception {
}
+
+ @Override
+ protected Vote executeGetNewVote(Choice choice) {
+ Vote result = new VoteImpl();
+ result.setChoice(choice);
+ return result;
+ }
+
+ @Override
+ protected void executeSaveVote(TopiaContext transaction, Poll poll,
+ PollAccount participant)
+ throws PollenBusinessException {
+
+ // 1- executeCanVote(transaction, poll, participant);
+ // 2- generate uid if needed
+ // 3- update or create participant
+ // 4- add participant in the poll if needed
+ // 5- save only votes with voteValue != 0 : update or votes
+ // 6- maybe execute calcul for continuousResults poll
+
+ // NEED test :
+ // need existing poll with choices
+ // getNewPollAccount
+ // set some votes for poll choices
+ // saveVote
+
+
+
+ }
}
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-26 09:17:43 UTC (rev 3014)
@@ -79,11 +79,13 @@
pollen.error.serviceVote.deleteVote=
pollen.error.serviceVote.getNbVotes=
pollen.error.serviceVote.getNewPollAccount=
+pollen.error.serviceVote.getNewVote=
pollen.error.serviceVote.getPollAccount=
pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotes=
pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
+pollen.error.serviceVote.saveVote=
pollen.exception.favorite_list_name_exist=
pollen.exception.favorite_participant_exist=
pollen.exception.favorite_participant_exist_without_email=
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-26 09:17:43 UTC (rev 3014)
@@ -78,11 +78,13 @@
pollen.error.serviceVote.deleteVote=
pollen.error.serviceVote.getNbVotes=
pollen.error.serviceVote.getNewPollAccount=
+pollen.error.serviceVote.getNewVote=
pollen.error.serviceVote.getPollAccount=
pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotes=
pollen.error.serviceVote.getVotesByPoll=
pollen.error.serviceVote.hasAlreadyVoted=
+pollen.error.serviceVote.saveVote=
pollen.exception.favorite_list_name_exist=La liste %1$s existe d\u00E9j\u00E0 pour l'utilisateur %2$s
pollen.exception.load_configuration=La configuration n'a pas \u00E9t\u00E9 charg\u00E9e correctement \! Veuillez v\u00E9rifier le d\u00E9marrage de l'application.
pollen.exception.participant_doubloons=Les doublons de la liste %1$s ont \u00E9t\u00E9 ignor\u00E9s \: %2$s
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -34,24 +34,25 @@
filter.setEndIndex(40);
filter.setOrderBy(UserAccount.LOGIN);
- TopiaQueryBuilder builder = new TopiaQueryBuilder();
- builder.setQuery(new TopiaQuery(UserAccount.class));
- builder.prepareQuery(filter);
+// TopiaQueryBuilder builder = new TopiaQueryBuilder();
+// builder.setQuery(new TopiaQuery(UserAccount.class));
+ TopiaQuery query = new TopiaQuery(UserAccount.class);
+ PollenUtils.prepareQuery(query, filter);
- log.debug("Query : " + builder.getQuery());
+ log.debug("Query : " + query);
- Assert.assertEquals(builder.getQuery().fullQuery(),
+ Assert.assertEquals(query.fullQuery(),
"FROM " + UserAccount.class.getName() +
" ORDER BY " + UserAccount.LOGIN);
filter.setOrderBy(null);
- builder.setQuery(new TopiaQuery(UserAccount.class));
- builder.prepareQuery(filter);
+ query = new TopiaQuery(UserAccount.class);
+ PollenUtils.prepareQuery(query, filter);
- log.debug("Query : " + builder.getQuery());
+ log.debug("Query : " + query);
- Assert.assertEquals(builder.getQuery().fullQuery(),
+ Assert.assertEquals(query.fullQuery(),
"FROM " + UserAccount.class.getName() +
" ORDER BY " + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
@@ -60,7 +61,7 @@
@Test
public void testCreateQueryFindElementsByCollection() throws IOException {
- TopiaQueryBuilder builder = new TopiaQueryBuilder();
+ //TopiaQueryBuilder builder = new TopiaQueryBuilder();
Filter filter = new Filter();
filter.setStartIndex(1);
@@ -68,14 +69,14 @@
filter.setOrderBy(FavoriteParticipant.NAME);
EntityQueryProperty participantPropertyProvider =
- builder.getEntityProperty(FavoriteParticipant.class, "P");
+ PollenUtils.getEntityQueryProperty(FavoriteParticipant.class, "P");
EntityQueryProperty listPropertyProvider =
- builder.getEntityProperty(FavoriteList.class, "L");
+ PollenUtils.getEntityQueryProperty(FavoriteList.class, "L");
listPropertyProvider.setPropertyJoin(FavoriteList.FAVORITE_PARTICIPANT);
log.info("test1 : orderBy FavoriteParticipant name");
- TopiaQuery result = builder.createQueryFindElementsByCollection(
+ TopiaQuery result = PollenUtils.createQueryFindElementsByCollection(
participantPropertyProvider, listPropertyProvider, filter);
log.debug("Query : " + result);
@@ -89,7 +90,7 @@
log.info("test2 : orderBy not set (default to topiaCreateDate desc)");
filter.setOrderBy(null);
- result = builder.createQueryFindElementsByCollection(
+ result = PollenUtils.createQueryFindElementsByCollection(
participantPropertyProvider, listPropertyProvider, filter);
log.debug("Query : " + result);
@@ -104,7 +105,7 @@
String orderBy = FavoriteParticipant.NAME + ", " + FavoriteParticipant.EMAIL + " desc";
filter.setOrderBy(orderBy);
- result = builder.createQueryFindElementsByCollection(
+ result = PollenUtils.createQueryFindElementsByCollection(
participantPropertyProvider, listPropertyProvider, filter);
log.debug("Query : " + result);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -1,5 +1,6 @@
package org.chorem.pollen.ui.components;
+import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.ClientElement;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link;
@@ -44,8 +45,11 @@
Link thumbLink = resources.createEventLink("showImage",
source.getImageFileName(), source.getImageDir(), true);
+ String alt = StringUtils.isNotEmpty(source.getDescription()) ?
+ source.getDescription() : source.getImageFileName();
+
writeLink(writer, link, "rel", "lightbox[pollChoiceImages]");
- writer.element("img", "src", thumbLink, "alt", source.getDescription());
+ writer.element("img", "src", thumbLink, "alt", alt);
writer.end();
writer.end();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -52,6 +52,8 @@
protected String text;
+ protected Double voteValue;
+
public ChoiceField() {
}
@@ -272,4 +274,12 @@
public boolean isHidden() {
return choice.isHidden();
}
+
+ public void setVoteValue(Double voteValue) {
+ this.voteValue = voteValue;
+ }
+
+ public Double getVoteValue() {
+ return voteValue;
+ }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-26 09:17:43 UTC (rev 3014)
@@ -22,6 +22,8 @@
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
@@ -45,6 +47,7 @@
import org.chorem.pollen.entity.PollAccount;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.Vote;
+import org.chorem.pollen.entity.VoteImpl;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.service.ServiceVote;
@@ -496,6 +499,10 @@
manager.getProperty(PollenProperty.NB_VOTES_PER_PAGE));
}
+ public boolean isPagerNeeded() throws PollenBusinessException {
+ return getPagerRange() < getNbVotes();
+ }
+
public int getNbVotes() throws PollenBusinessException {
if (nbVotes == null) {
Filter filter = new Filter();
@@ -555,6 +562,36 @@
return vote;
}
+ private List<Vote> editedVotes;
+
+ @Property
+ private Vote editedVote;
+
+ public List<Vote> getEditedVotes() {
+ if (editedVotes == null) {
+ editedVotes = new ArrayList<Vote>();
+
+ for (ChoiceField choice : choices) {
+ Vote vote = getPollAccount().getChoiceVote(choice.getChoice());
+ if (vote == null) {
+ vote = serviceVote.getNewVote(choice.getChoice());
+ }
+ editedVotes.add(vote);
+ }
+ }
+ return editedVotes;
+ }
+
+ void onValidateFormFromVoteForm() {
+ // percentage : check total = 100
+ getPollAccount().setChoiceVote(getEditedVotes());
+ try {
+ serviceVote.saveVote(getPollAccount());
+ } catch (PollenBusinessException eee) {
+ // record error
+ }
+ }
+
// /**
// * Retourne vrai si le champs pollAccount doit apparaître.
// *
@@ -572,15 +609,8 @@
// return !getPoll().getAnonymous() || isRestrictedPoll() || isGroupPoll();
// }
- public void setChoiceValue(Integer value) {
-// getCurrentVote().setChoiceValue(choice.getId(), value);
- }
-
-// public Integer getChoiceValue() {
-// return getCurrentVote().getChoiceValue(choice.getId());
-// }
-
public boolean getCanVote() {
+ // FIXME-fdesbois-2010-05-25 : copy check treatment directly in service
if (poll.isFinished()) {
return false;
}
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-25 15:13:12 UTC (rev 3013)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-26 09:17:43 UTC (rev 3014)
@@ -44,12 +44,12 @@
<!-- Sondage -->
<!--<t:zone t:id="pollZone" t:show="show" t:update="show">-->
- <t:if t:test="poll.anonymous">
- <p>${format:vote-size=nbVotes}</p>
+ <t:if t:test="pagerNeeded">
+ <t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="nbVotes"
+ t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>
<!--<t:feedback t:id="voteFeedback"/>-->
<p:else>
- <t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="nbVotes"
- t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>
+ <p>${format:vote-size=nbVotes}</p>
</p:else>
</t:if>
<t:form t:id="voteForm">
@@ -98,38 +98,38 @@
</th>
</tr>
</thead>
- <!--<t:if test="canVote">-->
- <!--<tfoot>-->
- <!--<tr>-->
+ <t:if test="canVote">
+ <tfoot>
+ <tr>
<!--<t:if test="accountFieldDisplayed">-->
- <!--<th id="voterName">-->
- <!--<input t:type="textfield" t:id="pollAccountName" value="pollAccount.votingId" t:validate="required"/>-->
- <!--</th>-->
+ <th id="voterName">
+ <input t:type="textfield" t:id="pollAccountName" value="pollAccount.name" t:validate="required"/>
+ </th>
<!--<p:else>-->
<!--<th></th>-->
<!--</p:else>-->
<!--</t:if>-->
- <!--<t:loop t:source="choices" t:value="choice" volatile="true">-->
- <!--<t:unless test="choice.hidden">-->
- <!--<th>-->
- <!--<t:if test="poll.voteCounting.normal">-->
- <!--<input t:type="checkbox" value="addChoice" />-->
- <!--</t:if>-->
- <!--<t:if test="poll.voteCounting.percentage">-->
- <!--<t:textField t:value="currentVote.getChoiceValues(choice.id)" size="3" t:validate="required, min=0, max=100"/>%-->
- <!--</t:if>-->
- <!--<t:if test="poll.voteCounting.condorcet">-->
- <!--<t:textField t:id="condorcetInput" t:value="choiceOfVote.value" size="3" t:nulls="zero" t:validate="min=0, max=99"/>-->
- <!--</t:if>-->
- <!--<t:if test="poll.voteCounting.number">-->
- <!--<t:textField t:value="addNumberVote" size="3" />-->
- <!--</t:if>-->
- <!--</th>-->
- <!--</t:unless>-->
- <!--</t:loop>-->
- <!--</tr>-->
- <!--</tfoot>-->
- <!--</t:if>-->
+ <t:loop t:source="editedVotes" t:value="editedVote" volatile="true">
+ <t:unless test="editedChoice.hidden">
+ <th>
+ <t:if test="poll.voteCountingType.normal">
+ <input t:type="checkbox" value="editedVote.voteValue" />
+ </t:if>
+ <t:if test="poll.voteCountingType.percentage">
+ <input t:type="textfield" value="editedVote.voteValue" size="3" t:validate="required, min=0, max=100"/>%
+ </t:if>
+ <t:if test="poll.voteCountingType.condorcet">
+ <input t:type="textfield" value="editedVote.voteValue" size="3" t:id="condorcetInput" t:nulls="zero" t:validate="min=0, max=99"/>
+ </t:if>
+ <t:if test="poll.voteCountingType.number">
+ <input t:type="textfield" value="editedVote.voteValue" size="3" />
+ </t:if>
+ </th>
+ </t:unless>
+ </t:loop>
+ </tr>
+ </tfoot>
+ </t:if>
<tbody>
<t:unless t:test="poll.anonymous">
<t:loop t:source="participants" t:value="participant" t:rowIndex="participantIndex" volatile="true">
1
0
25 May '10
Author: fdesbois
Date: 2010-05-25 17:13:12 +0200 (Tue, 25 May 2010)
New Revision: 3013
Url: http://chorem.org/repositories/revision/pollen/3013
Log:
Decompose choice part of the pollForm in components (problem with upload can't be used in zone)
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceDateForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImageForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceTextForm.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceDateForm.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceImageForm.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceTextForm.tml
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -9,7 +9,9 @@
import org.chorem.pollen.PollenException;
import org.chorem.pollen.PollenQueryBuilder;
import org.chorem.pollen.TopiaQueryBuilder;
+import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.ChoiceDAO;
import org.chorem.pollen.entity.Comment;
@@ -68,6 +70,9 @@
@Override
protected Poll executeGetNewPoll(UserAccount user) {
Poll poll = new PollImpl();
+ poll.setChoiceType(ChoiceType.TEXT);
+ poll.setVoteCountingType(VoteCountingType.NORMAL);
+ poll.setPollType(PollType.FREE);
// Initialize creator as an admin for the poll
PollAccount creator = new PollAccountImpl();
creator.setAdmin(true);
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceDateForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceDateForm.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceDateForm.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -0,0 +1,39 @@
+package org.chorem.pollen.ui.components;
+
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.ui.data.ChoiceField;
+import org.chorem.pollen.ui.models.PollFormModel;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+/**
+ * Created: 25 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ChoiceDateForm {
+
+ @Inject
+ private Messages messages;
+
+ @Parameter(required = true)
+ private PollFormModel model;
+
+ @Property
+ private ChoiceField choice;
+
+ public List<ChoiceField> getChoices() {
+ return model.getChoices();
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat(messages.get("date-pattern"));
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceDateForm.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -47,6 +47,7 @@
writeLink(writer, link, "rel", "lightbox[pollChoiceImages]");
writer.element("img", "src", thumbLink, "alt", source.getDescription());
writer.end();
+ writer.end();
}
/**
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImageForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImageForm.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImageForm.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -0,0 +1,28 @@
+package org.chorem.pollen.ui.components;
+
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Property;
+import org.chorem.pollen.ui.data.ChoiceField;
+import org.chorem.pollen.ui.models.PollFormModel;
+
+import java.util.List;
+
+/**
+ * Created: 25 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ChoiceImageForm {
+
+ @Parameter(required = true)
+ private PollFormModel model;
+
+ @Property
+ private ChoiceField choice;
+
+ public List<ChoiceField> getChoices() {
+ return model.getChoices();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImageForm.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceTextForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceTextForm.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceTextForm.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -0,0 +1,28 @@
+package org.chorem.pollen.ui.components;
+
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Property;
+import org.chorem.pollen.ui.data.ChoiceField;
+import org.chorem.pollen.ui.models.PollFormModel;
+
+import java.util.List;
+
+/**
+ * Created: 25 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ChoiceTextForm {
+
+ @Parameter(required = true)
+ private PollFormModel model;
+
+ @Property
+ private ChoiceField choice;
+
+ public List<ChoiceField> getChoices() {
+ return model.getChoices();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceTextForm.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -223,7 +223,14 @@
name = String.valueOf(getDate().getTime());
break;
case IMAGE:
- name = serviceImage.saveImage(getImage(), getImageDir());
+ if (image == null) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Saving image... " + getImageFileName() +
+ " in directory " + imageDir);
+ }
+ name = serviceImage.saveImage(image, imageDir);
break;
case TEXT:
name = getText();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -5,6 +5,7 @@
import org.apache.tapestry5.ioc.Messages;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenException;
+import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.ParticipantList;
@@ -141,9 +142,8 @@
if (choices == null) {
choices = new ArrayList<ChoiceField>();
if (createMode) {
- // Initialized to choice TEXT type
for (int i = 0; i < 4; i++) {
- choices.add(ChoiceField.getChoiceText());
+ choices.add(new ChoiceField(poll));
}
} else {
for (Choice current : poll.getChoice()) {
@@ -154,6 +154,12 @@
return choices;
}
+ public void setChoiceType(ChoiceType type) {
+ poll.setChoiceType(type);
+ // Reset choices
+ choices = null;
+ }
+
/**
* Change the poll type to {@code type}. The lists managment will depends on
* poll type. For a {@link PollType#RESTRICTED} poll, a new list will be
@@ -322,9 +328,15 @@
poll.clearChoice();
for (ChoiceField choiceField : getChoices()) {
choiceField.saveName(serviceImage);
+ if (logger.isDebugEnabled()) {
+ logger.debug("ChoiceField : " + choiceField.getName());
+ }
Choice choice = choiceField.getChoice();
if (StringUtils.isNotEmpty(choice.getName())) {
- poll.addChoice(choice);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Add choice to poll : " + choice.getName());
+ }
+ poll.addChoice(choice);
}
}
poll = servicePoll.createPoll(poll, getLists());
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-25 15:13:12 UTC (rev 3013)
@@ -1,5 +1,6 @@
package org.chorem.pollen.ui.pages.poll;
+import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
@@ -520,52 +521,52 @@
@Inject
private ServiceImage serviceImage;
- @InjectComponent
- private Zone choicesZone;
-
+// @InjectComponent
+// private Zone choicesZone;
+//
@Inject
- private Block choiceText;
+ private Block choiceTextBlock;
@Inject
- private Block choiceDate;
+ private Block choiceDateBlock;
@Inject
- private Block choiceImage;
+ private Block choiceImageBlock;
+//
+// @Property
+// private ChoiceField choice;
+//
+// @Property
+// private boolean refreshChoicesZone;
- @Property
- private ChoiceField choice;
-
- @Property
- private boolean refreshChoicesZone;
-
/**
* Get choices from poll if it exists or initialized 4 choices with the
* default type : TEXT.
*
* @return a list of ChoiceDTO
*/
- public List<ChoiceField> getChoices() throws PollenBusinessException {
- return getModel().getChoices();
- }
-
+// public List<ChoiceField> getChoices() throws PollenBusinessException {
+// return getModel().getChoices();
+// }
+//
public Block getChoiceTypeBlock() {
switch (getPoll().getChoiceType()) {
case DATE:
- return choiceDate;
+ return choiceDateBlock;
case IMAGE:
- return choiceImage;
+ return choiceImageBlock;
default:
- return choiceText;
+ return choiceTextBlock;
}
}
- @Log
- Object onChangeFromChoiceType(String value) {
- ChoiceType type = ChoiceType.valueOf(value);
- getPoll().setChoiceType(type);
- refreshChoicesZone = true;
- return choicesZone.getBody();
- }
+// @Log
+// Object onChangeFromChoiceType(String value) {
+// ChoiceType type = ChoiceType.valueOf(value);
+// getModel().setChoiceType(type);
+// refreshChoicesZone = true;
+// return choicesZone.getBody();
+// }
/** ********************** NAVIGATION/SUBMISSION ************************ */
@@ -601,21 +602,53 @@
@Log
void onSelected() {
refreshListsZone = false;
- refreshChoicesZone = false;
+// refreshChoicesZone = false;
}
+// /**
+// * ON_SELECTED:: Callback method for action on choiceStep submit buttons.
+// * Will change the view and display the choice formFragment of the pollForm.
+// * Note : maybe validations will be needed in this case (use edited flag).
+// */
+// @Log
+// void onSelectedFromChoiceStep(String choiceType) {
+// ChoiceType type = ChoiceType.valueOf(choiceType);
+// getModel().setChoiceType(type);
+// step = PollStep.CHOICES;
+// edited = true;
+// }
+
/**
- * ON_SELECTED:: Callback method for action on choiceStep submit button. Will
- * change the view and display the choice formFragment of the pollForm.
- * Note : maybe validations will be needed in this case (use edited flag).
+ * ON_SELECTED:: Callback method for action on choiceText submit button.
*/
@Log
- void onSelectedFromChoiceStep() {
+ void onSelectedFromChoiceText() {
+ getModel().setChoiceType(ChoiceType.TEXT);
step = PollStep.CHOICES;
edited = true;
}
/**
+ * ON_SELECTED:: Callback method for action on choiceDate submit button.
+ */
+ @Log
+ void onSelectedFromChoiceDate() {
+ getModel().setChoiceType(ChoiceType.DATE);
+ step = PollStep.CHOICES;
+ edited = true;
+ }
+
+ /**
+ * ON_SELECTED:: Callback method for action on choiceImage submit button.
+ */
+ @Log
+ void onSelectedFromChoiceImage() {
+ getModel().setChoiceType(ChoiceType.IMAGE);
+ step = PollStep.CHOICES;
+ edited = true;
+ }
+
+ /**
* ON_SELECTED:: Callback method for action on mainStep submit button. Will
* change the view and display the main formFragment of the pollForm.
* This is a previous action after being on choices.
@@ -632,13 +665,31 @@
public boolean isMainStep() {
return step.equals(PollStep.MAIN);
- }
+ }
+// @Log
+// Object onUploadException(FileUploadException ex) {
+// addError(ex.getMessage());
+// return this;
+// }
+
@Log
void onValidateForm() {
if (!edited) {
// Validate data
ErrorReport report = getModel().validate(messages);
+
+
+ if (logger.isDebugEnabled()) {
+ for (ChoiceField choiceField : getModel().getChoices()) {
+ logger.debug("Choice type : " + choiceField.getChoiceType());
+ logger.debug("Choice image : " + choiceField.getImage());
+ logger.debug("Choice text : " + choiceField.getText());
+ logger.debug("Choice date : " + choiceField.getDate());
+ }
+ }
+
+
// Record errors if report is not empty
if (report.hasErrors()) {
manager.recordFormErrors(componentSource, report, mainForm);
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-25 15:13:12 UTC (rev 3013)
@@ -93,7 +93,15 @@
groupName-label=Nom du groupe
participantEmail-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
participantEmail-regexp-message=Adresse email invalide.
+date-pattern=dd/MM/yyyy HH:mm
+choiceImageField-label=Image
+choiceImageField-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
+choiceImageField-regexp-message=L'image doit-\u00eatre au format JPG, GIF ou PNG.
+choiceDateField-label=Date et heure
+choiceDateField-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+choiceDateField-regexp-message=La date doit-\u00eatre au format 31/12/2000 23:59.
+
# FORM:: user
firstName-label=Pr\u00e9nom
lastName-label=Nom
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceDateForm.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceDateForm.tml (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceDateForm.tml 2010-05-25 15:13:12 UTC (rev 3013)
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <div id="p-pollForm-choices">
+ <fieldset>
+ <legend>
+ CHOICE_DATE
+ </legend>
+ <div t:type="loop" t:source="choices" t:value="choice"
+ t:volatile="true" class="clearfix">
+ <div class="fleft choiceName">
+ <label t:type="label" t:for="choiceDateField" />:
+ <input t:type="ck/dateTimeField"
+ t:id="choiceDateField"
+ value="choice.date" t:validate="regexp"
+ t:datePattern="message:date-pattern"
+ t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ <label t:type="label" t:for="choiceDescription" />:
+ </div>
+ <div class="fleft">
+ <textarea t:type="textarea" cols="34" rows="1"
+ t:id="choiceDescription"
+ t:value="choice.description" />
+ </div>
+ </div>
+ </fieldset>
+ </div>
+</body>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceDateForm.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceImageForm.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceImageForm.tml (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceImageForm.tml 2010-05-25 15:13:12 UTC (rev 3013)
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <div id="p-pollForm-choices">
+ <fieldset>
+ <legend>
+ CHOICE_IMAGE
+ </legend>
+ <div t:type="loop" t:source="choices" t:value="choice"
+ t:volatile="true" class="clearfix">
+ <div class="fleft choiceName">
+ <label t:type="label"
+ t:for="choiceImageField" />:
+ <input type="file" class="nameField"
+ t:type="upload" t:id="choiceImageField"
+ value="choice.image" />
+ <label t:type="label" t:for="choiceDescription" />:
+ </div>
+ <div class="fleft">
+ <textarea t:type="textarea" cols="34" rows="1"
+ t:id="choiceDescription"
+ t:value="choice.description" />
+ </div>
+ </div>
+ </fieldset>
+ </div>
+</body>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceImageForm.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceTextForm.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceTextForm.tml (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceTextForm.tml 2010-05-25 15:13:12 UTC (rev 3013)
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <div id="p-pollForm-choices">
+ <fieldset>
+ <legend>
+ CHOICE_TEXT
+ </legend>
+ <div t:type="loop" t:source="choices" t:value="choice"
+ t:volatile="true" class="clearfix">
+ <div class="fleft choiceName">
+ <label t:type="label" t:for="choiceTextField" />:
+ <input type="text" class="nameField"
+ t:type="textfield" t:id="choiceTextField"
+ value="choice.text" />
+ <label t:type="label" t:for="choiceDescription" />:
+ </div>
+ <div class="fleft">
+ <textarea t:type="textarea" cols="34" rows="1"
+ t:id="choiceDescription"
+ t:value="choice.description" />
+ </div>
+ </div>
+ </fieldset>
+ </div>
+</body>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/ChoiceTextForm.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-25 12:40:47 UTC (rev 3012)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-25 15:13:12 UTC (rev 3013)
@@ -367,74 +367,36 @@
</t:if>
</div>
</fieldset>
- <p class="center">
- <input t:type="submit" t:id="choiceStep" value="CHOICE" />
- </p>
</div>
- </t:formFragment>
- <t:formFragment t:id="choiceFormFragment" t:visible="choiceStep">
-
- <!-- CHOICES -->
- <div id="p-pollForm-choices">
- <fieldset>
- <legend>
- <label t:type="label" t:for="choiceType" />:
- <select t:type="select" t:id="choiceType"
- t:value="poll.choiceType" t:validate="required"
- t:mixins="nuiton/zoneUpdater" t:event="change"
- t:zone="p-pollForm-choices-zone" />
- </legend>
- <t:zone t:id="choicesZone" id="p-pollForm-choices-zone">
- <t:subForm t:visible="refreshChoicesZone">
- <div t:type="loop" t:source="choices" t:value="choice"
- t:volatile="true" class="clearfix">
- <div class="fleft choiceName">
- <t:delegate t:to="choiceTypeBlock" />
- <t:block t:id="choiceText">
- <label t:type="label" t:for="choiceTextField" />:
- <input type="text" class="nameField"
- t:type="textfield" t:id="choiceTextField"
- value="choice.text" />
- </t:block>
- <t:block t:id="choiceDate">
- <label t:type="label" t:for="choiceDateField" />:
- <input t:type="ck/dateTimeField"
- t:id="choiceDateField"
- value="choice.date" t:validate="regexp"
- t:datePattern="message:date-pattern"
- t:timePicker="true"
- t:timePickerAdjacent="true" />
- </t:block>
- <t:block t:id="choiceImage">
- <label t:type="label"
- t:for="choiceImageField" />:
- <input type="file" class="nameField"
- t:type="upload" t:id="choiceImageField"
- value="choice.image"
- t:validate="regexp" />
- </t:block>
- <t:block t:id="choiceDisplay">
- ${choice.name}
- </t:block>
-
- <t:label t:for="choiceDescription" />
- :
- </div>
- <div class="fleft">
- <t:textarea cols="34" rows="1"
- t:id="choiceDescription"
- t:value="choice.description" />
- </div>
- </div>
- </t:subForm>
- </t:zone>
- </fieldset>
- </div>
<p class="center">
- <input t:type="submit" t:id="mainStep" value="PREVIOUS" />
- <input t:type="submit" t:id="save" value="SAVE" />
+ <input t:type="submit" t:id="choiceText" value="TEXT" />
+ <input t:type="submit" t:id="choiceDate" value="DATE" />
+ <input t:type="submit" t:id="choiceImage" value="IMAGE" />
</p>
</t:formFragment>
</form>
+ <t:if t:test="choiceStep">
+ <!--<t:zone id="p-pollForm-choiceZone">-->
+
+ <!--</t:zone>-->
+ <form t:type="form" t:id="choiceForm" action="tapestry">
+ <t:errors />
+ <!-- CHOICES - Formulaire différent car t:upload ne fonctionne pas en ajax -->
+ <t:delegate t:to="choiceTypeBlock" />
+ <t:block t:id="choiceTextBlock">
+ <t:choiceTextForm t:model="model" />
+ </t:block>
+ <t:block t:id="choiceDateBlock">
+ <t:choiceDateForm t:model="model" />
+ </t:block>
+ <t:block t:id="choiceImageBlock">
+ <t:choiceImageForm t:model="model" />
+ </t:block>
+ <p class="center">
+ <input t:type="submit" t:id="mainStep" value="PREVIOUS" />
+ <input t:type="submit" t:id="save" value="SAVE" />
+ </p>
+ </form>
+ </t:if>
</t:zone>
</html>
1
0
Author: fdesbois
Date: 2010-05-25 14:40:47 +0200 (Tue, 25 May 2010)
New Revision: 3012
Url: http://chorem.org/repositories/revision/pollen/3012
Log:
- Create component ChoiceImage (not tested)
- Vote page is ok to render from now
- Add test of name nullity on addChoice for saving new poll
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/UserAccountDataSource.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -4,6 +4,7 @@
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.entity.PollAccount;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaDAO;
@@ -34,11 +35,15 @@
return getEntityProperty(FavoriteParticipant.class, alias);
}
- public EntityQueryProperty getPollCreatorProperty(
+ public EntityQueryProperty getPollAccountProperty(
String alias) {
return getEntityProperty(PollAccount.class, alias);
}
+ public EntityQueryProperty getPollProperty(String alias) {
+ return getEntityProperty(Poll.class, alias);
+ }
+
public TopiaQuery createQueryFindFavoriteParticipantsByFavoriteList(
Filter filter) {
@@ -56,4 +61,19 @@
return query;
}
+ public TopiaQuery createQueryFindVotesByPoll(Filter filter) {
+
+ EntityQueryProperty accountProperty = getPollAccountProperty("A");
+
+ EntityQueryProperty pollProperty = getPollProperty("P");
+ pollProperty.setPropertyJoin(Poll.POLL_ACCOUNT);
+
+ createQueryFindElementsByCollection(
+ accountProperty, pollProperty, filter);
+
+ query.addNotNull(accountProperty.nameProperty(PollAccount.VOTE_DATE));
+
+ return query;
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -1,6 +1,7 @@
package org.chorem.pollen.entity;
+import org.apache.commons.lang.StringUtils;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.votecounting.business.NumberMethod;
@@ -30,13 +31,14 @@
}
@Override
- public boolean getHidden() {
- return getName().startsWith(NumberMethod.HIDDEN_PREFIX);
+ public boolean isHidden() {
+ return StringUtils.isNotEmpty(name) &&
+ name.startsWith(NumberMethod.HIDDEN_PREFIX);
}
@Override
public void setHidden(boolean hidden) {
- boolean previous = getHidden();
+ boolean previous = isHidden();
if (hidden && !previous) {
setName(NumberMethod.HIDDEN_PREFIX + name);
} else if (!hidden && previous) {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -1,13 +1,20 @@
package org.chorem.pollen.service;
+import org.chorem.pollen.EntityQueryProperty;
import org.chorem.pollen.PollenContext;
+import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
+import org.chorem.pollen.PollenQueryBuilder;
+import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.PollAccountDAO;
import org.chorem.pollen.entity.PollAccountImpl;
import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.VoteDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
import java.util.List;
@@ -58,11 +65,35 @@
}
@Override
- protected List<PollAccount> executeGetVotes(TopiaContext transaction, Poll poll, int startIndex, int endIndex) throws Exception {
- return null;
+ protected List<PollAccount> executeGetVotes(TopiaContext transaction,
+ Filter filter)
+ throws Exception {
+
+ PollenQueryBuilder builder = context.newQueryBuilder(null);
+
+ TopiaQuery query = builder.createQueryFindVotesByPoll(filter);
+
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+
+ query.addLoad(PollAccount.CHOICE_VOTE);
+
+ List<PollAccount> results = dao.findAllByQuery(query);
+ return results;
}
@Override
+ protected int executeGetNbVotes(TopiaContext transaction, Filter filter)
+ throws TopiaException {
+
+ PollenQueryBuilder builder = context.newQueryBuilder(null);
+
+ TopiaQuery query = builder.createQueryFindVotesByPoll(filter);
+
+ int result = query.executeCount(transaction);
+ return result;
+ }
+
+ @Override
protected void executeDeleteVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception {
}
}
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-25 12:40:47 UTC (rev 3012)
@@ -77,6 +77,7 @@
pollen.error.serviceUser.updateUser=
pollen.error.serviceVote.canVote=
pollen.error.serviceVote.deleteVote=
+pollen.error.serviceVote.getNbVotes=
pollen.error.serviceVote.getNewPollAccount=
pollen.error.serviceVote.getPollAccount=
pollen.error.serviceVote.getVote=
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-25 12:40:47 UTC (rev 3012)
@@ -76,6 +76,7 @@
pollen.error.serviceUser.updateUser=
pollen.error.serviceVote.canVote=
pollen.error.serviceVote.deleteVote=
+pollen.error.serviceVote.getNbVotes=
pollen.error.serviceVote.getNewPollAccount=
pollen.error.serviceVote.getPollAccount=
pollen.error.serviceVote.getVote=
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -218,8 +218,7 @@
public String getServerPath() {
if (serverPath == null) {
- serverPath = "http://" + request.getHeader("host") +
- request.getContextPath();
+ serverPath = "http://" + request.getHeader("host");
if (logger.isDebugEnabled()) {
logger.debug("URL : " + serverPath);
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -0,0 +1,66 @@
+package org.chorem.pollen.ui.components;
+
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.SupportsInformalParameters;
+import org.apache.tapestry5.corelib.base.AbstractLink;
+import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.ui.data.ChoiceField;
+import org.chorem.pollen.ui.services.ServiceImage;
+import org.slf4j.Logger;
+
+/**
+ * Created: 25 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+@SupportsInformalParameters
+public class ChoiceImage extends AbstractLink {
+
+ @Parameter(required = true)
+ private ChoiceField source;
+
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private ServiceImage serviceImage;
+
+ void beginRender(MarkupWriter writer) {
+
+ Link link = resources.createEventLink("showImage",
+ source.getImageFileName(), source.getImageDir(), false);
+
+ Link thumbLink = resources.createEventLink("showImage",
+ source.getImageFileName(), source.getImageDir(), true);
+
+ writeLink(writer, link, "rel", "lightbox[pollChoiceImages]");
+ writer.element("img", "src", thumbLink, "alt", source.getDescription());
+ writer.end();
+ }
+
+ /**
+ * Event for showing image.
+ *
+ * @param src of the image
+ * @param imageDir directory of the image
+ * @param thumb to show the thumb image or not
+ * @return the streamResponse to display
+ * @see ServiceImage#createImageStream(String, String, boolean)
+ */
+ @Log
+ public StreamResponse onShowImage(String src, String imageDir,
+ boolean thumb) {
+ return serviceImage.createImageStream(src, imageDir, thumb);
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ChoiceImage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -93,7 +93,7 @@
* Instantiate a new choiceField for a Date ChoiceType.
*
* @return the ChoiceField which is date typed
- * @see #setDateType(java.lang.String)
+ * @see #setDateType()
*/
public static ChoiceField getChoiceDate() {
ChoiceField result = new ChoiceField();
@@ -131,7 +131,7 @@
* Change type of the choice to date type. The date type need a {@code
* pattern} to format the date when saving the choice.
*
- * @see #saveName()
+ * @see #saveName(ServiceImage)
*/
public void setDateType() {
setChoiceType(ChoiceType.DATE);
@@ -143,7 +143,7 @@
* of the choice as saving folder for the resulting image file.
*
* @param pollUId used as saving folder
- * @see #saveName()
+ * @see #saveName(ServiceImage)
*/
public void setImageType(String pollUId) {
setChoiceType(ChoiceType.IMAGE);
@@ -262,5 +262,7 @@
return getChoice().getChoiceType();
}
-
+ public boolean isHidden() {
+ return choice.isHidden();
+ }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -1,6 +1,8 @@
package org.chorem.pollen.ui.data;
+import org.apache.commons.lang.StringUtils;
+
/**
* PollUri
*
@@ -64,4 +66,8 @@
return uri;
}
+ public boolean hasAccountUid() {
+ return StringUtils.isNotEmpty(accountUid);
+ }
+
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -322,7 +322,10 @@
poll.clearChoice();
for (ChoiceField choiceField : getChoices()) {
choiceField.saveName(serviceImage);
- poll.addChoice(choiceField.getChoice());
+ Choice choice = choiceField.getChoice();
+ if (StringUtils.isNotEmpty(choice.getName())) {
+ poll.addChoice(choice);
+ }
}
poll = servicePoll.createPoll(poll, getLists());
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/UserAccountDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/UserAccountDataSource.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/UserAccountDataSource.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -15,10 +15,7 @@
* Created: 23 avr. 2010
*
* @author fdesbois
- * @version $Revision$
- * <p/>
- * Mise a jour: $Date$
- * par : $Author$
+ * @version $Id$
*/
public class UserAccountDataSource extends AbstractMappedGridDataSource<String, UserAccount> {
@@ -33,7 +30,8 @@
@Override
protected Map<String, UserAccount> execute(int startIndex, int endIndex,
- SortConstraint orderBy) throws PollenException {
+ SortConstraint orderBy)
+ throws PollenException {
filter.setStartIndex(startIndex);
filter.setEndIndex(endIndex);
filter.setOrderBy(resolveOrderBy(orderBy));
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -1,61 +0,0 @@
-package org.chorem.pollen.ui.models;
-
-import org.chorem.pollen.PollenBusinessException;
-import org.chorem.pollen.entity.Poll;
-import org.chorem.pollen.entity.PollAccount;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.service.ServicePoll;
-import org.chorem.pollen.service.ServiceVote;
-import org.chorem.pollen.ui.data.PollUri;
-
-/**
- * Created: 21 mai 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- * @version $Id$
- */
-public class VoteModel {
-
- protected Poll poll;
-
- protected PollAccount account;
-
- protected ServicePoll servicePoll;
-
- protected ServiceVote serviceVote;
-
- public VoteModel(ServicePoll servicePoll, ServiceVote serviceVote) {
- this.servicePoll = servicePoll;
- }
-
- public void init(PollUri uri)
- throws PollenBusinessException {
- poll = servicePoll.getPoll(uri.getPollUid());
- account = serviceVote.getPollAccount(uri.getAccountUid());
- }
-
- public Poll getPoll() {
- return poll;
- }
-
- public boolean isCreatorUser(UserAccount user) {
- return user.equals(poll.getCreator().getUserAccount());
- }
-
- public PollAccount getPollAccount() {
- if (account == null) {
- account = serviceVote.getNewPollAccount();
- }
- return account;
- }
-
- public boolean isAllowedToVote() {
- if (poll.isFinished()) {
- return false;
- }
- if (poll.getPollType().isRestrictedOrGroup() || poll.getAnonymous()) {
- return serviceVote.canVote(poll, account);
- }
- return true;
- }
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -28,7 +28,6 @@
import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.StreamResponse;
-import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
@@ -36,17 +35,15 @@
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.PollenBusinessException;
-import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.PollenProperty;
+import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.Choice;
-import org.chorem.pollen.entity.Comment;
-import org.chorem.pollen.entity.CommentImpl;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.Vote;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.service.ServiceUser;
@@ -56,11 +53,10 @@
import org.chorem.pollen.ui.components.Pager;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.ChoiceField;
+import org.chorem.pollen.ui.data.EvenOdd;
import org.chorem.pollen.ui.data.PollUri;
-import org.chorem.pollen.ui.models.VoteModel;
import org.chorem.pollen.ui.services.PollenManager;
import org.chorem.pollen.ui.services.ServiceImage;
-import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
/**
@@ -82,6 +78,14 @@
return border;
}
+ @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
+ @Property
+ private String title;
+
+ @Property
+ private PollUri uri;
+
+ /** Services injected */
@Inject
private Logger logger;
@@ -89,22 +93,10 @@
private Messages messages;
@Inject
- private PollenManager manager;
+ private Locale currentLocale;
- @Property
- private PollUri uri;
-
- /** TEMP : Affichage des messages pour l'utilisateur */
-// @Component(id = "feedback")
-// private FeedBack feedback;
-
- @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
- @Property
- private String title;
-
- /** Locale courante */
@Inject
- private Locale currentLocale;
+ private PollenManager manager;
@Inject
private ServicePoll servicePoll;
@@ -115,15 +107,13 @@
@Inject
private ServiceVote serviceVote;
- /** Compte du votant */
+ /** Page properties */
+ private Poll poll;
+
private PollAccount pollAccount;
- /** Format des dates */
private DateFormat dateFormat;
- @Persist
- private VoteModel model;
-
/**
* Address bar of the page. Display in Border layout component.
*
@@ -143,16 +133,15 @@
Object[] onPassivate() {
return new Object[]{uri, page};
}
-
@Log
void setupRender() {
if (uri == null) {
addFatal("Url null");
} else {
- model = null;
try {
- getModel().init(uri);
+ getPoll();
+ //pollAccount = serviceVote.getPollAccount(uri.getAccountUid());
} catch (PollenBusinessException eee) {
// Poll not found
String message = manager.getErrorMessage(logger, messages, eee);
@@ -183,12 +172,7 @@
// }
}
- public VoteModel getModel() {
- if (model != null) {
- model = new VoteModel(servicePoll, serviceVote);
- }
- return model;
- }
+ /************** POLL INFOS ************************************************/
/**
* DateFormat used in the page.
@@ -203,20 +187,33 @@
return dateFormat;
}
- public Poll getPoll() {
- return getModel().getPoll();
+ public Poll getPoll() throws PollenBusinessException {
+ if (poll == null) {
+ poll = servicePoll.getPoll(uri.getPollUid(), Poll.CHOICE);
+ }
+ return poll;
}
+ public PollAccount getCreator() throws PollenBusinessException {
+ return getPoll().getCreator();
+ }
+
/**
* Use a PollAccount to represent the current session user.
- * The existing account is used if accountUid is present in the uri.
- * Otherwise a new account is instanciate with user properties
- * (for vote name).
+ * The existing pollAccount is used if accountUid is present in the uri.
+ * Otherwise a new pollAccount is instanciate.
*
* @return
*/
- public PollAccount getPollAccount() throws PollenBusinessException {
- return getModel().getPollAccount();
+ public PollAccount getPollAccount() {
+ if (pollAccount == null) {
+ if (uri.hasAccountUid()) {
+ pollAccount = serviceVote.getPollAccount(uri.getAccountUid());
+ } else {
+ pollAccount = serviceVote.getNewPollAccount();
+ }
+ }
+ return pollAccount;
}
/**
@@ -226,63 +223,15 @@
* @throws PollenBusinessException
*/
public boolean isCreatorUser() throws PollenBusinessException {
- return isUserConnected() && getModel().isCreatorUser(getUserConnected());
+ UserAccount creatorAccount = poll.getCreator().getUserAccount();
+ return isUserConnected() && getUserConnected().equals(creatorAccount);
}
- /************** PAGER *****************************************************/
-
- @InjectComponent
- private Pager pager;
-
- private Integer page;
-
- @Persist
- private Integer nbVotesPerPage;
-
- public int getPage() {
- if (page == null) {
- page = pager.getFirstPage();
- }
- return page;
+ public String getHelpMessage() {
+ // Help message depends on voteCountingType
+ return "";
}
- @Log
- public void setPage(int page) {
- this.page = page;
- }
-
- /**
- * Get the number of votes to display per page from configuration.
- *
- * @return the number of votes to display per page
- */
- public int getNbVotesPerPage() {
- if (nbVotesPerPage == null) {
- nbVotesPerPage = getPagerRange();
- }
- return nbVotesPerPage;
- }
-
- public void setNbVotesPerPage(int nbVotesPerPage) {
- this.nbVotesPerPage = nbVotesPerPage;
- }
-
- public int getPagerRange() {
- return Integer.parseInt(
- manager.getProperty(PollenProperty.NB_VOTES_PER_PAGE));
- }
-
- public String getNoPagerText() throws PollenBusinessException {
- // FIXME : manage nbVotes in Poll
-
-// if (getPoll().getNbVotes() == 0) {
-// return messages.get("pollen.ui.vote.noVote");
-// }
-// return messages.format("pollen.ui.vote.noPager",
-// getPoll().getNbVotes());
- return "";
- }
-
/************** CHOICES ***************************************************/
private List<ChoiceField> choices;
@@ -298,24 +247,27 @@
@Inject
private Block choiceDate;
+//
+// private ChoiceField newChoice;
+//
+// @Inject
+// private Block newChoiceText;
+//
+// @Inject
+// private Block newChoiceImage;
+//
+// @Inject
+// private Block newChoiceDate;
- private ChoiceField newChoice;
-
@Inject
- private Block newChoiceText;
-
- @Inject
- private Block newChoiceImage;
-
- @Inject
- private Block newChoiceDate;
-
- @Inject
private ComponentResources resources;
@Inject
private ServiceImage serviceImage;
+ @Property
+ private EvenOdd evenOdd = new EvenOdd();
+
/**
* Get choices of the poll. The ChoiceDTO from poll will be converted
* to ChoiceField to easily managed different type of choice (image,
@@ -359,154 +311,229 @@
}
}
- /**
- * Image link to show the miniature (thumb) of current choice image.
- *
- * @return the image link for current choice image.
- */
- public Link getImageThumb() {
- return getImageLink(true);
- }
+// /**
+// * Image link to show the miniature (thumb) of current choice image.
+// *
+// * @return the image link for current choice image.
+// */
+// public Link getImageThumb() {
+// return getImageLink(true);
+// }
+//
+// /**
+// * Image link to show the normal (not thumb) image of current choice image.
+// *
+// * @return the image link for current choice image.
+// */
+// public Link getImageLink() {
+// return getImageLink(false);
+// }
+//
+// private Link getImageLink(boolean thumb) {
+// return resources.createEventLink("showImage",
+// choice.getImageFileName(), choice.getImageDir(), thumb);
+// }
+//
+// /**
+// * Event for showing image.
+// *
+// * @param src of the image
+// * @param imageDir directory of the image
+// * @param thumb to show the thumb image or not
+// * @return the streamResponse to display
+// * @see ServiceImage#createImageStream(String, String, boolean)
+// */
+// @Log
+// public StreamResponse onShowImage(String src, String imageDir,
+// boolean thumb) {
+// return serviceImage.createImageStream(src, imageDir, thumb);
+// }
+//
+// /**
+// * Delegator : Retrieve the newChoice to create a choice in the poll
+// * using the addChoice form.
+// *
+// * @return a ChoiceField to manage different choice type
+// * @throws PollenBusinessException
+// */
+// public ChoiceField getNewChoice() throws PollenBusinessException {
+// if (newChoice == null) {
+// newChoice = new ChoiceField(getPoll());
+//// switch (getPoll().getChoiceType()) {
+//// case DATE:
+//// newChoice = ChoiceField.getChoiceDate();
+//// break;
+//// case IMAGE:
+//// newChoice = ChoiceField.getChoiceImage(
+//// getPoll().getPollUid());
+//// break;
+//// case TEXT:
+//// default:
+//// newChoice = ChoiceField.getChoiceText();
+//// }
+// // Don't know what validate is
+//// newChoice.setValidate(true);
+// }
+// return newChoice;
+// }
+//
+// /**
+// * Retrieve the block to display for input choiceName depends on
+// * choice type.
+// *
+// * @return the block to display
+// * @throws PollenBusinessException
+// */
+//// public Block getNewChoiceBlock() throws PollenBusinessException {
+//// switch(getPoll().getChoiceType()) {
+//// case IMAGE:
+//// return newChoiceImage;
+//// case DATE:
+//// return newChoiceDate;
+//// case TEXT:
+//// default:
+//// return newChoiceText;
+//// }
+//// }
+//
+// public boolean isPollChoiceRunning() throws PollenBusinessException {
+// return getPoll().getChoiceAddAllowed() && isPollChoiceStarted();
+// }
+//
+// /**
+// * TODO : whithout DTO, this method can be place in PollEntity
+// *
+// * @return true if adding choice is started, false otherwise
+// * @throws PollenBusinessException
+// */
+// public boolean isPollChoiceStarted() throws PollenBusinessException {
+// Date now = new Date();
+// boolean started = getPoll().getBeginChoiceDate() == null
+// || getPoll().getBeginChoiceDate().before(now);
+// boolean ended = getPoll().getEndChoiceDate() != null
+// && getPoll().getEndChoiceDate().before(now);
+// return started && !ended;
+// }
+//
+// public boolean getCanDeleteChoice() throws PollenBusinessException {
+// return isPollChoiceRunning() && isCreatorUser();
+// }
+//
+// /**
+// * ACTION EVENT :: delete selected choice
+// */
+// void onActionFromDeleteChoice(String choiceId)
+// throws PollenBusinessException {
+// if (getCanDeleteChoice()) {
+//
+//// servicePoll.deleteChoice(getPoll(), choiceId);
+// // Reset choices (ChoiceField list) to retrieve the updated one
+// // from poll
+// choices = null;
+// }
+// }
+//
+// public boolean getCanAddChoice() throws PollenBusinessException {
+// return isPollChoiceRunning();
+// }
+//
+// /**
+// * SUCCESS EVENT :: add a new choice from addChoice form.
+// *
+// * @throws PollenBusinessException
+// */
+// void onSuccessFromAddChoice() throws PollenBusinessException {
+// if (getCanAddChoice()) {
+// // No validation done on choice with existing name
+// // Save name depends on choice type
+// newChoice.saveName(serviceImage);
+// //getPoll().addChoice(newChoice.getChoice());
+// }
+// }
- /**
- * Image link to show the normal (not thumb) image of current choice image.
- *
- * @return the image link for current choice image.
- */
- public Link getImageLink() {
- return getImageLink(false);
- }
+ /************** PAGER *****************************************************/
- private Link getImageLink(boolean thumb) {
- return resources.createEventLink("showImage",
- choice.getImageFileName(), choice.getImageDir(), thumb);
+ @InjectComponent
+ private Pager pager;
+
+ private Integer page;
+
+ @Persist
+ private Integer nbVotesPerPage;
+
+ private Integer nbVotes;
+
+ public int getPage() {
+ if (page == null) {
+ page = pager.getFirstPage();
+ }
+ return page;
}
- /**
- * Event for showing image.
- *
- * @param src of the image
- * @param imageDir directory of the image
- * @param thumb to show the thumb image or not
- * @return the streamResponse to display
- * @see ServiceImage#createImageStream(String, String, boolean)
- */
@Log
- public StreamResponse onShowImage(String src, String imageDir,
- boolean thumb) {
- return serviceImage.createImageStream(src, imageDir, thumb);
+ public void setPage(int page) {
+ this.page = page;
}
-
+
/**
- * Delegator : Retrieve the newChoice to create a choice in the poll
- * using the addChoice form.
+ * Get the number of votes to display per page from configuration.
*
- * @return a ChoiceField to manage different choice type
- * @throws PollenBusinessException
+ * @return the number of votes to display per page
*/
- public ChoiceField getNewChoice() throws PollenBusinessException {
- if (newChoice == null) {
- newChoice = new ChoiceField(getPoll());
-// switch (getPoll().getChoiceType()) {
-// case DATE:
-// newChoice = ChoiceField.getChoiceDate();
-// break;
-// case IMAGE:
-// newChoice = ChoiceField.getChoiceImage(
-// getPoll().getPollUid());
-// break;
-// case TEXT:
-// default:
-// newChoice = ChoiceField.getChoiceText();
-// }
- // Don't know what validate is
-// newChoice.setValidate(true);
+ public int getNbVotesPerPage() {
+ if (nbVotesPerPage == null) {
+ nbVotesPerPage = getPagerRange();
}
- return newChoice;
+ return nbVotesPerPage;
}
- /**
- * Retrieve the block to display for input choiceName depends on
- * choice type.
- *
- * @return the block to display
- * @throws PollenBusinessException
- */
-// public Block getNewChoiceBlock() throws PollenBusinessException {
-// switch(getPoll().getChoiceType()) {
-// case IMAGE:
-// return newChoiceImage;
-// case DATE:
-// return newChoiceDate;
-// case TEXT:
-// default:
-// return newChoiceText;
-// }
-// }
-
- public boolean isPollChoiceRunning() throws PollenBusinessException {
- return getPoll().getChoiceAddAllowed() && isPollChoiceStarted();
+ public void setNbVotesPerPage(int nbVotesPerPage) {
+ this.nbVotesPerPage = nbVotesPerPage;
}
- /**
- * TODO : whithout DTO, this method can be place in PollEntity
- *
- * @return true if adding choice is started, false otherwise
- * @throws PollenBusinessException
- */
- public boolean isPollChoiceStarted() throws PollenBusinessException {
- Date now = new Date();
- boolean started = getPoll().getBeginChoiceDate() == null
- || getPoll().getBeginChoiceDate().before(now);
- boolean ended = getPoll().getEndChoiceDate() != null
- && getPoll().getEndChoiceDate().before(now);
- return started && !ended;
+ public int getPagerRange() {
+ return Integer.parseInt(
+ manager.getProperty(PollenProperty.NB_VOTES_PER_PAGE));
}
- public boolean getCanDeleteChoice() throws PollenBusinessException {
- return isPollChoiceRunning() && isCreatorUser();
- }
-
- /**
- * ACTION EVENT :: delete selected choice
- */
- void onActionFromDeleteChoice(String choiceId)
- throws PollenBusinessException {
- if (getCanDeleteChoice()) {
-
-// servicePoll.deleteChoice(getPoll(), choiceId);
- // Reset choices (ChoiceField list) to retrieve the updated one
- // from poll
- choices = null;
+ public int getNbVotes() throws PollenBusinessException {
+ if (nbVotes == null) {
+ Filter filter = new Filter();
+ filter.setReference(getPoll());
+ nbVotes = serviceVote.getNbVotes(filter);
}
+ return nbVotes;
}
- public boolean getCanAddChoice() throws PollenBusinessException {
- return isPollChoiceRunning();
+ @Log
+ public Filter getVoteFilter() throws PollenBusinessException {
+ Filter filter = new Filter();
+ filter.setStartIndex(pager.getStartIndex());
+ filter.setEndIndex(pager.getEndIndex());
+ filter.setReference(getPoll());
+ return filter;
}
- /**
- * SUCCESS EVENT :: add a new choice from addChoice form.
- *
- * @throws PollenBusinessException
- */
- void onSuccessFromAddChoice() throws PollenBusinessException {
- if (getCanAddChoice()) {
- // No validation done on choice with existing name
- // Save name depends on choice type
- newChoice.saveName(serviceImage);
- //getPoll().addChoice(newChoice.getChoice());
- }
+ public String getNoPagerText() throws PollenBusinessException {
+ // FIXME : manage nbVotes in Poll
+
+// if (getPoll().getNbVotes() == 0) {
+// return messages.get("pollen.ui.vote.noVote");
+// }
+// return messages.format("pollen.ui.vote.noPager",
+// getPoll().getNbVotes());
+ return "";
}
/************** VOTES *****************************************************/
- private List<Vote> votes;
+ private List<PollAccount> participants;
@Property
- private int voteIndex;
+ private int participantIndex;
- private Vote currentVote;
+ @Property
+ private PollAccount participant;
/**
* Retrieve votes of the current poll from business module.
@@ -516,19 +543,16 @@
* @return the list of votes to display
* @throws PollenBusinessException
*/
- public List<Vote> getVotes() throws PollenBusinessException {
- if (votes == null) {
-// votes = servicePoll.getVotes(getPoll(),
-// pager.getStartIndex(), pager.getEndIndex());
+ public List<PollAccount> getParticipants() throws PollenBusinessException {
+ if (participants == null) {
+ participants = serviceVote.getVotes(getVoteFilter());
}
- return votes;
+ return participants;
}
- public Vote getCurrentVote() {
- if (currentVote == null) {
-// currentVote = serviceVote.getNewVote(getPollAccount());
- }
- return currentVote;
+ public Vote getVote() {
+ Vote vote = participant.getChoiceVote(choice.getChoice());
+ return vote;
}
// /**
@@ -557,11 +581,17 @@
// }
public boolean getCanVote() {
- return getModel().isAllowedToVote();
+ if (poll.isFinished()) {
+ return false;
+ }
+ if (poll.getPollType().isRestrictedOrGroup() || poll.getAnonymous()) {
+ return serviceVote.canVote(poll, pollAccount);
+ }
+ return true;
}
public boolean canEditVote() throws PollenBusinessException {
- // If the current account exist from uri and equals to the current vote
+ // If the current pollAccount exist from uri and equals to the current vote
// String newAccountId = getPollAccount().getId();
// if (newAccountId != null &&
// newAccountId.equals(vote.getPollAccountId())) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -1,8 +1,10 @@
package org.chorem.pollen.ui.services;
+import org.apache.tapestry5.Link;
import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.upload.services.UploadedFile;
+import org.chorem.pollen.ui.data.ChoiceField;
/**
* This service is used to manage images in pollen application.
@@ -59,5 +61,4 @@
* @return the filename of the saved file
*/
String saveImage(UploadedFile tmpfile, String filedir);
-
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-05-25 12:40:47 UTC (rev 3012)
@@ -13,11 +13,13 @@
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.Link;
import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.services.Response;
import org.apache.tapestry5.upload.services.UploadedFile;
import org.chorem.pollen.PollenProperty;
import org.chorem.pollen.PollenContext;
+import org.chorem.pollen.ui.data.ChoiceField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-25 09:29:17 UTC (rev 3011)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-25 12:40:47 UTC (rev 3012)
@@ -3,7 +3,7 @@
<html t:type="border" t:addressBar="addressBar" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUid"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <t:if test="poll">
+
<h1 class="titleVote">${poll.title}</h1>
<!-- Informations sur le sondage -->
@@ -13,18 +13,18 @@
<legend>${message:about}</legend>
<div style="float: right">
<t:if test="poll.publicResults">
- <a t:type="pagelink" t:page="poll/Results" t:context="poll.pollUid">
+ <a t:type="pagelink" t:page="poll/Results" t:context="poll.uid">
<img src="${asset:context:img/count.png}" title="${message:results-help}" alt="${message:results}"/>
</a>
</t:if>
- <t:FeedContextLink t:id="feedContext" />
- <t:if test="feedFileExisting">
- <t:FileLink filename="${poll.pollUid}" type="literal:application/atom+xml" t:context="feedContext">
- <img src="${asset:context:img/feed.png}" title="Atom" alt="Atom"/>
- </t:FileLink>
- </t:if>
+ <!--<t:FeedContextLink t:id="feedContext" />-->
+ <!--<t:if test="feedFileExisting">-->
+ <!--<t:FileLink filename="${poll.pollUid}" type="literal:application/atom+xml" t:context="feedContext">-->
+ <!--<img src="${asset:context:img/feed.png}" title="Atom" alt="Atom"/>-->
+ <!--</t:FileLink>-->
+ <!--</t:if>-->
</div>
- <label>${message:creator-label}</label> ${poll.creatorName}
+ <label>${message:creator-label}</label> ${creator.name}
<br/>
<label>${message:beginDate-label}</label>
<t:output value="poll.beginDate" format="dateFormat"/>
@@ -32,7 +32,7 @@
<label>${message:endDate-label}</label>
<t:output value="poll.endDate" format="dateFormat"/>
<br/>
- <label>${message:pollType-label}</label> ${poll.voteCounting}
+ <label>${message:pollType-label}</label> ${poll.voteCountingType}
<span t:type="ck/Tooltip" title="${message:help}" value="${helpMessage}" effect="appear">
<img src="${asset:context:img/help.png}" alt="${message:help}"/>
</span>
@@ -41,50 +41,51 @@
<!--<t:if test="pollChoiceOrVoteStarted">-->
- <!--<!– Sondage –>-->
+ <!-- Sondage -->
- <!--<!–<t:zone t:id="pollZone" t:show="show" t:update="show">–>-->
- <!--<t:if t:test="poll.anonymous">-->
- <!--<p>${voteSizeMessage}</p>-->
+ <!--<t:zone t:id="pollZone" t:show="show" t:update="show">-->
+ <t:if t:test="poll.anonymous">
+ <p>${format:vote-size=nbVotes}</p>
<!--<t:feedback t:id="voteFeedback"/>-->
- <!--<p:else>-->
- <!--<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"-->
- <!--t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>-->
- <!--</p:else>-->
- <!--</t:if>-->
- <!--<t:form t:id="voteForm" t:zone="pollZone">-->
- <!--<table id="poll">-->
- <!--<thead>-->
- <!--<tr>-->
- <!--<t:if test="${AccountFieldDisplayed}">-->
- <!--<th style="width:200px;">${message:voterName}</th>-->
+ <p:else>
+ <t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="nbVotes"
+ t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>
+ </p:else>
+ </t:if>
+ <t:form t:id="voteForm">
+ <table id="poll">
+ <thead>
+ <tr>
+ <!--<t:if test="accountFieldDisplayed">-->
+ <th style="width:200px;">${message:voterName}</th>
<!--<p:else>-->
<!--<th></th>-->
<!--</p:else>-->
<!--</t:if>-->
- <!--<th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">-->
- <!--<t:unless test="choice.hidden">-->
- <!--<!– Blocks for each choice type –>-->
- <!--<t:block t:id="choiceText">-->
- <!--<span class="desc">${choice.text}</span>-->
- <!--</t:block>-->
- <!--<t:block t:id="choiceImage">-->
+ <th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">
+ <t:unless test="choice.hidden">
+ <!-- Blocks for each choice type -->
+ <t:block t:id="choiceText">
+ <span class="desc">${choice.text}</span>
+ </t:block>
+ <t:block t:id="choiceImage">
+ <t:choiceImage t:source="choice" />
<!--<a rel="lightbox[pollChoiceImages]" href="${imageLink}">-->
<!--<img src="${imageThumb}" alt="${choice.description}"/>-->
<!--</a>-->
- <!--</t:block>-->
- <!--<t:block t:id="choiceDate">-->
- <!--<t:output value="choice.date" format="dateFormat"/>-->
- <!--</t:block>-->
- <!--<!– Display choice with or whithout description –>-->
- <!--<t:if t:test="choice.description">-->
- <!--<span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">-->
- <!--<t:delegate to="choiceBlock" />-->
- <!--</span>-->
- <!--<p:else>-->
- <!--<t:delegate to="choiceBlock" />-->
- <!--</p:else>-->
- <!--</t:if>-->
+ </t:block>
+ <t:block t:id="choiceDate">
+ <t:output value="choice.date" format="dateFormat"/>
+ </t:block>
+ <!-- Display choice with or whithout description -->
+ <t:if t:test="choice.description">
+ <span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">
+ <t:delegate to="choiceBlock" />
+ </span>
+ <p:else>
+ <t:delegate to="choiceBlock" />
+ </p:else>
+ </t:if>
<!--<t:if test="canDeleteChoice">-->
<!--<!– Action to delete the choice –>-->
<!--<t:actionlink t:id="deleteChoice" context="choice.id"-->
@@ -93,10 +94,10 @@
<!--alt="message:pollen.ui.choice.delete.title"/>-->
<!--</t:actionlink>-->
<!--</t:if>-->
- <!--</t:unless>-->
- <!--</th>-->
- <!--</tr>-->
- <!--</thead>-->
+ </t:unless>
+ </th>
+ </tr>
+ </thead>
<!--<t:if test="canVote">-->
<!--<tfoot>-->
<!--<tr>-->
@@ -109,7 +110,7 @@
<!--</p:else>-->
<!--</t:if>-->
<!--<t:loop t:source="choices" t:value="choice" volatile="true">-->
- <!--<t:if test="!choice.hidden">-->
+ <!--<t:unless test="choice.hidden">-->
<!--<th>-->
<!--<t:if test="poll.voteCounting.normal">-->
<!--<input t:type="checkbox" value="addChoice" />-->
@@ -124,23 +125,23 @@
<!--<t:textField t:value="addNumberVote" size="3" />-->
<!--</t:if>-->
<!--</th>-->
- <!--</t:if>-->
+ <!--</t:unless>-->
<!--</t:loop>-->
<!--</tr>-->
<!--</tfoot>-->
<!--</t:if>-->
- <!--<tbody>-->
- <!--<t:unless t:test="poll.anonymous">-->
- <!--<t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true">-->
- <!--<tr>-->
- <!--<td class="${evenodd.next}">-->
- <!--<t:if test="${AccountFieldDisplayed}">-->
- <!--<t:unless test="${currentVoteAnonymous}">-->
- <!--${vote.name}-->
- <!--<p:else>-->
- <!--?-->
- <!--</p:else>-->
- <!--</t:unless>-->
+ <tbody>
+ <t:unless t:test="poll.anonymous">
+ <t:loop t:source="participants" t:value="participant" t:rowIndex="participantIndex" volatile="true">
+ <tr>
+ <td class="${evenodd.next}">
+ <!--<t:if test="accountFieldDisplayed">-->
+ <t:if test="participant.anonymous">
+ ?
+ <p:else>
+ ${participant.name}
+ </p:else>
+ </t:if>
<!--</t:if>-->
<!--<t:unless test="${poll.anonymous}">-->
<!--<t:if test="canEditVote()">-->
@@ -154,21 +155,24 @@
<!--</t:actionlink>-->
<!--</t:if>-->
<!--</t:unless>-->
- <!--</td>-->
- <!--<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">-->
- <!--<t:unless t:test="choiceHidden">-->
+ </td>
+ <t:loop t:source="choices" t:value="choice" volatile="true">
+ <t:unless t:test="choice.hidden">
<!--${setCurrentVoteChoice()}-->
- <!--<t:if t:test="poll.anonymous">-->
- <!--<td class="anonymous">?</td>-->
- <!--<p:else>-->
- <!--<t:if test="isNormalVoteCounting()">-->
- <!--<t:if test="isChoiceInVote(currentVoteChoice)">-->
- <!--<td class="voted">OK</td>-->
- <!--<p:else>-->
- <!--<td class="notVoted"></td>-->
- <!--</p:else>-->
- <!--</t:if>-->
- <!--</t:if>-->
+ <t:if t:test="poll.anonymous">
+ <td class="anonymous">?</td>
+ <p:else>
+ <t:if test="vote">
+ <t:if test="poll.voteCountingType.normal">
+ <td class="voted">OK</td>
+ <p:else>
+ <td class="voted">${vote.voteValue}</td>
+ </p:else>
+ </t:if>
+ <p:else>
+ <td class="notVoted"></td>
+ </p:else>
+ </t:if>
<!--<t:if test="isPercentageVoteCounting()">-->
<!--<t:if test="isChoiceInVote(currentVoteChoice)">-->
<!--<td class="voted">${currentVoteChoice.value} %</td>-->
@@ -193,13 +197,13 @@
<!--</p:else>-->
<!--</t:if>-->
<!--</t:if>-->
- <!--</p:else>-->
- <!--</t:if>-->
- <!--</t:unless>-->
- <!--</t:loop>-->
- <!--</tr>-->
- <!--</t:loop>-->
- <!--</t:unless>-->
+ </p:else>
+ </t:if>
+ </t:unless>
+ </t:loop>
+ </tr>
+ </t:loop>
+ </t:unless>
<!--<t:if test="poll.continuousResults">-->
<!--<tr>-->
<!--<td>-->
@@ -212,11 +216,11 @@
<!--</t:loop>-->
<!--</tr>-->
<!--</t:if>-->
- <!--</tbody>-->
- <!--</table>-->
- <!--<div id="voteError">-->
- <!--<t:errors/>-->
- <!--</div>-->
+ </tbody>
+ </table>
+ <div id="voteError">
+ <t:errors/>
+ </div>
<!--<t:if test="poll.running">-->
<!--<div id="buttons">-->
<!--<t:if test="anonymousVoteDisplayed">-->
@@ -227,8 +231,9 @@
<!--<input t:id="submitVote" t:type="Submit" t:value="${message:submitVote}" />-->
<!--</div>-->
<!--</t:if>-->
- <!--</t:form>-->
- <!--<!–</t:zone>–>-->
+ </t:form>
+ <!--</t:zone>-->
+ <!--</t:if>-->
<!--<!– Ajout de choix –>-->
@@ -311,5 +316,5 @@
<!--</t:zone>-->
<!--</t:if>-->
- </t:if>
+
</html>
\ No newline at end of file
1
0
25 May '10
Author: fdesbois
Date: 2010-05-25 11:29:17 +0200 (Tue, 25 May 2010)
New Revision: 3011
Url: http://chorem.org/repositories/revision/pollen/3011
Log:
- Start refactor Vote page
- Add pollenUtils for entities
- Move votes methods in a new ServiceVote
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -121,6 +121,7 @@
// Set context in PollenProperty enum to use easily method
// getValue() on PollenProperty
PollenProperty.setContext(this);
+ PollenUtils.setContext(this);
createSuperAdmin(serviceUser);
//
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -0,0 +1,22 @@
+package org.chorem.pollen;
+
+import java.util.Date;
+
+/**
+ * Created: 21 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class PollenUtils {
+
+ private static PollenContext context;
+
+ public static void setContext(PollenContext context) {
+ PollenUtils.context = context;
+ }
+
+ public static Date getCurrentDate() {
+ return context.getCurrentDate();
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -1,10 +1,14 @@
package org.chorem.pollen.entity;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenUtils;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
+import java.util.Date;
+
/**
* PollImpl
*
@@ -21,26 +25,6 @@
private static final long serialVersionUID = 1L;
@Override
- public boolean canVote(PollAccount person) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean canAdminPoll(PollAccount person) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean canCreateChoice(PollAccount person) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean canAccessPoll(PollAccount person) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
public ChoiceType getChoiceType() {
return ChoiceType.valueOf(getTypeChoice());
}
@@ -71,6 +55,7 @@
}
@Override
+ @Deprecated
public Choice addNewChoice(String name, String description) {
// check exist
Choice choice = new ChoiceImpl();
@@ -80,4 +65,21 @@
addChoice(choice);
return choice;
}
+
+ @Override
+ public boolean isStarted() {
+ Date now = PollenUtils.getCurrentDate();
+ return getBeginDate() == null || getBeginDate().before(now);
+ }
+
+ @Override
+ public boolean isFinished() {
+ Date now = PollenUtils.getCurrentDate();
+ return getEndDate() != null && getEndDate().before(now);
+ }
+
+ @Override
+ public boolean isRunning() {
+ return isStarted() && !isFinished() && !getClosed();
+ }
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -269,24 +269,6 @@
}
@Override
- protected void executeCreateUpdateVote(TopiaContext transaction,
- PollAccount person) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected void executeDeleteVote(TopiaContext transaction, Poll poll,
- PollAccount person) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected Poll executeGetPollForUpdate(TopiaContext transaction,
- String pollUId) throws PollenBusinessException, TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
protected List<Poll> executeGetAllPolls(TopiaContext transaction)
throws TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
@@ -312,25 +294,6 @@
}
@Override
- protected List<PollAccount> executeGetVotes(TopiaContext transaction,
- Poll poll, int startIndex, int endIndex)
- throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected Poll executeGetPollForResults(TopiaContext transaction,
- String pollUId) throws PollenBusinessException, TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- protected Poll executeGetPollForVote(TopiaContext transaction,
- String pollUId) throws PollenBusinessException, TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
protected ParticipantList executeGetNewPollList() {
PollAccount list = new PollAccountImpl();
list.setList(true);
@@ -380,7 +343,7 @@
@Override
protected Poll executeGetPoll(TopiaContext transaction,
String pollUid, String... properties)
- throws TopiaException {
+ throws TopiaException, PollenBusinessException {
PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
@@ -389,6 +352,10 @@
addLoad(properties);
Poll result = dao.findByQuery(query);
+ if (result == null) {
+ throw new PollenBusinessException(
+ PollenBusinessException.PollenExceptionType.POLL_NOT_EXIST);
+ }
return result;
}
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -0,0 +1,68 @@
+package org.chorem.pollen.service;
+
+import org.chorem.pollen.PollenContext;
+import org.chorem.pollen.PollenException;
+import org.chorem.pollen.entity.Poll;
+import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.PollAccountImpl;
+import org.chorem.pollen.entity.UserAccount;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+
+import java.util.List;
+
+/**
+ * Created: 21 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ServiceVoteImpl extends ServiceVoteAbstract {
+
+ private PollenContext context;
+
+ public void setContext(PollenContext context) {
+ this.context = context;
+ }
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws PollenException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
+ @Override
+ protected boolean executeCanVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception {
+ return false;
+ }
+
+ @Override
+ protected PollAccount executeGetNewPollAccount() throws Exception {
+ PollAccount account = new PollAccountImpl();
+ return account;
+ }
+
+ @Override
+ protected PollAccount executeGetPollAccount(TopiaContext transaction, String accountUid) throws Exception {
+ return null;
+ }
+
+ @Override
+ protected List<PollAccount> executeGetVotes(TopiaContext transaction, Poll poll, int startIndex, int endIndex) throws Exception {
+ return null;
+ }
+
+ @Override
+ protected void executeDeleteVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception {
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-25 09:29:17 UTC (rev 3011)
@@ -75,7 +75,12 @@
pollen.error.serviceUser.getUsers=
pollen.error.serviceUser.updateFavoriteParticipant=
pollen.error.serviceUser.updateUser=
+pollen.error.serviceVote.canVote=
+pollen.error.serviceVote.deleteVote=
+pollen.error.serviceVote.getNewPollAccount=
+pollen.error.serviceVote.getPollAccount=
pollen.error.serviceVote.getVote=
+pollen.error.serviceVote.getVotes=
pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
pollen.exception.favorite_list_name_exist=
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-25 09:29:17 UTC (rev 3011)
@@ -74,7 +74,12 @@
pollen.error.serviceUser.getUsers=
pollen.error.serviceUser.updateFavoriteParticipant=
pollen.error.serviceUser.updateUser=
+pollen.error.serviceVote.canVote=
+pollen.error.serviceVote.deleteVote=
+pollen.error.serviceVote.getNewPollAccount=
+pollen.error.serviceVote.getPollAccount=
pollen.error.serviceVote.getVote=
+pollen.error.serviceVote.getVotes=
pollen.error.serviceVote.getVotesByPoll=
pollen.error.serviceVote.hasAlreadyVoted=
pollen.exception.favorite_list_name_exist=La liste %1$s existe d\u00E9j\u00E0 pour l'utilisateur %2$s
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -4,6 +4,7 @@
import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.ioc.Messages;
import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenException;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.ParticipantList;
@@ -99,7 +100,8 @@
* @param user Connected user as creator of a new poll (can be null
* if no user is connected).
*/
- public void initPoll(ServicePoll servicePoll, String uid, UserAccount user) {
+ public void initPoll(ServicePoll servicePoll, String uid, UserAccount user)
+ throws PollenBusinessException {
if (StringUtils.isNotEmpty(uid)) {
if (logger.isDebugEnabled()) {
logger.debug("Get existing poll with pollUID = " + uid);
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -0,0 +1,61 @@
+package org.chorem.pollen.ui.models;
+
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.entity.Poll;
+import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.service.ServicePoll;
+import org.chorem.pollen.service.ServiceVote;
+import org.chorem.pollen.ui.data.PollUri;
+
+/**
+ * Created: 21 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class VoteModel {
+
+ protected Poll poll;
+
+ protected PollAccount account;
+
+ protected ServicePoll servicePoll;
+
+ protected ServiceVote serviceVote;
+
+ public VoteModel(ServicePoll servicePoll, ServiceVote serviceVote) {
+ this.servicePoll = servicePoll;
+ }
+
+ public void init(PollUri uri)
+ throws PollenBusinessException {
+ poll = servicePoll.getPoll(uri.getPollUid());
+ account = serviceVote.getPollAccount(uri.getAccountUid());
+ }
+
+ public Poll getPoll() {
+ return poll;
+ }
+
+ public boolean isCreatorUser(UserAccount user) {
+ return user.equals(poll.getCreator().getUserAccount());
+ }
+
+ public PollAccount getPollAccount() {
+ if (account == null) {
+ account = serviceVote.getNewPollAccount();
+ }
+ return account;
+ }
+
+ public boolean isAllowedToVote() {
+ if (poll.isFinished()) {
+ return false;
+ }
+ if (poll.getPollType().isRestrictedOrGroup() || poll.getAnonymous()) {
+ return serviceVote.canVote(poll, account);
+ }
+ return true;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -173,7 +173,12 @@
logger.debug("-------- NEW POLL FORM MODEL --------");
}
model = new PollFormModel();
- model.initPoll(servicePoll, pollUID, getUserConnected());
+ try {
+ model.initPoll(servicePoll, pollUID, getUserConnected());
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(logger, messages, eee);
+ addFatal(message);
+ }
}
return model;
}
@@ -394,7 +399,7 @@
/** Flag if submit comes from lists edition */
private boolean editLists;
- protected static final String EVENT_UPDATE_POLL_TYPE = "updateFromPollType";
+ protected static final String EVENT_UPDATE_POLL_TYPE = "updatePollType";
/** DATA ** */
@@ -437,7 +442,7 @@
}
@Log
- Object onUpdateFromPollType(String value) {
+ Object onUpdatePollType(String value) {
getModel().setPollType(servicePoll, manager, PollType.valueOf(value));
return refreshListZone();
}
@@ -658,11 +663,18 @@
pollLinks.setPollUri(uri);
// Send an email to the creator
if (creator.getEmail() != null) {
- if (!sendCreatorEmail(creator, uri)) {
- return mainZone;
+ try {
+ sendCreatorEmail(creator, uri);
+ pollLinks.addInfo(messages.get(
+ "pollen.ui.poll.links.creatorEmail.success"));
+ } catch (PollenBusinessException eee) {
+ String message =
+ manager.getErrorMessage(logger, messages, eee);
+ pollLinks.addError(message);
}
} else {
- pollLinks.addInfo("pollen.ui.poll.links.creatorEmail.notDefined");
+ pollLinks.addInfo(messages.get(
+ "pollen.ui.poll.links.creatorEmail.notDefined"));
}
if (getPoll().getPollType().isRestrictedOrGroup()) {
pollLinks.addInfo("Les votants ont reçu un mail !");
@@ -672,7 +684,8 @@
return mainZone;
}
- protected boolean sendCreatorEmail(PollAccount creator, PollUri uri) {
+ protected void sendCreatorEmail(PollAccount creator, PollUri uri)
+ throws PollenBusinessException {
PollenEmail email = new PollenEmailImpl();
email.setTo(creator.getEmail());
email.setSubject(messages.format(
@@ -684,15 +697,8 @@
servicePollUri.getVoteUrl(uri),
servicePollUri.getModerateVoteUrl(uri),
servicePollUri.getPollUpdateUrl(uri)));
- try {
- serviceEmail.sendEmail(email);
- pollLinks.addInfo("pollen.ui.poll.links.creatorEmail.success");
- } catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(logger, messages, eee);
- addError(message);
- return false;
- }
- return true;
+
+ serviceEmail.sendEmail(email);
}
@Log
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -4,6 +4,7 @@
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.ui.base.AbstractPollenPage;
@@ -69,7 +70,7 @@
}
}
- public boolean isPollNull() {
+ public boolean isPollNull() throws PollenBusinessException {
return getPoll() == null;
}
@@ -77,7 +78,7 @@
this.pollUri = pollUri;
}
- public Poll getPoll() {
+ public Poll getPoll() throws PollenBusinessException {
if (pollUri != null) {
poll = servicePoll.getPoll(pollUri.getPollUid());
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -478,7 +478,7 @@
if (id != null && !"".equals(id)) {
pollId = id.split(":", 2)[0];
- poll = servicePoll.getPollForResults(pollId);
+ //poll = servicePoll.getPollForResults(pollId);
if (poll != null) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -50,12 +50,14 @@
import org.chorem.pollen.entity.Vote;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.service.ServiceVote;
import org.chorem.pollen.ui.base.AbstractUploadPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.components.Pager;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.ChoiceField;
import org.chorem.pollen.ui.data.PollUri;
+import org.chorem.pollen.ui.models.VoteModel;
import org.chorem.pollen.ui.services.PollenManager;
import org.chorem.pollen.ui.services.ServiceImage;
import org.nuiton.web.tapestry5.components.FeedBack;
@@ -79,860 +81,9 @@
public Border getBorder() {
return border;
}
-//
-// @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
-// @Property
-// private String title;
-//
-// /** Paramètres de la page */
-// private String param;
-//
-// /** Affichage des messages pour l'utilisateur */
-// @Component(id = "feedback")
-// private FeedBack feedback;
-//
-//
-// /**
-// * Objet de session représentant l'url du site.
-// */
-// @SessionState
-// @Property
-// private String siteURL;
-//
-// @Component
-// private Form voteForm;
-//
-//// @Component(id = "pollAccountName")
-//// private TextField nameField;
-//
-//// /** Composant DateTimeField pour les choix du sondage */
-//// @SuppressWarnings("unused")
-//// @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" })
-//// private DateTimeField dateDTF;
-//
-// /** Locale courante */
-// @Inject
-// private Locale currentLocale;
-//
-// @Inject
-// private Logger logger;
-//
-// @Inject
-// private Messages messages;
-//
-// /**
-// * Vote courant de l'utilisateur
-// */
-// @Property
-// private Vote vote;
-//
-// /** Choix courant du sondage */
-// @Property
-// private Choice choiceOfPoll;
-// /** Choix courant du nouveau vote */
-// @Property
-// private Choice choiceOfVote;
-//
-// /** Résultats du sondage */
-// @Persist
-// private List<Result> results;
-//
-// /**
-// * Modèle pour l'affichage de la liste des sondages
-// */
-// @SuppressWarnings( { "unchecked", "unused" })
-// @Property
-// @Retain
-// private BeanModel voteModel;
-//
-// /*@InjectPage
-// private ImageDisplay imageDisplay;*/
-//
-//// @InjectComponent
-//// private Zone pollZone;
-//
-// /**
-// * Objet servant à changer la couleur à chaque ligne de la liste des
-// * sondages
-// */
-// @SuppressWarnings("unused")
-// @Property
-// private EvenOdd evenOdd = new EvenOdd();
-//
-// /** Choix courant (type texte) */
-// private boolean addChoice;
-//
-// /** Le votant a déjà voté ? */
-// private boolean alreadyVoted;
-//
-// /** Le vote est anonyme */
-// @Property
-// private boolean anonymousVote = false;
-//
-// /** Liste des choix */
-//// private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>();
-//
-// /** Identifiant du compte correspondant à l'adresse forgée */
-//// private String pollAccountId;
-//
-// /** Compte du votant */
-//// @Property
-//// private PollAccountDTO pollAccount;
-//
-//// /** Nouveau choix de type texte */
-//// @Property
-//// @Persist
-//// private ChoiceDTO newChoice;
-//
-// /** Nouveau choix de type date */
-// @Property
-// @Persist
-// private DateChoiceUIO newDateChoice;
-//
-// /** Nouveau choix de type image */
-// @Property
-// @Persist
-// private ImageChoiceUIO newImageChoice;
-//
-// /** Injection des services */
-// @Inject
-// private ServicePoll servicePoll;
-// @Inject
-// private ServiceVote serviceVote;
-//
-// @Inject
-// private ServicePollAccount servicePollAccount;
-// @Inject
-// private ServiceResults serviceResults;
-//
-// /**
-// * Composant pour la gestion des flux RSS
-// */
-// @InjectComponent
-// private ContextLink feedContext;
-//
-// /**
-// * Context to get feed of the current poll
-// * @return a FeedContext defined in .tml file
-// */
-// public ContextLink getFeedContext() {
-// return feedContext;
-// }
-//
-//// /**
-//// * Composant pour la gestion des upload d'images
-//// */
-//// @InjectComponent
-//// private ImageContextLink imgContext;
-////
-//// /**
-//// * Context to get images for choices.
-//// * @return an ImageContextLink defined in .tml file
-//// */
-//// public ImageContextLink getImgContext() {
-//// return imgContext;
-//// }
-//
-// @InjectComponent
-// private FeedBack voteFeedback;
-//
-// public String getVoteSizeMessage() throws PollenBusinessException {
-// if (log.isDebugEnabled()) {
-// log.debug("poll voteDTOs list size : " + getVotes().size());
-// log.debug("poll nbVotes : " + getPoll().getNbVotes());
-// }
-// return messages.format("vote-size", getPoll().getNbVotes());
-// }
-//
-// /** Méthode appelée après la soumission du vote. */
-//// @Log
-//// Object onSuccessFromVoteForm() throws PollenBusinessException {
-//// if (initPollAccount()) {
-//// List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
-//// if (getPoll().getVoteCounting() == VoteCountingType.NORMAL) {
-//// int nbChoices = 0;
-//// for (ChoiceDTO choice : getPoll().getChoices()) {
-//// if (choice.getValue() == 1) {
-//// nbChoices++;
-//// }
-//// choiceDTOs.add(choice);
-//// }
-//// if (nbChoices > getPoll().getMaxChoiceNb()) {
-//// voteForm.recordError(messages.format(("tooManyChoices"),
-//// getPoll().getMaxChoiceNb()));
-//// return pollZone.getBody();
-//// }
-////
-//// } else if (getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE) {
-//// int total = 0;
-//// for (ChoiceDTO choice : getPoll().getChoices()) {
-//// total = total + choice.getValue();
-//// choiceDTOs.add(choice);
-//// }
-//// if (total != 100) {
-//// voteForm.recordError(messages.get("not100percent"));
-//// return pollZone.getBody();
-//// }
-////
-//// } else if (getPoll().getVoteCounting() == VoteCountingType.CONDORCET) {
-//// for (ChoiceDTO choice : getPoll().getChoices()) {
-//// if (choice.getValue() == 0) {
-//// choice.setValue(100);
-//// }
-//// choiceDTOs.add(choice);
-//// }
-////
-//// } else if (getPoll().getVoteCounting() == VoteCountingType.NUMBER) {
-//// String votingId = pollAccount.getVotingId();
-//// if (anonymousVote) {
-//// votingId = "anonymous" + UUID.randomUUID().toString().replaceAll("-", "");
-//// }
-////
-//// for (ChoiceDTO choice : getPoll().getChoices()) {
-//// if (!choice.isHidden()) {
-//// choiceDTOs.add(choice);
-////
-//// // creates a new hidden choice
-////// ChoiceDTO hiddenChoice = new ChoiceDTO();
-////// hiddenChoice.setName(NumberMethod.HIDDEN_PREFIX +
-////// choice.getName() + "#" + votingId);
-////// hiddenChoice.setHidden(true);
-////// hiddenChoice.setValue(choice.getValue());
-////// hiddenChoice.setPollId(choice.getPollId());
-////// hiddenChoice.setVoteId(choice.getVoteId());
-////// hiddenChoice.setValidate(false);
-//// ChoiceDTO hiddenChoice =
-//// servicePoll.getNewHiddenChoice(choice, votingId);
-////
-//// String choiceId =
-//// serviceChoice.createChoice(hiddenChoice);
-//// hiddenChoice.setId(choiceId);
-//// choiceDTOs.add(hiddenChoice);
-//// }
-//// }
-//// }
-////
-//// VoteDTO vote = new VoteDTO(null, getPoll().getId(), null);
-//// vote.setChoiceDTOs(choiceDTOs);
-//// vote.setWeight(pollAccount.getWeight());
-//// vote.setAnonymous(anonymousVote);
-////
-//// // mise à jour du vote ou création d'un nouveau vote
-//// if (alreadyVoted) {
-//// for (VoteDTO v : getVotes()) {
-//// PollAccountDTO voteAccount = servicePollAccount
-//// .findPollAccountById(v.getPollAccountId());
-////
-//// if (voteAccount.getVotingId().equals(getPollAccount().getVotingId())) {
-//// vote.setId(v.getId());
-//// deleteVote(vote.getId());
-//// serviceVote.createVote(vote, getPollAccount());
-//// }
-//// }
-//// } else {
-//// serviceVote.createVote(vote, getPollAccount());
-//// }
-////
-//// // Mise à jour du sondage et des résultats
-//// //poll = servicePoll.findPollByPollId(getPoll().getPollId());
-//// poll = null;
-//// countPoll();
-////
-//// addFeedEntry(PollAction.ADDVOTE, getPollAccount().getVotingId(),
-//// getResultsAsString());
-//// sendMailNotification();
-//// voteFeedback.addInfo(messages.get("vote-success"));
-//// page = pager.getLastPage();
-//// // Reset votes to reload them depends on page change.
-//// votes = null;
-//// return this;
-//// }
-////// voteChoices.clear();
-//// return pollZone.getBody();
-//// }
-//
-//// private void deleteVote(String voteId) throws PollenBusinessException {
-//// for (VoteDTO vote : getVotes()) {
-//// if (vote.getId().equals(voteId)) {
-////
-//// List<ChoiceDTO> choiceDTOs = vote.getChoiceDTOs();
-//// for (ChoiceDTO choiceDTO : choiceDTOs) {
-////
-//// if (choiceDTO.isHidden()) {
-//// serviceChoice.deleteChoice(choiceDTO.getId());
-//// }
-//// }
-////
-//// break;
-//// }
-//// }
-////
-//// serviceVote.deleteVote(voteId);
-//// }
-////
-//// /** Méthode appelée lors de la suppression d'un vote. */
-//// Object onActionFromDeleteVote(String voteId) throws PollenBusinessException {
-//// deleteVote(voteId);
-////
-//// // Mise à jour du sondage et des résultats
-////// poll = servicePoll.findPollByPollId(poll.getPollId());
-//// poll = null;
-//// countPoll();
-////
-//// return pollZone.getBody();
-//// }
-//
-// /** Initialisation du pollAccount et contrôle du nom. */
-//// private boolean initPollAccount() throws PollenBusinessException {
-////
-//// //// Contrôle et définition du votingId
-//// alreadyVoted = false;
-//// boolean modifAllowed = false;
-//// boolean restrictedListsForbidden = false;
-////
-//// // Suppression des espaces pouvant provoquer un double vote
-//// String votingId = getPollAccount().getVotingId().trim();
-//// getPollAccount().setVotingId(votingId);
-////
-//// // Contrôle de la présence du votant dans les listes de votants
-//// // du sondage (si le sondage n'est pas libre)
-////// if (!isFreePoll()) {
-////// restrictedListsForbidden = true;
-////// for (VotingListDTO list : poll.getVotingListDTOs()) {
-////// for (PollAccountDTO account : list.getPollAccountDTOs()) {
-////// if (pollAccount.getVotingId().equals(account.getVotingId())) {
-////// restrictedListsForbidden = false;
-////// pollAccount = servicePollAccount
-////// .findPollAccountById(account.getId());
-////// pollAccount.setVotingListId(list.getId());
-////// pollAccount.setWeight(account.getWeight());
-////// logger.debug("Compte \"" + account.getVotingId()
-////// + "\" présent dans la liste \""
-////// + list.getName() + "\" (poids="
-////// + account.getWeight() + ")");
-////// }
-////// }
-////// }
-////// }
-////
-//// // The calcul of alreadyVoted will be needed for no double votingId
-//// // Carefull, not correct for an anonymous vote
-//// alreadyVoted = serviceVote.hasAlreadyVoted(votingId, getPoll());
-////
-//// // Check for restricted poll
-//// if (!alreadyVoted && !isFreePoll()) {
-//// if (uri.getAccountUid() != null) {
-//// // The accountUid must be valid for the poll
-//// PollAccountDTO restrictedAccount =
-//// servicePoll.getRestrictedAccount(uri.getAccountUid(), getPoll());
-////
-//// if (restrictedAccount != null) {
-//// // PollAccount is replaced by the good account from db
-//// pollAccount = restrictedAccount;
-//// // Refresh alreadyVoted value depends on getPollAccount()
-//// alreadyVoted = getPollAccount().isHasVoted();
-//// // Existing account is null is forbidden for a restricted poll
-//// } else {
-//// restrictedListsForbidden = true;
-//// }
-//// // Not allowed to vote without an accountUid
-//// } else {
-//// restrictedListsForbidden = true;
-//// }
-////
-//// if (restrictedListsForbidden) {
-////// voteForm.recordError(nameField,
-////// messages.get("restrictedListsForbidden"));
-//// }
-//// }
-////
-//// // Génération d'un identifiant de vote (si le sondage est libre et anonyme)
-//// if (getPoll().isAnonymous()) {
-//// anonymousVote = true;
-//// if (isFreePoll()) {
-//// getPollAccount().setVotingId("anonymous"
-//// + UUID.randomUUID().toString().replaceAll("-", ""));
-//// }
-//// }
-////
-//// //// Définition de l'userId
-//// if (userExists) {
-//// getPollAccount().setUserId(user.getId());
-//// } else {
-//// getPollAccount().setUserId("");
-//// }
-////
-//// modifAllowed = isModifAllowed(getPollAccount().getVotingId());
-//// if (alreadyVoted && !modifAllowed) {
-////// voteForm.recordError(nameField, messages.format("alreadyVoted",
-////// getPollAccount().getVotingId()));
-//// }
-////
-//// logger.debug("votingId: " + getPollAccount().getVotingId());
-//// logger.debug("alreadyVoted: " + alreadyVoted);
-//// logger.debug("modifAllowed: " + modifAllowed);
-//// logger.debug("restrictedListsForbidden: " + restrictedListsForbidden);
-//// return ((!alreadyVoted || modifAllowed) && !restrictedListsForbidden);
-//// }
-//
-// /**
-// * Retourne vrai si la modification du vote est autorisée. C'est à dire si
-// * l'utilisateur connecté est l'auteur du vote ou si le votant défini par
-// * l'url est l'auteur du vote.
-// *
-// * @param votingId le votant a rechercher
-// * @return vrai si la modification du vote est autorisée
-// */
-//// public boolean isModifAllowed(String votingId) throws PollenBusinessException {
-//// boolean modifAllowed = false;
-//// int i = 0;
-////
-//// // parcours des votes pour trouver celui correspondant au votingId
-//// // et contrôle du droit de modification
-//// while (i < getVotes().size() && !modifAllowed) {
-////
-//// // account : compte associé au vote courant
-//// //String id = getVotes().get(i).getPollAccountId();
-//// //PollAccountDTO account = servicePollAccount.findPollAccountById(id);
-//// VoteDTO curr = getVotes().get(i);
-////
-//// // si le votant du vote correspond au votingId
-//// if (curr.getName().equals(votingId)) {
-//// if (logger.isDebugEnabled()) {
-//// logger.debug("vote name: " + curr.getName());
-//// logger.debug("vote account: " + curr.getPollAccountId());
-////// logger.debug("voting account: " + pollAccountId);
-//// }
-////
-//// // si le votant du vote correspond au votant actuel (pollAccountId)
-////// if (pollAccountId != null
-////// && pollAccountId.equals(curr.getPollAccountId())) {
-////// modifAllowed = true;
-////// }
-////
-//// // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
-//// if (userExists && user.getId().length() > 0) {
-//// modifAllowed = user.getId().equals(curr.getUserId());
-//// }
-//// }
-////
-//// i++;
-//// }
-////
-//// return modifAllowed;
-//// }
-//
-// /** Ajout d'une entrée dans le flux de syndication */
-// private void addFeedEntry(PollAction pollAction, String titleStr,
-// String contentStr) throws PollenBusinessException {
-// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUid();
-// File feedFile = getFeedContext().getFile(getPoll().getPollUid());
-// String title = null;
-// String content = null;
-//
-// switch (pollAction) {
-// case ADDVOTE:
-// if (isVoteAnonymous()) {
-// titleStr = messages.get("anonymous");
-// }
-// title = messages.format("pollFeed_voteTitle", titleStr);
-// content = messages.format("pollFeed_voteContent", contentStr);
-// break;
-// case ADDCHOICE:
-// title = messages.format("pollFeed_choiceTitle", titleStr);
-// content = messages.format("pollFeed_choiceContent", contentStr);
-// break;
-// case ADDCOMMENT:
-// title = messages.format("pollFeed_commentTitle", titleStr);
-// content = messages.format("pollFeed_commentContent", contentStr);
-// break;
-// }
-//
-// if (!feedFile.exists()) {
-// FeedUtil.createFeed(feedFile, "atom_1.0", messages.format(
-// "pollFeed_title", getPoll().getTitle()), siteURL, messages
-// .format("pollFeed_desc", getPoll().getDescription()));
-// }
-// FeedUtil.feedFeed(feedFile, title, voteURL, content);
-// }
-//
-// /** Envoi du mail de notification */
-// private void sendMailNotification() throws PollenBusinessException {
-// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUid();
-// String modifURL = siteURL + "poll/Modification/" + getPoll().getPollUid()
-// + ":" + MD5.encode(getPoll().getCreatorId());
-// Map<String, String> data = new HashMap<String, String>();
-// data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
-// data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
-// data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM));
-//
-// // Mail au créateur
-// data.put("to", getPoll().getCreatorEmail());
-// data.put("title", messages.format("voteEmail_subject", getPoll().getTitle()));
-// data.put("msg", messages.format("voteEmail_msg", getPoll().getTitle(), getPoll()
-// .getNbVotes(), voteURL, modifURL));
-//
-// for (PreventRuleDTO rule : getPoll().getPreventRuleDTOs()) {
-// PreventRuleManager manager = new PreventRuleManager(rule);
-// manager.execute("vote", getVotes().size(), data);
-// }
-// }
-//
-// public boolean isAddChoice() {
-// return addChoice;
-// }
-//
-// public void setAddChoice(boolean addChoice) {
-// choiceOfVote.setValue((addChoice) ? 1 : 0);
-// }
-//
-// public void setAddNumberVote(Integer value) {
-// if (value != null) {
-// choiceOfVote.setValue(value);
-//
-// } else {
-// choiceOfVote.setValue(-1);
-// }
-// }
-//
-// public Integer getAddNumberVote() {
-// return null;
-// }
-//
-//
-// /**
-// * Retourne si le choix fait partie du vote (s'il a été renseigné par le
-// * votant).
-// *
-// * @param choice le choix concerné
-// * @return true si le choix est dans le vote
-// */
-// public Boolean isChoiceInVote(ChoiceDTO choice) throws PollenBusinessException {
-// if (choice != null) {
-// switch (getPoll().getVoteCounting()) {
-// case NORMAL:
-// return choice.getValue() > 0;
-// case PERCENTAGE:
-// return true;
-// case CONDORCET:
-// return choice.getValue() < 100;
-// case NUMBER:
-// return choice.getValue() >= 0;
-// }
-// }
-// return null;
-// }
-//
-// public boolean isChoiceHidden() {
-// return choiceOfPoll.isHidden();
-// }
-//
-// /**
-// * Retourne le choix de vote correspondant au choix de sondage courant.
-// *
-// * @return un choix de vote
-// */
-// @Property(write = false)
-// private ChoiceDTO currentVoteChoice;
-//
-// public char setCurrentVoteChoice() {
-//// currentVoteChoice = null;
-//// for (ChoiceDTO choice : vote.getChoiceDTOs()) {
-//// if (choice.getId().equals(choiceOfPoll.getId())) {
-//// currentVoteChoice = choice;
-//// break;
-//// }
-//// }
-//
-// return 0;
-// }
-//
-// /**
-// * Retourne le résultat correspondant au choix de sondage courant.
-// *
-// * @return le résultat du choix
-// */
-// public String getCurrentChoiceResult() {
-// String val = "";
-// for (ResultDTO result : results) {
-// if (result.getName().equals(choiceOfPoll.getName())) {
-// val = removeTrailing0(result.getValue());
-// }
-// }
-// return val;
-// }
-//
-// /**
-// * Vérifie que le fichier de flux de syndication existe.
-// *
-// * @return vrai si le fichier existe
-// */
-// @Log
-// public boolean isFeedFileExisting() throws PollenBusinessException {
-// File feedFile = getFeedContext().getFile(getPoll().getPollUid());
-// if (log.isDebugEnabled()) {
-// log.debug("feed context path : " + getFeedContext().getContextPath());
-// log.debug("feed absolute path : " + feedFile.getAbsolutePath());
-// }
-// return feedFile.exists() ? true : false;
-// }
-//
-// /**
-// * Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un
-// * double : 1,0 -> 1 et 1,2 -> 1,2.
-// *
-// * @param val le nombre
-// * @return le nombre sans 0 final
-// */
-// private String removeTrailing0(String val) {
-// if (val.endsWith(".0")) {
-// val = val.substring(0, val.indexOf('.'));
-// }
-// return val;
-// }
-//
-// /**
-// * Retourne une chaîne contenant les résultats du sondage.
-// *
-// * @return les résultats
-// */
-// public String getResultsAsString() throws PollenBusinessException {
-// StringBuffer res = new StringBuffer("");
-// Iterator<ResultDTO> it = results.iterator();
-// while (it.hasNext()) {
-// ResultDTO result = it.next();
-// if (isDateType()) {
-// Date date = new Date(Long.parseLong(result.getName()));
-// res.append(dateFormat.format(date));
-// } else {
-// res.append(result.getName());
-// }
-// res.append("=" + removeTrailing0(result.getValue()));
-// if (it.hasNext()) {
-// res.append(", ");
-// }
-// }
-// return res.toString();
-// }
-//
-// /**
-// * Retourne true si le sondage est anonyme ou si le vote soumis est anonyme.
-// * Utilisé lors de la soumission d'un vote.
-// *
-// * @return true si le vote est anonyme
-// */
-// public boolean isVoteAnonymous() throws PollenBusinessException {
-// return getPoll().isAnonymous() || anonymousVote;
-// }
-//
-// /**
-// * Retourne true si le sondage est anonyme ou si le vote courant est
-// * anonyme. Utilisé dans la boucle de parcours des votes.
-// *
-// * @return true si le vote est anonyme
-// */
-// public boolean isCurrentVoteAnonymous() throws PollenBusinessException {
-// return getPoll().isAnonymous() || vote.isAnonymous();
-// }
-//
-// /** Retourne vrai si la checkbox anonymousVote doit être affichée. */
-// public boolean isAnonymousVoteDisplayed() throws PollenBusinessException {
-// return getPoll().isAnonymousVoteAllowed() && !getPoll().isAnonymous();
-// }
-//
-// /** Retourne l'identifiant du votant du vote courant */
-// public String getCurrentVotingId() {
-// return vote.getName();
-// }
-//
-// /** Validation du champs de saisie du choix (texte). */
-// void onValidateFromTextName(String value) throws ValidationException, PollenBusinessException {
-// validateNewChoice(value);
-// }
-//
-// /** Validation du champs de saisie du choix (date). */
-// void onValidateFromDateDTF(Date value) throws ValidationException, PollenBusinessException {
-// validateNewChoice(String.valueOf(value.getTime()));
-// }
-//
-// /** Validation du champs de saisie du choix (image). */
-// void onValidateFromImgFile(UploadedFile value) throws ValidationException, PollenBusinessException {
-// validateNewChoice(value.getFileName().replace(' ', '_'));
-// }
-//
-// /** Validation du champs de saisie du choix. */
-// private void validateNewChoice(String value) throws ValidationException, PollenBusinessException {
-// for (ChoiceDTO choice : getPoll().getChoices()) {
-// if (value.equals(choice.getName())) {
-// throw new ValidationException(messages.format("choiceExists",
-// value));
-// }
-// }
-// }
-//
-// /** Méthode appelée lors de l'ajout d'un choix. */
-// Object onSuccessFromChoiceForm() throws PollenBusinessException {
-// String choiceName = null;
-// String choiceDesc = null;
-// if (isTextType()) {
-// if (newChoice.getName() != null) {
-// newChoice.setValidate(true);
-// newChoice.setPollUid(getPoll().getPollUid());
-// getPoll().getChoices().add(newChoice);
-// choiceName = newChoice.getName();
-// choiceDesc = newChoice.getDescription();
-// }
-// } else if (isDateType()) {
-// if (newDateChoice.getDate() != null) {
-// newDateChoice.setValidate(true);
-// newDateChoice.setPollUid(getPoll().getPollUid());
-// newDateChoice.setName(String.valueOf(newDateChoice.getDate()
-// .getTime()));
-// getPoll().getChoices().add(newDateChoice);
-// Date date = new Date(Long.parseLong(newDateChoice.getName()));
-// choiceName = dateFormat.format(date);
-// choiceDesc = newDateChoice.getDescription();
-// }
-// } else if (isImageType()) {
-// if (newImageChoice.getImg() != null) {
-// newImageChoice.setValidate(true);
-// newImageChoice.setPollUid(getPoll().getPollUid());
-// newImageChoice.setName(newImageChoice.getImg().getFileName()
-// .replace(' ', '_'));
-// getPoll().getChoices().add(newImageChoice);
-// //File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
-//// File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
-//// ImageUtil.saveImage(newImageChoice, imgFile);
-// choiceName = newImageChoice.getName();
-// choiceDesc = newImageChoice.getDescription();
-// }
-// }
-//
-// servicePoll.updatePoll(getPoll());
-// poll = null;
-// //poll = servicePoll.findPollByPollId(getPoll().getPollId());
-// addFeedEntry(PollAction.ADDCHOICE, choiceName, choiceDesc);
-//// newChoice = new ChoiceDTO();
-//// newDateChoice = new DateChoiceUIO();
-//// newImageChoice = new ImageChoiceUIO();
-// return this;
-// }
-//
-//// public boolean isPollNull() {
-//// return poll == null;
-//// }
-//
-//
-// public boolean isPollChoiceOrVoteStarted() throws PollenBusinessException {
-// return isPollChoiceStarted() || isPollStarted();
-// }
-//
-//// public boolean isDescNull() {
-//// return choiceOfPoll.getDescription() == null
-//// || "".equals(choiceOfPoll.getDescription());
-//// }
-//
-//
-// public boolean isFreePoll() throws PollenBusinessException {
-// return getPoll().getPollType() == PollType.FREE;
-// }
-//
-// public boolean isRestrictedPoll() throws PollenBusinessException {
-// return getPoll().getPollType() == PollType.RESTRICTED;
-// }
-//
-// public boolean isGroupPoll() throws PollenBusinessException {
-// return getPoll().getPollType() == PollType.GROUP;
-// }
-//
-// public boolean isTextType() throws PollenBusinessException {
-// return getPoll().getChoiceType() == ChoiceType.TEXT;
-// }
-//
-// public boolean isDateType() throws PollenBusinessException {
-// return getPoll().getChoiceType() == ChoiceType.DATE;
-// }
-//
-// public boolean isImageType() throws PollenBusinessException {
-// return getPoll().getChoiceType() == ChoiceType.IMAGE;
-// }
-//
-// public boolean isNormalVoteCounting() throws PollenBusinessException {
-// return getPoll().getVoteCounting() == VoteCountingType.NORMAL;
-// }
-//
-// public boolean isPercentageVoteCounting() throws PollenBusinessException {
-// return getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE;
-// }
-//
-// public boolean isCondorcetVoteCounting() throws PollenBusinessException {
-// return getPoll().getVoteCounting() == VoteCountingType.CONDORCET;
-// }
-//
-// public boolean isNumberVoteCounting() throws PollenBusinessException {
-// return getPoll().getVoteCounting() == VoteCountingType.NUMBER;
-// }
-//
-// /** Retourne le message d'aide correspondant au type de sondage. */
-// public String getHelpMessage() throws PollenBusinessException {
-// switch (getPoll().getVoteCounting()) {
-// case NORMAL:
-// return messages.get("normalVote-help");
-// case PERCENTAGE:
-// return messages.get("percentageVote-help");
-// case CONDORCET:
-// return messages.get("condorcetVote-help");
-// case NUMBER:
-// return messages.get("numberVote-help");
-// default:
-// return "";
-// }
-// }
-//
-// /**
-// * Retourne la date correspondant au choix courant
-// *
-// * @return date
-// */
-// public Date getChoiceNameAsDate() {
-// return new Date(Long.valueOf(choiceOfPoll.getName()));
-// }
-//
-// /** Dépouillement du sondage. Mise à jour des résultats. */
-// private void countPoll() throws PollenBusinessException {
-// ResultListDTO resultListDTO = null;
-// if (getPoll().getContinuousResults()) {
-//
-// if (isGroupPoll()) {
-// resultListDTO = serviceResults.getGroupResults(getPoll().getPollUid());
-// } else {
-// resultListDTO = serviceResults.getNormalResults(getPoll().getPollUid());
-// }
-//
-// results = resultListDTO.getResultDTOs();
-//
-// if (logger.isDebugEnabled()) {
-// for (ResultDTO res : results) {
-// logger.debug(res.getName() + ": " + res.getValue()
-// + ", (voteCounting=" + res.getVoteCounting()
-// + ", byGroup=" + res.isByGroup() + ")");
-// }
-// }
-// }
-// }
-
-
-
-
-
-
-
-
- ////////////////// NEW IMPLEMENTATION
-
@Inject
- private Logger log;
+ private Logger logger;
@Inject
private Messages messages;
@@ -944,8 +95,8 @@
private PollUri uri;
/** TEMP : Affichage des messages pour l'utilisateur */
- @Component(id = "feedback")
- private FeedBack feedback;
+// @Component(id = "feedback")
+// private FeedBack feedback;
@Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
@Property
@@ -960,15 +111,9 @@
@Inject
private ServiceUser serviceUser;
-
- /**
- * Sondage pour lequel l'utilisateur vote
- */
- @Persist
- private Poll poll;
- @Property
- private boolean pollNull;
+ @Inject
+ private ServiceVote serviceVote;
/** Compte du votant */
private PollAccount pollAccount;
@@ -976,11 +121,18 @@
/** Format des dates */
private DateFormat dateFormat;
+ @Persist
+ private VoteModel model;
+
/**
- * Méthode appelée au moment de l'activation de la page
+ * Address bar of the page. Display in Border layout component.
*
- * @param id l'identifiant du sondage et du votant
+ * @return the address bar of the page.
*/
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar().appendCurrent(title);
+ }
+
void onActivate(EventContext ec) throws PollenBusinessException {
uri = ec.get(PollUri.class, 0);
if (ec.getCount() > 1) {
@@ -988,49 +140,54 @@
}
}
- /**
- * Méthode appelée au moment de la désactivation de la page
- *
- * @return l'identifiant du sondage et du votant
- */
Object[] onPassivate() {
return new Object[]{uri, page};
}
- /**
- * Initialisation de l'affichage
- */
+
@Log
void setupRender() {
- try {
- poll = null;
- getPoll();
-
- if (getPoll().getClosed()) {
- feedback.addInfo(messages.get("pollClosed"));
- } else if (!isPollStarted()) {
- feedback.addInfo(messages.get("pollNotStarted"));
- } else if (isPollFinished()) {
- feedback.addInfo(messages.get("pollFinished"));
+ if (uri == null) {
+ addFatal("Url null");
+ } else {
+ model = null;
+ try {
+ getModel().init(uri);
+ } catch (PollenBusinessException eee) {
+ // Poll not found
+ String message = manager.getErrorMessage(logger, messages, eee);
+ addFatal(message);
}
- if (isPollChoiceRunning()) {
- feedback.addInfo(messages.get("pollChoiceRunning"));
- }
-
- //countPoll();
- } catch (PollenBusinessException eee) {
- feedback.addError(messages.get(eee.getMessage()));
- pollNull = true;
}
+
+
+// try {
+// poll = null;
+// getPoll();
+//
+// if (getPoll().getClosed()) {
+// addInfo(messages.get("pollClosed"));
+// } else if (!isPollStarted()) {
+// addInfo(messages.get("pollNotStarted"));
+// } else if (isPollFinished()) {
+// addInfo(messages.get("pollFinished"));
+// }
+// if (isPollChoiceRunning()) {
+// addInfo(messages.get("pollChoiceRunning"));
+// }
+//
+// //countPoll();
+// } catch (PollenBusinessException eee) {
+// addError(messages.get(eee.getMessage()));
+// pollNull = true;
+// }
}
- /**
- * Address bar of the page. Display in Border layout component.
- *
- * @return the address bar of the page.
- */
- public AddressBar getAddress() {
- return AddressBar.newBar().appendCurrent(title);
+ public VoteModel getModel() {
+ if (model != null) {
+ model = new VoteModel(servicePoll, serviceVote);
+ }
+ return model;
}
/**
@@ -1046,40 +203,10 @@
return dateFormat;
}
- public Poll getPoll() throws PollenBusinessException {
- if (poll == null) {
- poll = servicePoll.getPollForVote(uri.getPollUid());
-
- if (poll != null) {
-
- // Initialisations pour les formulaires
-// newChoice = new ChoiceDTO();
-// newDateChoice = new DateChoiceUIO();
-// newImageChoice = new ImageChoiceUIO();
- } else {
- throw new PollenBusinessException(
- PollenExceptionType.POLL_NOT_EXIST);
- }
- }
- return poll;
+ public Poll getPoll() {
+ return getModel().getPoll();
}
- public boolean isPollStarted() throws PollenBusinessException {
- Date now = new Date();
- return getPoll().getBeginDate() == null ||
- getPoll().getBeginDate().before(now);
- }
-
- public boolean isPollFinished() throws PollenBusinessException {
- Date now = new Date();
- return getPoll().getEndDate() != null &&
- getPoll().getEndDate().before(now);
- }
-
- public boolean isPollRunning() throws PollenBusinessException {
- return isPollStarted() && !isPollFinished() && !getPoll().getClosed();
- }
-
/**
* Use a PollAccount to represent the current session user.
* The existing account is used if accountUid is present in the uri.
@@ -1089,34 +216,7 @@
* @return
*/
public PollAccount getPollAccount() throws PollenBusinessException {
- if (pollAccount == null) {
- // Identification du votant
- if (uri.getAccountUid() != null) {
- // pollAccount = serviceUser.getPerson(uri.getAccountUid());
-
-
-// pollAccountId = pollAccount.getId();
- }
-
- if (pollAccount == null) {
- // pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO();
-
-
-// if (userExists) {
-// if (user.getFirstName() != null && user.getLastName() != null) {
-// pollAccount.setVotingId(
-// user.getFirstName() + " " + user.getLastName());
-//
-// } else if (user.getFirstName() != null) {
-// pollAccount.setVotingId(user.getFirstName());
-//
-// } else if (user.getLastName() != null) {
-// pollAccount.setVotingId(user.getLastName());
-// }
-// }
- }
- }
- return pollAccount;
+ return getModel().getPollAccount();
}
/**
@@ -1126,8 +226,7 @@
* @throws PollenBusinessException
*/
public boolean isCreatorUser() throws PollenBusinessException {
- return isUserConnected() && getUserConnected().equals(
- getPoll().getCreator().getUserAccount());
+ return isUserConnected() && getModel().isCreatorUser(getUserConnected());
}
/************** PAGER *****************************************************/
@@ -1227,8 +326,8 @@
*/
public List<ChoiceField> getChoices() throws PollenBusinessException {
if (choices == null) {
- if (log.isInfoEnabled()) {
- log.info("Prepare choices for render");
+ if (logger.isInfoEnabled()) {
+ logger.info("Prepare choices for render");
}
choices = new ArrayList<ChoiceField>();
for (Choice curr : getPoll().getChoice()) {
@@ -1236,8 +335,8 @@
choices.add(field);
}
}
- if (log.isDebugEnabled()) {
- log.debug("nb choices loaded : " + choices.size());
+ if (logger.isDebugEnabled()) {
+ logger.debug("nb choices loaded : " + choices.size());
}
return choices;
}
@@ -1457,8 +556,8 @@
// return getCurrentVote().getChoiceValue(choice.getId());
// }
- public boolean getCanVote() throws PollenBusinessException {
- return isPollRunning();
+ public boolean getCanVote() {
+ return getModel().isAllowedToVote();
}
public boolean canEditVote() throws PollenBusinessException {
@@ -1486,68 +585,70 @@
/************** COMMENTS **************************************************/
- @InjectComponent
- private Zone commentZone;
+ // TODO-fdesbois-2010-05-21 : create a component for comments
- private List<Comment> comments;
-
- /** Commentaire courant pour l'affichage des commentaires */
- @SuppressWarnings("unused")
- @Property
- @Persist
- private Comment comment;
-
- /** Nouveau commentaire posté */
- private Comment newComment;
-
- public List<Comment> getComments() throws PollenBusinessException {
- if (comments == null) {
- comments = servicePoll.getComments(poll, -1, -1);
- }
- return comments;
- }
-
- /**
- * Accessor for newComment property. Instantiate a new comment if needed.
- *
- * @return the current newComment.
- */
- public Comment getNewComment() {
- if (newComment == null) {
- newComment = new CommentImpl();
- }
- return newComment;
- }
-
- /**
- * ACTION EVENT :: delete a comment.
- *
- * @param commentId id of the comment to delete
- * @return the commentZone
- * @throws PollenBusinessException
- */
- Object onActionFromDeleteComment(String commentId) throws PollenBusinessException {
-// servicePoll.deleteComment(getPoll(), commentId);
- return commentZone.getBody();
- }
-
- /**
- * SUCCESS EVENT :: submit form for adding a new comment.
- *
- * @return the commentZone
- * @throws PollenBusinessException
- */
- @Log
- Object onSuccessFromCommentForm() throws PollenBusinessException {
- if (log.isDebugEnabled()) {
- log.debug("newComment author : " + getNewComment().getAuthor());
- log.debug("newComment text : " + getNewComment().getText());
- }
-// getNewComment().setPostDate(new Date());
-// servicePoll.createComment(getPoll(), getNewComment());
-// addFeedEntry(PollAction.ADDCOMMENT,
-// getNewComment().getAuthor(),
-// getNewComment().getText());
- return commentZone.getBody();
- }
+// @InjectComponent
+// private Zone commentZone;
+//
+// private List<Comment> comments;
+//
+// /** Commentaire courant pour l'affichage des commentaires */
+// @SuppressWarnings("unused")
+// @Property
+// @Persist
+// private Comment comment;
+//
+// /** Nouveau commentaire posté */
+// private Comment newComment;
+//
+// public List<Comment> getComments() throws PollenBusinessException {
+// if (comments == null) {
+// comments = servicePoll.getComments(poll, -1, -1);
+// }
+// return comments;
+// }
+//
+// /**
+// * Accessor for newComment property. Instantiate a new comment if needed.
+// *
+// * @return the current newComment.
+// */
+// public Comment getNewComment() {
+// if (newComment == null) {
+// newComment = new CommentImpl();
+// }
+// return newComment;
+// }
+//
+// /**
+// * ACTION EVENT :: delete a comment.
+// *
+// * @param commentId id of the comment to delete
+// * @return the commentZone
+// * @throws PollenBusinessException
+// */
+// Object onActionFromDeleteComment(String commentId) throws PollenBusinessException {
+//// servicePoll.deleteComment(getPoll(), commentId);
+// return commentZone.getBody();
+// }
+//
+// /**
+// * SUCCESS EVENT :: submit form for adding a new comment.
+// *
+// * @return the commentZone
+// * @throws PollenBusinessException
+// */
+// @Log
+// Object onSuccessFromCommentForm() throws PollenBusinessException {
+// if (logger.isDebugEnabled()) {
+// logger.debug("newComment author : " + getNewComment().getAuthor());
+// logger.debug("newComment text : " + getNewComment().getText());
+// }
+//// getNewComment().setPostDate(new Date());
+//// servicePoll.createComment(getPoll(), getNewComment());
+//// addFeedEntry(PollAction.ADDCOMMENT,
+//// getNewComment().getAuthor(),
+//// getNewComment().getText());
+// return commentZone.getBody();
+// }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-25 09:29:17 UTC (rev 3011)
@@ -41,6 +41,8 @@
import org.chorem.pollen.service.ServicePollImpl;
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.service.ServiceUserImpl;
+import org.chorem.pollen.service.ServiceVote;
+import org.chorem.pollen.service.ServiceVoteImpl;
import org.chorem.pollen.ui.data.PollUri;
import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
@@ -88,6 +90,12 @@
return service;
}
+ public static ServiceVote buildServiceVote(PollenManager manager) {
+ ServiceVoteImpl service = new ServiceVoteImpl();
+ service.setContext(manager.getContext());
+ return service;
+ }
+
public static ServiceEmail buildServiceEmail(PollenManager manager) {
ServiceEmailImpl service = new ServiceEmailImpl();
service.setContext(manager.getContext());
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-21 11:59:50 UTC (rev 3010)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-25 09:29:17 UTC (rev 3011)
@@ -1,12 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html t:type="border" t:addressBar="addressBar" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUid"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-<t:border t:address="address.items" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUid"
- xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-
- <t:feedback t:id="feedback"/>
- <t:unless test="pollNull">
+ <t:if test="poll">
<h1 class="titleVote">${poll.title}</h1>
-
<!-- Informations sur le sondage -->
<div id="pollTop">
${poll.description}
@@ -14,9 +13,9 @@
<legend>${message:about}</legend>
<div style="float: right">
<t:if test="poll.publicResults">
- <t:PageLink t:page="poll/Results" t:context="poll.pollUid">
+ <a t:type="pagelink" t:page="poll/Results" t:context="poll.pollUid">
<img src="${asset:context:img/count.png}" title="${message:results-help}" alt="${message:results}"/>
- </t:PageLink>
+ </a>
</t:if>
<t:FeedContextLink t:id="feedContext" />
<t:if test="feedFileExisting">
@@ -40,277 +39,277 @@
</fieldset>
</div>
- <t:if test="pollChoiceOrVoteStarted">
+ <!--<t:if test="pollChoiceOrVoteStarted">-->
- <!-- Sondage -->
+ <!--<!– Sondage –>-->
- <!--<t:zone t:id="pollZone" t:show="show" t:update="show">-->
- <t:if t:test="poll.anonymous">
- <p>${voteSizeMessage}</p>
- <t:feedback t:id="voteFeedback"/>
- <p:else>
- <t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"
- t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>
- </p:else>
- </t:if>
- <t:form t:id="voteForm" t:zone="pollZone">
- <table id="poll">
- <thead>
- <tr>
- <t:if test="${AccountFieldDisplayed}">
- <th style="width:200px;">${message:voterName}</th>
- <p:else>
- <th></th>
- </p:else>
- </t:if>
- <th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">
- <t:unless test="choice.hidden">
- <!-- Blocks for each choice type -->
- <t:block t:id="choiceText">
- <span class="desc">${choice.text}</span>
- </t:block>
- <t:block t:id="choiceImage">
- <a rel="lightbox[pollChoiceImages]" href="${imageLink}">
- <img src="${imageThumb}" alt="${choice.description}"/>
- </a>
- </t:block>
- <t:block t:id="choiceDate">
- <t:output value="choice.date" format="dateFormat"/>
- </t:block>
- <!-- Display choice with or whithout description -->
- <t:if t:test="choice.description">
- <span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">
- <t:delegate to="choiceBlock" />
- </span>
- <p:else>
- <t:delegate to="choiceBlock" />
- </p:else>
- </t:if>
- <t:if test="canDeleteChoice">
- <!-- Action to delete the choice -->
- <t:actionlink t:id="deleteChoice" context="choice.id"
- t:mixins="confirm" t:message="message:pollen.ui.choice.delete.confirm">
- <img src="${asset:context:img/delete.png}" title="message:pollen.ui.choice.delete.title"
- alt="message:pollen.ui.choice.delete.title"/>
- </t:actionlink>
- </t:if>
- </t:unless>
- </th>
- </tr>
- </thead>
- <t:if test="canVote">
- <tfoot>
- <tr>
- <t:if test="accountFieldDisplayed">
- <th id="voterName">
- <input t:type="textfield" t:id="pollAccountName" value="pollAccount.votingId" t:validate="required"/>
- </th>
- <p:else>
- <th></th>
- </p:else>
- </t:if>
- <t:loop t:source="choices" t:value="choice" volatile="true">
- <t:if test="!choice.hidden">
- <th>
- <t:if test="poll.voteCounting.normal">
- <input t:type="checkbox" value="addChoice" />
- </t:if>
- <t:if test="poll.voteCounting.percentage">
- <t:textField t:value="currentVote.getChoiceValues(choice.id)" size="3" t:validate="required, min=0, max=100"/>%
- </t:if>
- <t:if test="poll.voteCounting.condorcet">
- <t:textField t:id="condorcetInput" t:value="choiceOfVote.value" size="3" t:nulls="zero" t:validate="min=0, max=99"/>
- </t:if>
- <t:if test="poll.voteCounting.number">
- <t:textField t:value="addNumberVote" size="3" />
- </t:if>
- </th>
- </t:if>
- </t:loop>
- </tr>
- </tfoot>
- </t:if>
- <tbody>
- <t:unless t:test="poll.anonymous">
- <t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true">
- <tr>
- <td class="${evenodd.next}">
- <t:if test="${AccountFieldDisplayed}">
- <t:unless test="${currentVoteAnonymous}">
- ${vote.name}
- <p:else>
- ?
- </p:else>
- </t:unless>
- </t:if>
- <t:unless test="${poll.anonymous}">
- <t:if test="canEditVote()">
- <t:actionlink t:id="editVote" context="voteIndex" t:zone="pollZone">
- <img src="${asset:context:img/editSmall.png}" title="${message:edit}" alt="${message:edit}"/>
- </t:actionlink>
- </t:if>
- <t:if test="creatorUser">
- <t:actionlink t:id="deleteVote" context="vote.id" t:zone="pollZone">
- <img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>
- </t:actionlink>
- </t:if>
- </t:unless>
- </td>
- <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
- <t:unless t:test="choiceHidden">
- ${setCurrentVoteChoice()}
- <t:if t:test="poll.anonymous">
- <td class="anonymous">?</td>
- <p:else>
- <t:if test="isNormalVoteCounting()">
- <t:if test="isChoiceInVote(currentVoteChoice)">
- <td class="voted">OK</td>
- <p:else>
- <td class="notVoted"></td>
- </p:else>
- </t:if>
- </t:if>
- <t:if test="isPercentageVoteCounting()">
- <t:if test="isChoiceInVote(currentVoteChoice)">
- <td class="voted">${currentVoteChoice.value} %</td>
- <p:else>
- <td class="notVoted"></td>
- </p:else>
- </t:if>
- </t:if>
- <t:if test="isCondorcetVoteCounting()">
- <t:if test="isChoiceInVote(currentVoteChoice)">
- <td class="voted">${currentVoteChoice.value}</td>
- <p:else>
- <td class="notVoted"></td>
- </p:else>
- </t:if>
- </t:if>
- <t:if test="isNumberVoteCounting()">
- <t:if test="isChoiceInVote(currentVoteChoice)">
- <td class="voted">${currentVoteChoice.value}</td>
- <p:else>
- <td class="notVoted"></td>
- </p:else>
- </t:if>
- </t:if>
- </p:else>
- </t:if>
- </t:unless>
- </t:loop>
- </tr>
- </t:loop>
- </t:unless>
- <t:if test="poll.continuousResults">
- <tr>
- <td>
- <t:PageLink t:page="poll/results" t:context="${poll.pollUid}">${message:results}</t:PageLink>
- </td>
- <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
- <t:if test="!isChoiceHidden()">
- <td class="result">${currentChoiceResult}</td>
- </t:if>
- </t:loop>
- </tr>
- </t:if>
- </tbody>
- </table>
- <div id="voteError">
- <t:errors/>
- </div>
- <t:if test="pollRunning">
- <div id="buttons">
- <t:if test="anonymousVoteDisplayed">
- <t:checkbox t:id="anonymousVote" t:value="anonymousVote" />
- <t:label for="anonymousVote" />
- <br/>
- </t:if>
- <input t:id="submitVote" t:type="Submit" t:value="${message:submitVote}" />
- </div>
- </t:if>
- </t:form>
- <!--</t:zone>-->
+ <!--<!–<t:zone t:id="pollZone" t:show="show" t:update="show">–>-->
+ <!--<t:if t:test="poll.anonymous">-->
+ <!--<p>${voteSizeMessage}</p>-->
+ <!--<t:feedback t:id="voteFeedback"/>-->
+ <!--<p:else>-->
+ <!--<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"-->
+ <!--t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--<t:form t:id="voteForm" t:zone="pollZone">-->
+ <!--<table id="poll">-->
+ <!--<thead>-->
+ <!--<tr>-->
+ <!--<t:if test="${AccountFieldDisplayed}">-->
+ <!--<th style="width:200px;">${message:voterName}</th>-->
+ <!--<p:else>-->
+ <!--<th></th>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--<th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">-->
+ <!--<t:unless test="choice.hidden">-->
+ <!--<!– Blocks for each choice type –>-->
+ <!--<t:block t:id="choiceText">-->
+ <!--<span class="desc">${choice.text}</span>-->
+ <!--</t:block>-->
+ <!--<t:block t:id="choiceImage">-->
+ <!--<a rel="lightbox[pollChoiceImages]" href="${imageLink}">-->
+ <!--<img src="${imageThumb}" alt="${choice.description}"/>-->
+ <!--</a>-->
+ <!--</t:block>-->
+ <!--<t:block t:id="choiceDate">-->
+ <!--<t:output value="choice.date" format="dateFormat"/>-->
+ <!--</t:block>-->
+ <!--<!– Display choice with or whithout description –>-->
+ <!--<t:if t:test="choice.description">-->
+ <!--<span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">-->
+ <!--<t:delegate to="choiceBlock" />-->
+ <!--</span>-->
+ <!--<p:else>-->
+ <!--<t:delegate to="choiceBlock" />-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--<t:if test="canDeleteChoice">-->
+ <!--<!– Action to delete the choice –>-->
+ <!--<t:actionlink t:id="deleteChoice" context="choice.id"-->
+ <!--t:mixins="confirm" t:message="message:pollen.ui.choice.delete.confirm">-->
+ <!--<img src="${asset:context:img/delete.png}" title="message:pollen.ui.choice.delete.title"-->
+ <!--alt="message:pollen.ui.choice.delete.title"/>-->
+ <!--</t:actionlink>-->
+ <!--</t:if>-->
+ <!--</t:unless>-->
+ <!--</th>-->
+ <!--</tr>-->
+ <!--</thead>-->
+ <!--<t:if test="canVote">-->
+ <!--<tfoot>-->
+ <!--<tr>-->
+ <!--<t:if test="accountFieldDisplayed">-->
+ <!--<th id="voterName">-->
+ <!--<input t:type="textfield" t:id="pollAccountName" value="pollAccount.votingId" t:validate="required"/>-->
+ <!--</th>-->
+ <!--<p:else>-->
+ <!--<th></th>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--<t:loop t:source="choices" t:value="choice" volatile="true">-->
+ <!--<t:if test="!choice.hidden">-->
+ <!--<th>-->
+ <!--<t:if test="poll.voteCounting.normal">-->
+ <!--<input t:type="checkbox" value="addChoice" />-->
+ <!--</t:if>-->
+ <!--<t:if test="poll.voteCounting.percentage">-->
+ <!--<t:textField t:value="currentVote.getChoiceValues(choice.id)" size="3" t:validate="required, min=0, max=100"/>%-->
+ <!--</t:if>-->
+ <!--<t:if test="poll.voteCounting.condorcet">-->
+ <!--<t:textField t:id="condorcetInput" t:value="choiceOfVote.value" size="3" t:nulls="zero" t:validate="min=0, max=99"/>-->
+ <!--</t:if>-->
+ <!--<t:if test="poll.voteCounting.number">-->
+ <!--<t:textField t:value="addNumberVote" size="3" />-->
+ <!--</t:if>-->
+ <!--</th>-->
+ <!--</t:if>-->
+ <!--</t:loop>-->
+ <!--</tr>-->
+ <!--</tfoot>-->
+ <!--</t:if>-->
+ <!--<tbody>-->
+ <!--<t:unless t:test="poll.anonymous">-->
+ <!--<t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true">-->
+ <!--<tr>-->
+ <!--<td class="${evenodd.next}">-->
+ <!--<t:if test="${AccountFieldDisplayed}">-->
+ <!--<t:unless test="${currentVoteAnonymous}">-->
+ <!--${vote.name}-->
+ <!--<p:else>-->
+ <!--?-->
+ <!--</p:else>-->
+ <!--</t:unless>-->
+ <!--</t:if>-->
+ <!--<t:unless test="${poll.anonymous}">-->
+ <!--<t:if test="canEditVote()">-->
+ <!--<t:actionlink t:id="editVote" context="voteIndex" t:zone="pollZone">-->
+ <!--<img src="${asset:context:img/editSmall.png}" title="${message:edit}" alt="${message:edit}"/>-->
+ <!--</t:actionlink>-->
+ <!--</t:if>-->
+ <!--<t:if test="creatorUser">-->
+ <!--<t:actionlink t:id="deleteVote" context="vote.id" t:zone="pollZone">-->
+ <!--<img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>-->
+ <!--</t:actionlink>-->
+ <!--</t:if>-->
+ <!--</t:unless>-->
+ <!--</td>-->
+ <!--<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">-->
+ <!--<t:unless t:test="choiceHidden">-->
+ <!--${setCurrentVoteChoice()}-->
+ <!--<t:if t:test="poll.anonymous">-->
+ <!--<td class="anonymous">?</td>-->
+ <!--<p:else>-->
+ <!--<t:if test="isNormalVoteCounting()">-->
+ <!--<t:if test="isChoiceInVote(currentVoteChoice)">-->
+ <!--<td class="voted">OK</td>-->
+ <!--<p:else>-->
+ <!--<td class="notVoted"></td>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:if>-->
+ <!--<t:if test="isPercentageVoteCounting()">-->
+ <!--<t:if test="isChoiceInVote(currentVoteChoice)">-->
+ <!--<td class="voted">${currentVoteChoice.value} %</td>-->
+ <!--<p:else>-->
+ <!--<td class="notVoted"></td>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:if>-->
+ <!--<t:if test="isCondorcetVoteCounting()">-->
+ <!--<t:if test="isChoiceInVote(currentVoteChoice)">-->
+ <!--<td class="voted">${currentVoteChoice.value}</td>-->
+ <!--<p:else>-->
+ <!--<td class="notVoted"></td>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:if>-->
+ <!--<t:if test="isNumberVoteCounting()">-->
+ <!--<t:if test="isChoiceInVote(currentVoteChoice)">-->
+ <!--<td class="voted">${currentVoteChoice.value}</td>-->
+ <!--<p:else>-->
+ <!--<td class="notVoted"></td>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:if>-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:unless>-->
+ <!--</t:loop>-->
+ <!--</tr>-->
+ <!--</t:loop>-->
+ <!--</t:unless>-->
+ <!--<t:if test="poll.continuousResults">-->
+ <!--<tr>-->
+ <!--<td>-->
+ <!--<t:PageLink t:page="poll/results" t:context="${poll.pollUid}">${message:results}</t:PageLink>-->
+ <!--</td>-->
+ <!--<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">-->
+ <!--<t:if test="!isChoiceHidden()">-->
+ <!--<td class="result">${currentChoiceResult}</td>-->
+ <!--</t:if>-->
+ <!--</t:loop>-->
+ <!--</tr>-->
+ <!--</t:if>-->
+ <!--</tbody>-->
+ <!--</table>-->
+ <!--<div id="voteError">-->
+ <!--<t:errors/>-->
+ <!--</div>-->
+ <!--<t:if test="poll.running">-->
+ <!--<div id="buttons">-->
+ <!--<t:if test="anonymousVoteDisplayed">-->
+ <!--<t:checkbox t:id="anonymousVote" t:value="anonymousVote" />-->
+ <!--<t:label for="anonymousVote" />-->
+ <!--<br/>-->
+ <!--</t:if>-->
+ <!--<input t:id="submitVote" t:type="Submit" t:value="${message:submitVote}" />-->
+ <!--</div>-->
+ <!--</t:if>-->
+ <!--</t:form>-->
+ <!--<!–</t:zone>–>-->
- <!-- Ajout de choix -->
- <!--<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUid"/>-->
- <t:if test="canAddChoice">
- <h4>${message:pollen.ui.choice.add.title}</h4>
- <div id="choiceFormDiv">
- <t:form t:id="addChoice">
- <t:if t:test="newChoice.type.date">
- <label t:type="label" for="choiceDate" />*<br />
- <input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"
- t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"
- t:datePattern="message:pollen.ui.choice.datePattern"/>
- </t:if>
- <t:if t:test="newChoice.type.image">
- <label t:type="label" for="choiceImage" />*<br />
- <input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />
- </t:if>
- <t:if t:test="newChoice.type.text">
- <label t:type="label" for="choiceText" />*<br />
- <input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>
- </t:if>
-<!-- <t:delegate t:to="newChoiceBlock" /><br />
- <t:block t:id="newChoiceDate">
- <label t:type="label" for="choiceDate" />*<br />
- <input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"
- t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"
- t:datePattern="message:pollen.ui.choice.datePattern"/>
- </t:block>
- <t:block t:id="newChoiceImage">
- <label t:type="label" for="choiceImage" />*<br />
- <input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />
- </t:block>
- <t:block t:id="newChoiceText">
- <label t:type="label" for="choiceText" />*<br />
- <input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>
- </t:block>-->
- <label t:type="label" for="choiceDescription" /><br />
- <input t:type="textfield" t:id="choiceDescription" value="newChoice.description" />
- <input t:type="submit" value="message:pollen.ui.choice.add.submit" />
- </t:form>
- </div>
- </t:if>
+ <!--<!– Ajout de choix –>-->
+ <!--<!–<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUid"/>–>-->
+ <!--<t:if test="canAddChoice">-->
+ <!--<h4>${message:pollen.ui.choice.add.title}</h4>-->
+ <!--<div id="choiceFormDiv">-->
+ <!--<t:form t:id="addChoice">-->
+ <!--<t:if t:test="newChoice.type.date">-->
+ <!--<label t:type="label" for="choiceDate" />*<br />-->
+ <!--<input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"-->
+ <!--t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"-->
+ <!--t:datePattern="message:pollen.ui.choice.datePattern"/>-->
+ <!--</t:if>-->
+ <!--<t:if t:test="newChoice.type.image">-->
+ <!--<label t:type="label" for="choiceImage" />*<br />-->
+ <!--<input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />-->
+ <!--</t:if>-->
+ <!--<t:if t:test="newChoice.type.text">-->
+ <!--<label t:type="label" for="choiceText" />*<br />-->
+ <!--<input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>-->
+ <!--</t:if>-->
+<!--<!– <t:delegate t:to="newChoiceBlock" /><br />-->
+ <!--<t:block t:id="newChoiceDate">-->
+ <!--<label t:type="label" for="choiceDate" />*<br />-->
+ <!--<input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"-->
+ <!--t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"-->
+ <!--t:datePattern="message:pollen.ui.choice.datePattern"/>-->
+ <!--</t:block>-->
+ <!--<t:block t:id="newChoiceImage">-->
+ <!--<label t:type="label" for="choiceImage" />*<br />-->
+ <!--<input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />-->
+ <!--</t:block>-->
+ <!--<t:block t:id="newChoiceText">-->
+ <!--<label t:type="label" for="choiceText" />*<br />-->
+ <!--<input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>-->
+ <!--</t:block>–>-->
+ <!--<label t:type="label" for="choiceDescription" /><br />-->
+ <!--<input t:type="textfield" t:id="choiceDescription" value="newChoice.description" />-->
+ <!--<input t:type="submit" value="message:pollen.ui.choice.add.submit" />-->
+ <!--</t:form>-->
+ <!--</div>-->
+ <!--</t:if>-->
<!-- Ajout de commentaires -->
- <h3>${message:comments}</h3>
- <t:zone t:id="commentZone" show="show" update="show">
- <div id="commentsDiv">
- <div t:type="loop" t:source="comments" t:value="comment" class="${evenodd.next}">
- <t:if test="creatorUser">
- <span class="cmd">
- <t:actionlink t:id="deleteComment" context="comment.id" t:zone="commentZone">
- <img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>
- </t:actionlink>
- </span>
- </t:if>
- <span class="name">${comment.author}</span> :
- <span class="date">
- <t:output value="comment.postDate" format="dateFormat"/>
- </span>
- <t:textOutput value="${comment.text}" />
- </div>
- </div>
- <div id="commentFormDiv">
- <t:form t:id="commentForm" t:zone="commentZone" t:volatile="true">
- <t:label for="commenterName" />
- <br/>
- <t:textField t:value="newComment.author" t:id="commenterName"
- t:validate="required" />
- <br/>
- <t:label for="commentArea" />
- <br/>
- <t:textArea t:value="newComment.text" t:id="commentArea"
- t:validate="required" />
- <br/>
- <t:Submit t:id="submitComment" t:value="${message:submitComment}" />
- </t:form>
- </div>
- </t:zone>
+ <!--<h3>${message:comments}</h3>-->
+ <!--<t:zone t:id="commentZone" show="show" update="show">-->
+ <!--<div id="commentsDiv">-->
+ <!--<div t:type="loop" t:source="comments" t:value="comment" class="${evenodd.next}">-->
+ <!--<t:if test="creatorUser">-->
+ <!--<span class="cmd">-->
+ <!--<t:actionlink t:id="deleteComment" context="comment.id" t:zone="commentZone">-->
+ <!--<img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>-->
+ <!--</t:actionlink>-->
+ <!--</span>-->
+ <!--</t:if>-->
+ <!--<span class="name">${comment.author}</span> :-->
+ <!--<span class="date">-->
+ <!--<t:output value="comment.postDate" format="dateFormat"/>-->
+ <!--</span>-->
+ <!--<t:textOutput value="${comment.text}" />-->
+ <!--</div>-->
+ <!--</div>-->
+ <!--<div id="commentFormDiv">-->
+ <!--<t:form t:id="commentForm" t:zone="commentZone" t:volatile="true">-->
+ <!--<t:label for="commenterName" />-->
+ <!--<br/>-->
+ <!--<t:textField t:value="newComment.author" t:id="commenterName"-->
+ <!--t:validate="required" />-->
+ <!--<br/>-->
+ <!--<t:label for="commentArea" />-->
+ <!--<br/>-->
+ <!--<t:textArea t:value="newComment.text" t:id="commentArea"-->
+ <!--t:validate="required" />-->
+ <!--<br/>-->
+ <!--<t:Submit t:id="submitComment" t:value="${message:submitComment}" />-->
+ <!--</t:form>-->
+ <!--</div>-->
+ <!--</t:zone>-->
- </t:if>
- </t:unless>
-</t:border>
\ No newline at end of file
+ <!--</t:if>-->
+ </t:if>
+</html>
\ No newline at end of file
1
0
r3010 - in trunk/pollen-ui/src/main/java/org/chorem/pollen/ui: components pages/admin pages/poll pages/user
by fdesbois@users.chorem.org 21 May '10
by fdesbois@users.chorem.org 21 May '10
21 May '10
Author: fdesbois
Date: 2010-05-21 13:59:50 +0200 (Fri, 21 May 2010)
New Revision: 3010
Url: http://chorem.org/repositories/revision/pollen/3010
Log:
Replace 'Handler' by 'Callback' in javadoc for onSomething methods
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-21 11:56:38 UTC (rev 3009)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-21 11:59:50 UTC (rev 3010)
@@ -57,7 +57,7 @@
private Form createList;
/**
- * SETUP_RENDER :: Handler method called when the component is rendered.
+ * SETUP_RENDER :: Callback method called when the component is rendered.
* Will clean errors from {@code createList} form.
*/
void setupRender() {
@@ -65,7 +65,7 @@
}
/**
- * ON_PREPARE :: Handler method for both prepareRender and prepareSubmit
+ * ON_PREPARE :: Callback method for both prepareRender and prepareSubmit
* events of {@code createList} form. Will instantiate a new instance
* of FavoriteList using {@code serviceFavorite} and user connected.
*
@@ -82,7 +82,7 @@
}
/**
- * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * ON_VALIDATE_FORM :: Callback method for validateForm event of the
* {@code createList} form. The {@code newFavoriteList} will be created
* using {@code serviceFavorite}. Errors from service will be recorded
* into the {@code createList} form.
@@ -108,7 +108,7 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the {@code createList}
+ * ON_SUCCESS :: Callback method for success event of the {@code createList}
* form. Will display a success message and refresh the {@code page}
* container.
*/
@@ -119,7 +119,7 @@
}
/**
- * ON_FAILURE :: Handler method for failure event of the {@code createList}
+ * ON_FAILURE :: Callback method for failure event of the {@code createList}
* form. Will refresh the form (included in a zone} to display errors.
*/
Object onFailureFromCreateList() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-21 11:56:38 UTC (rev 3009)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-21 11:59:50 UTC (rev 3010)
@@ -132,7 +132,7 @@
}
/**
- * ON_ACTION :: Handler method for action on editParticipant actionLink. The
+ * ON_ACTION :: Callback method for action on editParticipant actionLink. The
* participantEdited will be set to the participant selected in the Grid
* with {@code id}.
*
@@ -148,7 +148,7 @@
}
/**
- * ON_ACTION :: Handler method for action on cancelEdition actionLink.
+ * ON_ACTION :: Callback method for action on cancelEdition actionLink.
* Simply refresh the zone will change edition mode.
*
* @return the updateZone content to refresh
@@ -158,7 +158,7 @@
}
/**
- * ON_ACTION :: Handler method for action on removeParticipant actionLink.
+ * ON_ACTION :: Callback method for action on removeParticipant actionLink.
* The selected id from the Grid will be used to delete the participant.
*
* @param id used to delete the participant
@@ -195,7 +195,7 @@
}
/**
- * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * ON_VALIDATE_FORM :: Callback method for validateForm event of the
* participantsForm. The participantEdited will be updated using
* serviceFavorite. Errors from service will be recorded into the
* participantsForm.
@@ -217,7 +217,7 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the participantsForm.
+ * ON_SUCCESS :: Callback method for success event of the participantsForm.
* Clean form data (participantEdited) and display a success message. {@link
* #onSubmitFromParticipantsForm()} will be called after it to refresh the
* updateZone.
@@ -239,7 +239,7 @@
}
/**
- * ON_SUBMIT :: Handler method for submit event called after succes or
+ * ON_SUBMIT :: Callback method for submit event called after succes or
* failure of the participantsForm. Will refresh the updateZone to display
* errors or Grid updated.
*
@@ -258,7 +258,7 @@
private Form addParticipant;
/**
- * ON_PREPARE :: Handler method for both prepareSubmit and prepareRender
+ * ON_PREPARE :: Callback method for both prepareSubmit and prepareRender
* events of the participantsForm. Will instantiate a new
* FavoriteParticipant to render or saved with form data.
*
@@ -272,7 +272,7 @@
}
/**
- * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * ON_VALIDATE_FORM :: Callback method for validateForm event of the
* addParticipant form. The newParticipant will be created using
* serviceFavorite. Errors from service will be recorded into the
* addParticipant form.
@@ -293,7 +293,7 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the addParticipant
+ * ON_SUCCESS :: Callback method for success event of the addParticipant
* form. Will display a success message. {@link #onSubmitFromAddParticipant()}
* will be called after it to refresh the updateZone.
*/
@@ -304,7 +304,7 @@
}
/**
- * ON_SUBMIT :: Handler method for submit event called after succes or
+ * ON_SUBMIT :: Callback method for submit event called after succes or
* failure of the addParticipant form. Will refresh the updateZone to
* display errors or Grid updated.
*
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-21 11:56:38 UTC (rev 3009)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-21 11:59:50 UTC (rev 3010)
@@ -147,7 +147,7 @@
}
/**
- * ON_ACTION :: Handler method for action on editAccount actionLink. The
+ * ON_ACTION :: Callback method for action on editAccount actionLink. The
* accountEdited will be set to the user selected in the Grid with {@code
* login}.
*
@@ -163,7 +163,7 @@
}
/**
- * ON_ACTION :: Handler method for action on deletedAccount actionLink. The
+ * ON_ACTION :: Callback method for action on deletedAccount actionLink. The
* selected login from the Grid will be used to delete the user.
*
* @param login used to delete the user
@@ -174,7 +174,7 @@
}
/**
- * ON_PREPARE_FOR_SUBMIT :: Handler method for prepareSubmit event of the
+ * ON_PREPARE_FOR_SUBMIT :: Callback method for prepareSubmit event of the
* usersForm. The accountEdited will be initialized to properly be saved in
* {@link #onValidateFormFromUsersForm()}
*/
@@ -185,7 +185,7 @@
}
/**
- * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * ON_VALIDATE_FORM :: Callback method for validateForm event of the
* usersForm. The accountEdited will be updated using serviceUser. Errors
* from service will be recorded into the usersForm.
*
@@ -202,7 +202,7 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the usersForm. No error
+ * ON_SUCCESS :: Callback method for success event of the usersForm. No error
* occurs from validation, a message will be displayed to client.
*
* @return the current page to refresh
@@ -213,7 +213,7 @@
}
/**
- * ON_FAILURE :: Handler method for failure event of the usersForm. Errors
+ * ON_FAILURE :: Callback method for failure event of the usersForm. Errors
* were recorded into the usersForm. The usersForm will be refresh to
* display error messages.
*
@@ -243,7 +243,7 @@
private String newPassword;
/**
- * ON_PREPARE :: Handler method for prepare events of the newUserForm. The
+ * ON_PREPARE :: Callback method for prepare events of the newUserForm. The
* newUser will be initialized if needed before render and before submit.
*/
public void onPrepareFromNewUserForm() {
@@ -253,7 +253,7 @@
}
/**
- * ON_VALIDATE_FORM :: Handler method for validateForm event of the
+ * ON_VALIDATE_FORM :: Callback method for validateForm event of the
* newUserForm. The newUser will be created using serviceUser. Errors from
* service will be recorded into the newUserForm. The password will be
* generated if an email is set into the form. Otherwise the password will
@@ -292,7 +292,7 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the newUserForm. No
+ * ON_SUCCESS :: Callback method for success event of the newUserForm. No
* error occurs from validation, success message is displayed to client and
* an email is sent to the newUser created if it's defined. The persist
* fields of the page will be discarded to refresh the grid with no order or
@@ -335,7 +335,7 @@
}
/**
- * ON_FAILURE :: Handler method for failure event of the newUserForm. Errors
+ * ON_FAILURE :: Callback method for failure event of the newUserForm. Errors
* were recorded into the newUserForm. The newUserForm will be refresh to
* display error messages.
*
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-21 11:56:38 UTC (rev 3009)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-21 11:59:50 UTC (rev 3010)
@@ -590,7 +590,7 @@
private ServicePollUri servicePollUri;
/**
- * ON_SELECTED:: Handler method for all submit actions. Will reset refreshing
+ * ON_SELECTED:: Callback method for all submit actions. Will reset refreshing
* zones flags used for subForm components.
*/
@Log
@@ -600,7 +600,7 @@
}
/**
- * ON_SELECTED:: Handler method for action on choiceStep submit button. Will
+ * ON_SELECTED:: Callback method for action on choiceStep submit button. Will
* change the view and display the choice formFragment of the pollForm.
* Note : maybe validations will be needed in this case (use edited flag).
*/
@@ -611,7 +611,7 @@
}
/**
- * ON_SELECTED:: Handler method for action on mainStep submit button. Will
+ * ON_SELECTED:: Callback method for action on mainStep submit button. Will
* change the view and display the main formFragment of the pollForm.
* This is a previous action after being on choices.
*/
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-21 11:56:38 UTC (rev 3009)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-21 11:59:50 UTC (rev 3010)
@@ -149,7 +149,7 @@
}
/**
- * ON_ACTION :: Handler method for action on {@code deleteList} actionLink.
+ * ON_ACTION :: Callback method for action on {@code deleteList} actionLink.
* Check is done using {@link #canDeleteList()}, then the {@code
* serviceFavorite} is called to execute the delete on {@code
* favoriteListSelected}.
1
0
Author: fdesbois
Date: 2010-05-21 13:56:38 +0200 (Fri, 21 May 2010)
New Revision: 3009
Url: http://chorem.org/repositories/revision/pollen/3009
Log:
- Add javadoc
- Change signature of getErrorMessage from PollenManager
- Refactor exceptions managment by ErrorReport in PollFormModel validations
- Extract sendEmail method for creator from onSuccess callback
Modified:
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -282,7 +282,7 @@
feedback.addInfo(messages.get("loginOk"));
} catch (PollenBusinessException eee) {
feedback.addError(
- manager.getErrorMessage(eee, messages, logger));
+ manager.getErrorMessage(logger, messages, eee));
}
}
return this;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -11,6 +11,8 @@
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.service.ServiceFavorite;
import org.chorem.pollen.ui.base.PollenPage;
import org.chorem.pollen.ui.services.PollenManager;
@@ -91,7 +93,7 @@
try {
serviceFavorite.createFavoriteList(newFavoriteList);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
if (logger.isDebugEnabled()) {
logger.debug(message);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -210,8 +210,9 @@
try {
serviceFavorite.updateFavoriteParticipant(participantEdited);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
- participantsForm.recordError(message);
+// String message = manager.getErrorMessage(eee, messages, logger);
+// participantsForm.recordError(message);
+ manager.recordFormError(logger, messages, eee, participantsForm);
}
}
@@ -285,8 +286,9 @@
try {
serviceFavorite.createFavoriteParticipant(newParticipant);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
- addParticipant.recordError(message);
+// String message = manager.getErrorMessage(eee, messages, logger);
+// addParticipant.recordError(message);
+ manager.recordFormError(logger, messages, eee, participantsForm);
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -11,7 +11,7 @@
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.ui.data.ChoiceField;
-import org.chorem.pollen.ui.data.FieldValidationException;
+import org.chorem.pollen.ui.data.ErrorReport;
import org.chorem.pollen.ui.pages.poll.PollForm;
import org.chorem.pollen.ui.services.PollenManager;
import org.chorem.pollen.ui.services.ServiceImage;
@@ -90,11 +90,14 @@
/**
* Initialize the poll using an {@code uid} for an existing poll or the
* current {@code user} connected if he exists as the creator of a new
- * poll.
+ * poll with {@code createMode} flag set.
*
- * @param uid Unique id of an existing poll (can be null for a new poll)
- * @param user Connected user as creator of a new poll (can be null if no
- * user is connected).
+ * @param servicePoll Service used to retrieve an existing poll based on
+ * {@code uid} or instantiate a new one.
+ * @param uid Unique id of an existing poll (can be null for a new
+ * poll)
+ * @param user Connected user as creator of a new poll (can be null
+ * if no user is connected).
*/
public void initPoll(ServicePoll servicePoll, String uid, UserAccount user) {
if (StringUtils.isNotEmpty(uid)) {
@@ -322,7 +325,8 @@
poll = servicePoll.createPoll(poll, getLists());
}
- public void validate(Messages messages) throws FieldValidationException {
+ public ErrorReport validate(Messages messages) {
+ ErrorReport report = new ErrorReport();
// Initialize beginDate if needed
Date beginDate = poll.getBeginDate();
@@ -334,9 +338,11 @@
// Check endDate
Date endDate = poll.getEndDate();
if (endDate != null && endDate.before(beginDate)) {
- throw new FieldValidationException(
- PollForm.FORM_FIELD_END_DATE,
+ report.recordFieldError(PollForm.FORM_FIELD_END_DATE,
"error endDate before beginDate");
+// throw new FieldValidationException(
+// PollForm.FORM_FIELD_END_DATE,
+// "error endDate before beginDate");
}
// Add choices is allowed after creation
@@ -351,23 +357,28 @@
// Check beginChoiceDate
if (endDate != null && beginChoiceDate.after(endDate)) {
- throw new FieldValidationException(
- PollForm.FORM_FIELD_BEGIN_CHOICE_DATE,
+ report.recordFieldError(PollForm.FORM_FIELD_BEGIN_CHOICE_DATE,
"error beginChoiceDate after endDate");
+// throw new FieldValidationException(
+// PollForm.FORM_FIELD_BEGIN_CHOICE_DATE,
+// "error beginChoiceDate after endDate");
}
// Check endChoiceDate
Date endChoiceDate = poll.getEndChoiceDate();
if (endChoiceDate != null && endChoiceDate.before(beginChoiceDate)) {
- throw new FieldValidationException(
- PollForm.FORM_FIELD_END_CHOICE_DATE,
+ report.recordFieldError(PollForm.FORM_FIELD_END_CHOICE_DATE,
"error endChoiceDate before beginChoiceDate");
+// throw new FieldValidationException(
+// PollForm.FORM_FIELD_END_CHOICE_DATE,
+// "error endChoiceDate before beginChoiceDate");
}
}
- // TODO-fdesbois-2010-05-20 : change exceptions by ErrorReport
// validation rules :
// - not allowed to save poll without choice if addChoiceAllowed is false
+
+ return report;
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connection.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -100,9 +100,9 @@
}
} catch (PollenBusinessException eee) {
// TODO two different errors, on password or on login
- //addError(messages.get("loginFailed"));
- String message = manager.getErrorMessage(eee, messages, logger);
- loginForm.recordError(message);
+// String message = manager.getErrorMessage(eee, messages, logger);
+// loginForm.recordError(message);
+ manager.recordFormError(logger, messages, eee, loginForm);
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -195,8 +195,9 @@
try {
serviceUser.updateUser(accountEdited, true);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
- usersForm.recordError(message);
+// String message = manager.getErrorMessage(eee, messages, logger);
+// usersForm.recordError(message);
+ manager.recordFormError(logger, messages, eee, usersForm);
}
}
@@ -279,7 +280,7 @@
serviceUser.createUser(newUser);
addInfo(passwordInfo);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
switch (eee.getType()) {
case USER_EMAIL_EXIST:
newUserForm.recordError(newEmail, message);
@@ -320,7 +321,7 @@
newUser.getLogin(), newUser.getEmail()));
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
addError(message);
addInfo(messages.format(
"pollen.ui.user.create.emailFailedShowPassword",
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -14,6 +14,7 @@
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.corelib.components.Select;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
@@ -39,6 +40,7 @@
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.ChoiceField;
+import org.chorem.pollen.ui.data.ErrorReport;
import org.chorem.pollen.ui.data.FieldValidationException;
import org.chorem.pollen.ui.data.PollUri;
import org.chorem.pollen.ui.models.ParticipantListModel;
@@ -117,6 +119,19 @@
@InjectComponent
private Form mainForm;
+ private enum PollStep {
+ MAIN, CHOICES;
+ }
+
+ /** Current step of the Form */
+ private PollStep step;
+
+ /**
+ * Flag to detect an internal edition in the form. Use when submit
+ * actions are triggered from all buttons except the save one.
+ */
+ private boolean edited;
+
void onActivate(String id) {
pollUID = id;
}
@@ -379,7 +394,7 @@
/** Flag if submit comes from lists edition */
private boolean editLists;
- protected static final String EVENT_UPDATE_POLL_TYPE = "updatePollType";
+ protected static final String EVENT_UPDATE_POLL_TYPE = "updateFromPollType";
/** DATA ** */
@@ -422,7 +437,7 @@
}
@Log
- Object onUpdatePollType(String value) {
+ Object onUpdateFromPollType(String value) {
getModel().setPollType(servicePoll, manager, PollType.valueOf(value));
return refreshListZone();
}
@@ -469,7 +484,7 @@
try {
getModel().setCurrentList(manager, listName);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
listsFeedback.addError(message);
}
}
@@ -495,12 +510,13 @@
return listsZone.getBody();
}
- /** ********************** CHOIX **************************************** */
+ /** ********************** CHOICES ************************************** */
- @Property
- private ChoiceField choice;
+ @Inject
+ private ServiceImage serviceImage;
- private List<ChoiceField> choices;
+ @InjectComponent
+ private Zone choicesZone;
@Inject
private Block choiceText;
@@ -511,30 +527,19 @@
@Inject
private Block choiceImage;
- private boolean refresh;
+ @Property
+ private ChoiceField choice;
+ @Property
+ private boolean refreshChoicesZone;
+
/**
* Get choices from poll if it exists or initialized 4 choices with the
- * default type : TEXT. TODO-fdesbois-2010-05-19 : put this treatment in
- * PollFormModel
+ * default type : TEXT.
*
* @return a list of ChoiceDTO
*/
public List<ChoiceField> getChoices() throws PollenBusinessException {
-// if (choices == null) {
-// choices = new ArrayList<ChoiceField>();
-// if (isCreateMode()) {
-// // Initialized to choice TEXT type
-// for (int i = 0; i < 4; i++) {
-// choices.add(ChoiceField.getChoiceText());
-// }
-// } else {
-// for (Choice current : getPoll().getChoice()) {
-// choices.add(new ChoiceField(getPoll(), current));
-// }
-// }
-// }
-// return choices;
return getModel().getChoices();
}
@@ -549,44 +554,67 @@
}
}
- private enum PollStep {
-
- MAIN, CHOICES;
+ @Log
+ Object onChangeFromChoiceType(String value) {
+ ChoiceType type = ChoiceType.valueOf(value);
+ getPoll().setChoiceType(type);
+ refreshChoicesZone = true;
+ return choicesZone.getBody();
}
- private PollStep step;
+ /** ********************** NAVIGATION/SUBMISSION ************************ */
- private boolean edited;
+ /** Service used to retrieve Field components from their ids */
+ @Inject
+ private ComponentSource componentSource;
- @Property
- private boolean refreshChoicesZone;
+ /** Form fields used for validation */
+ public static final String FORM_FIELD_BEGIN_DATE = "beginDate";
- @InjectComponent
- private Zone choicesZone;
+ public static final String FORM_FIELD_END_DATE = "endDate";
+ public static final String FORM_FIELD_BEGIN_CHOICE_DATE = "beginChoiceDate";
+
+ public static final String FORM_FIELD_END_CHOICE_DATE = "endChoiceDate";
+
+ /** Resulting page after success submission */
+ @InjectPage
+ private PollLinks pollLinks;
+
+ /** Service to send email after success */
@Inject
- private ServiceImage serviceImage;
+ private ServiceEmail serviceEmail;
- @Log
- Object onChangeFromChoiceType(String value) {
- ChoiceType type = ChoiceType.valueOf(value);
- getPoll().setChoiceType(type);
- refreshChoicesZone = true;
- return choicesZone.getBody();
- }
+ /** Service to manage uris used in emails sent */
+ @Inject
+ private ServicePollUri servicePollUri;
+ /**
+ * ON_SELECTED:: Handler method for all submit actions. Will reset refreshing
+ * zones flags used for subForm components.
+ */
@Log
void onSelected() {
refreshListsZone = false;
refreshChoicesZone = false;
}
+ /**
+ * ON_SELECTED:: Handler method for action on choiceStep submit button. Will
+ * change the view and display the choice formFragment of the pollForm.
+ * Note : maybe validations will be needed in this case (use edited flag).
+ */
@Log
void onSelectedFromChoiceStep() {
step = PollStep.CHOICES;
edited = true;
}
+ /**
+ * ON_SELECTED:: Handler method for action on mainStep submit button. Will
+ * change the view and display the main formFragment of the pollForm.
+ * This is a previous action after being on choices.
+ */
@Log
void onSelectedFromMainStep() {
step = PollStep.MAIN;
@@ -601,86 +629,40 @@
return step.equals(PollStep.MAIN);
}
- @Inject
- private ComponentSource componentSource;
-
- public static final String FORM_FIELD_BEGIN_DATE = "beginDate";
-
- public static final String FORM_FIELD_END_DATE = "endDate";
-
- public static final String FORM_FIELD_BEGIN_CHOICE_DATE = "beginChoiceDate";
-
- public static final String FORM_FIELD_END_CHOICE_DATE = "endChoiceDate";
-
@Log
void onValidateForm() {
if (!edited) {
- // Need validations on dates
- try {
- getModel().validate(messages);
- getModel().create(servicePoll, serviceImage);
- } catch (FieldValidationException eee) {
- manager.recordFormError(eee, mainForm, componentSource);
- } catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
- mainForm.recordError(message);
+ // Validate data
+ ErrorReport report = getModel().validate(messages);
+ // Record errors if report is not empty
+ if (report.hasErrors()) {
+ manager.recordFormErrors(componentSource, report, mainForm);
+ } else {
+ // Execute create for business save in database
+ try {
+ getModel().create(servicePoll, serviceImage);
+ } catch (PollenBusinessException eee) {
+ manager.recordFormError(logger, messages, eee, mainForm);
+ }
}
}
}
- @Inject
- private PageRenderLinkSource linkSource;
-
- private Link successLink;
-
- @InjectPage
- private PollLinks pollLinks;
-
- @Inject
- private ServiceEmail serviceEmail;
-
- @Inject
- private ServicePollUri servicePollUri;
-
-// public void prepareSuccessLinks(Poll newPoll) {
-// String creatorUid = newPoll.getCreator().getUid();
-// String pollUid = newPoll.getUid();
-// PollUri uri = servicePollUri.getNewPollUri(creatorUid, pollUid);
-//// successLink = linkSource.createPageRenderLinkWithContext(
-//// PollLinks.class, uri);
-// pollLinks.setPollUri(uri);
-// }
-
@Log
Object onSuccess() {
if (!edited) {
+ pollLinks.addInfo("Sauvegarde OK !");
PollAccount creator = getPoll().getCreator();
PollUri uri = servicePollUri.getNewPollUri(creator.getUid(),
getPoll().getUid());
pollLinks.setPollUri(uri);
- pollLinks.addInfo("Sauvegarde OK !");
+ // Send an email to the creator
if (creator.getEmail() != null) {
- pollLinks.addInfo("Vous avez recu un mail !");
- PollenEmail email = new PollenEmailImpl();
- email.setTo(creator.getEmail());
- email.setSubject(messages.format(
- "pollen.email.createPoll.subject",
- getPoll().getTitle()));
- email.setContent(messages.format(
- "pollen.email.createPoll.content",
- getPoll().getTitle(),
- servicePollUri.getVoteUrl(uri),
- servicePollUri.getModerateVoteUrl(uri),
- servicePollUri.getPollUpdateUrl(uri)));
- try {
- serviceEmail.sendEmail(email);
- } catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
- addError(message);
+ if (!sendCreatorEmail(creator, uri)) {
return mainZone;
}
- } else {
- // TODO-fdesbois-2010-05-20 : display a pretty message for this case : the links page need to be keeped by user
+ } else {
+ pollLinks.addInfo("pollen.ui.poll.links.creatorEmail.notDefined");
}
if (getPoll().getPollType().isRestrictedOrGroup()) {
pollLinks.addInfo("Les votants ont reçu un mail !");
@@ -690,6 +672,29 @@
return mainZone;
}
+ protected boolean sendCreatorEmail(PollAccount creator, PollUri uri) {
+ PollenEmail email = new PollenEmailImpl();
+ email.setTo(creator.getEmail());
+ email.setSubject(messages.format(
+ "pollen.email.createPoll.subject",
+ getPoll().getTitle()));
+ email.setContent(messages.format(
+ "pollen.email.createPoll.content",
+ getPoll().getTitle(),
+ servicePollUri.getVoteUrl(uri),
+ servicePollUri.getModerateVoteUrl(uri),
+ servicePollUri.getPollUpdateUrl(uri)));
+ try {
+ serviceEmail.sendEmail(email);
+ pollLinks.addInfo("pollen.ui.poll.links.creatorEmail.success");
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(logger, messages, eee);
+ addError(message);
+ return false;
+ }
+ return true;
+ }
+
@Log
Object onFailure() {
return mainZone;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -25,6 +25,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.services.PropertyAccess;
import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.service.ServiceFavorite;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -133,10 +133,10 @@
/**
* ON_VALIDATE_FORM :: <br \>
* UI validation : check if the two passwords are equals. <br \>
- * BUSINESS validation : execute {@link ServiceUser#updateUser(UserAccount) }
+ * BUSINESS validation : execute {@link ServiceUser#updateUser(UserAccount,boolean) }
* which throws errors
- * {@link PollenBusinessException.PollenExceptionType.USER_WRONG_PASSWORD}
- * and {@link PollenBusinessException.PollenExceptionType.USER_EMAIL_EXIST}.
+ * {@link PollenBusinessException.PollenExceptionType#USER_WRONG_PASSWORD}
+ * and {@link PollenBusinessException.PollenExceptionType#USER_EMAIL_EXIST}.
*/
@Log
void onValidateFormFromAccountForm() {
@@ -159,7 +159,7 @@
}
serviceUser.updateUser(user, false);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
switch (eee.getType()) {
case USER_WRONG_PASSWORD:
accountForm.recordError(passwordField, message); break;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -132,8 +132,8 @@
* UI validation : check if the two passwords are equals. <br \>
* BUSINESS validation : execute {@link ServiceUser#createUser(UserAccount)}
* which throws errors
- * {@link PollenBusinessException.PollenExceptionType.USER_LOGIN_EXIST}
- * and {@link PollenBusinessException.PollenExceptionType.USER_EMAIL_EXIST}.
+ * {@link PollenBusinessException.PollenExceptionType#USER_LOGIN_EXIST}
+ * and {@link PollenBusinessException.PollenExceptionType#USER_EMAIL_EXIST}.
*/
void onValidateFormFromRegister() {
// Check newPassword that must be equals to passwordVerify
@@ -153,7 +153,7 @@
// Saving new user
serviceUser.createUser(newUser);
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
switch (eee.getType()) {
case USER_EMAIL_EXIST:
register.recordError(emailField, message); break;
@@ -199,7 +199,7 @@
newUser.getEmail()));
} catch (PollenBusinessException eee) {
- String message = manager.getErrorMessage(eee, messages, logger);
+ String message = manager.getErrorMessage(logger, messages, eee);
index.addError(message);
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -24,6 +24,8 @@
import org.apache.tapestry5.Field;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
+import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.ioc.util.CaseInsensitiveMap;
@@ -34,7 +36,6 @@
import org.chorem.pollen.PollenProperty;
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.ui.data.ErrorReport;
-import org.chorem.pollen.ui.data.FieldValidationException;
import org.nuiton.util.ApplicationConfig;
import org.slf4j.Logger;
@@ -44,23 +45,31 @@
import java.util.Properties;
/**
- * WaoManager
+ * This service contains the main {@link PollenContext} for business. This is
+ * the service that start and stop the business part of the application. For
+ * this, PollenManager was registered in Tapestry as a {@link
+ * RegistryShutdownListener} to stop the context and contribute to registry
+ * startup from {@link AppModule#contributeRegistryStartup(OrderedConfiguration,
+ * ServiceUser, PollenManager, RegistryShutdownHub)}. The application {@code
+ * context} was not visible for pages, this service use delegation for needed
+ * methods from {@code context}.
* <p/>
+ * This service is also used to manage errors from {@link
+ * PollenBusinessException} that contains i18n keys for messages. Traductions are
+ * made via Tapestry global catalog messages ({@code app.properties}). But you
+ * need to write messages in {@code resources/i18n/pollen-ui.properties}. A
+ * maven goal is used to merge i18n messages from business (and libs) and ui
+ * into the main Tapestry catalog {@code app.properties}
+ * <p/>
* Created: 24 nov. 2009
*
* @author fdesbois
- * @version $Revision$
- * <p/>
- * Mise a jour: $Date$
- * par : $Author$
+ * @version $Id$
*/
public class PollenManager implements Runnable,
RegistryShutdownListener,
SymbolProvider {
-// private static final Logger logger =
-// LoggerFactory.getLogger(PollenManager.class);
-
private final Map<String, String> propertiesMap =
new CaseInsensitiveMap<String>();
@@ -69,7 +78,8 @@
private ServiceUser serviceUser;
/**
- * Constructor of WaoManager. It needs the WaoContext to start and stop.
+ * Constructor of PollenManager. It needs the PollenContext to start and
+ * stop.
*
* @param context used to manage application lifecycle
*/
@@ -129,8 +139,17 @@
return context.createPollenUrlId();
}
- public String getErrorMessage(PollenBusinessException error,
- Messages messages, Logger logger) {
+ /**
+ * Retrieve an error message from business {@code error} exception. Will
+ * used {@code messages} and {@code logger} services.
+ *
+ * @param logger Service to log error message from business
+ * @param messages Service to retrieve messages from i18n catalog
+ * @param error Exception to treate
+ * @return the error message to display
+ */
+ public String getErrorMessage(Logger logger, Messages messages,
+ PollenBusinessException error) {
if (logger.isDebugEnabled()) {
logger.debug("ERROR from business : " + error.getMessage() +
" _ args = " + Arrays.toString(error.getArgs()));
@@ -144,23 +163,44 @@
return message;
}
- public void recordFormError(FieldValidationException error,
- Form form, ComponentSource componentSource)
- throws ClassCastException {
- if (error.getField() == null) {
- form.recordError(error.getMessage());
- } else {
- Field field = getFieldByName(error.getField(), componentSource);
- form.recordError(field, error.getMessage());
- }
+ /**
+ * Record a business {@code error} exception into a {@code form}. Will used
+ * {@code messages} and {@code logger} services.
+ *
+ * @param logger Service to log error message from business
+ * @param messages Service to retrieve messages from i18n catalog
+ * @param error Exception to treate
+ * @param form Form where error need to be recorded
+ * @see #getErrorMessage(Logger, Messages, PollenBusinessException)
+ */
+ public void recordFormError(Logger logger, Messages messages,
+ PollenBusinessException error,
+ Form form) {
+ String message = getErrorMessage(logger, messages, error);
+ form.recordError(message);
}
- public void recordFormErrors(ErrorReport report,
- Form form, ComponentSource componentSource)
- throws ClassCastException {
+ /**
+ * Record ui errors (from validation) defined in {@code report} into a
+ * {@code form}. Will used {@code componentSource} service.
+ *
+ * @param componentSource Service to retrieve Field components from their
+ * ids
+ * @param report ErrorReport that contains errors
+ * @param form Form where errors need to be recorded
+ * @throws ClassCastException when {@code componentSource} doesn't
+ * find the right component based on field
+ * ids in {@code report}.
+ * @throws IllegalArgumentException when no field component was found based
+ * on field ids in {@code report}.
+ */
+ public void recordFormErrors(ComponentSource componentSource,
+ ErrorReport report,
+ Form form)
+ throws ClassCastException, IllegalArgumentException {
for (Map.Entry<String, String> entry : report.getFieldErrors().entrySet()) {
- Field field = getFieldByName(entry.getKey(), componentSource);
+ Field field = getFieldByName(componentSource, entry.getKey());
form.recordError(field, entry.getValue());
}
for (String message : report.getErrors()) {
@@ -168,9 +208,24 @@
}
}
- protected Field getFieldByName(String field, ComponentSource componentSource)
- throws ClassCastException {
+// public void recordFormError(FieldValidationException error,
+// Form form, ComponentSource componentSource)
+// throws ClassCastException {
+// if (error.getField() == null) {
+// form.recordError(error.getMessage());
+// } else {
+// Field field = getFieldByName(error.getField(), componentSource);
+// form.recordError(field, error.getMessage());
+// }
+// }
+
+ protected Field getFieldByName(ComponentSource componentSource, String field)
+ throws ClassCastException, IllegalArgumentException {
Component component = componentSource.getComponent(field);
+ if (component == null) {
+ throw new IllegalArgumentException("no field component was found" +
+ " with id " + field);
+ }
if (!(component instanceof Field)) {
throw new ClassCastException("invalid cast to Field from : " +
component.getClass().getName());
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -2,34 +2,98 @@
import org.apache.tapestry5.Link;
import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.PollUri;
-import org.chorem.pollen.ui.pages.poll.PollForm;
-import org.chorem.pollen.ui.pages.poll.VoteForPoll;
/**
+ * Service used to manage PollUri in application. The contextPath is needed to
+ * retrieve proper urls from uri, but to retrieve Tapestry links, only {@link
+ * PageRenderLinkSource} service is used. The links will be used in Tapestry
+ * templates, and full urls will be used for emails.
+ * <p/>
* Created: 20 mai 2010
*
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
+ * @see PollUri
+ * @see ServicePollUriImpl
*/
public interface ServicePollUri {
+ /**
+ * Retrieve link for poll update page.
+ *
+ * @param uri PollUri that contains pollUid and creatorUid
+ * @return the Link to used for poll update page
+ */
Link getPollUpdateLink(PollUri uri);
+ /**
+ * Retrieve link for vote page.
+ *
+ * @param uri PollUri that contains pollUid (accountUid is not necessary)
+ * @return the Link to used for vote page
+ */
Link getVoteLink(PollUri uri);
+ /**
+ * Retrieve link for moderation on vote page.
+ *
+ * @param uri PollUri that contains pollUid and creatorUid (moderator)
+ * @return the Link to used for moderation on vote page
+ */
Link getModerateVoteLink(PollUri uri);
+ /**
+ * Retrieve url for poll update page.
+ *
+ * @param uri PollUri that contains pollUid and creatorUid
+ * @return the full url to used for poll update page
+ */
String getPollUpdateUrl(PollUri uri);
+ /**
+ * Retrieve url for vote page.
+ *
+ * @param uri PollUri that contains pollUid (accountUid is not necessary)
+ * @return the full url to used for vote page
+ */
String getVoteUrl(PollUri uri);
+ /**
+ * Retrieve url for moderation on vote page.
+ *
+ * @param uri PollUri that contains pollUid and creatorUid (moderator)
+ * @return the full url to used for moderation on vote page
+ */
String getModerateVoteUrl(PollUri uri);
+ /**
+ * Retrieve a new instance of PollUri with {@code accountUid} and {@code
+ * pollUid} initialized.
+ *
+ * @param accountUid Unique id of the account for the uri
+ * @param pollUid Unique id of the poll for the uri
+ * @return a new PollUri
+ */
PollUri getNewPollUri(String accountUid, String pollUid);
+ /**
+ * Retrieve a new instance of PollUri based on string {@code uri} that
+ * contains both account and poll uid necessary.
+ *
+ * @param uri Full uri as a String
+ * @return a new PollUri
+ */
PollUri getNewPollUri(String uri);
+ /**
+ * Injector for contextPath used for urls. This method need to be called
+ * before retrieving urls. The {@link Border} layout will do this job on
+ * page render.
+ *
+ * @param contextPath Context path of the current server
+ */
void setContextPath(String contextPath);
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java 2010-05-21 11:56:38 UTC (rev 3009)
@@ -14,10 +14,17 @@
*/
public class ServicePollUriImpl implements ServicePollUri {
+ /** Service used to create links */
private PageRenderLinkSource linkSource;
+ /** Context path of the current server used to create urls */
private String contextPath;
+ /**
+ * Constructor of ServicePollUriImpl.
+ *
+ * @param linkSource Service used to create links.
+ */
public ServicePollUriImpl(PageRenderLinkSource linkSource) {
this.linkSource = linkSource;
}
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-20 17:54:37 UTC (rev 3008)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-21 11:56:38 UTC (rev 3009)
@@ -76,6 +76,8 @@
pollen.ui.poll.links.editPage=Lien d'acc\u00e8s \u00e0 la modification du sondage :
pollen.ui.poll.links.register=Si vous \u00eates un utilisateur identifi\u00e9, vous pouvez retrouver ces liens dans la page
pollen.ui.poll.links.myPolls=Mes sondages
+pollen.ui.poll.links.creatorEmail.success=Un email vous a \u00e9t\u00e9 envoy\u00e9 avec les liens ci-dessous.
+pollen.ui.poll.links.creatorEmail.notDefined=Aucun email n'a \u00e9t\u00e9 d\u00e9fini \u00e0 la cr\u00e9ation du sondage, vous devriez enregistrer cette page dans vos favoris pour ne pas perdre les liens.
# OLD LOGIN_COMPONENT
1
0
r3008 - in trunk/pollen-ui/src/main: java/org/chorem/pollen/ui/components java/org/chorem/pollen/ui/models java/org/chorem/pollen/ui/pages/poll resources/org/chorem/pollen/ui/components
by fdesbois@users.chorem.org 20 May '10
by fdesbois@users.chorem.org 20 May '10
20 May '10
Author: fdesbois
Date: 2010-05-20 19:54:37 +0200 (Thu, 20 May 2010)
New Revision: 3008
Url: http://chorem.org/repositories/revision/pollen/3008
Log:
- Add some notes
- Change restriction for email on UserLists -> email is required. It's pretty tricky to check if user has email on poll creation (what can we do about accountUid on each participant ?)
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-20 17:36:51 UTC (rev 3007)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-20 17:54:37 UTC (rev 3008)
@@ -182,7 +182,7 @@
} else {
logo = "pollen" + pageLogo + "_en.png";
}
-
+ // Initialize contextPath for servicePollUri
servicePollUri.setContextPath(getServerPath());
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-20 17:36:51 UTC (rev 3007)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-20 17:54:37 UTC (rev 3008)
@@ -364,6 +364,10 @@
"error endChoiceDate before beginChoiceDate");
}
}
+
+ // TODO-fdesbois-2010-05-20 : change exceptions by ErrorReport
+ // validation rules :
+ // - not allowed to save poll without choice if addChoiceAllowed is false
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 17:36:51 UTC (rev 3007)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 17:54:37 UTC (rev 3008)
@@ -679,6 +679,8 @@
addError(message);
return mainZone;
}
+ } else {
+ // TODO-fdesbois-2010-05-20 : display a pretty message for this case : the links page need to be keeped by user
}
if (getPoll().getPollType().isRestrictedOrGroup()) {
pollLinks.addInfo("Les votants ont reçu un mail !");
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-05-20 17:36:51 UTC (rev 3007)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-05-20 17:54:37 UTC (rev 3008)
@@ -26,7 +26,7 @@
</p:nameCell>
<p:emailCell>
<t:if t:test="editionMode">
- <input t:type="textfield" t:id="editEmail" value="participantEdited.email" t:validate="regexp" size="15" />
+ <input t:type="textfield" t:id="editEmail" value="participantEdited.email" t:validate="required,regexp" size="15" />
<p:else>${participant.email}</p:else>
</t:if>
</p:emailCell>
1
0
r3007 - in trunk/pollen-ui/src/main: java/org/chorem/pollen/ui/base java/org/chorem/pollen/ui/components java/org/chorem/pollen/ui/data java/org/chorem/pollen/ui/pages/poll java/org/chorem/pollen/ui/services resources/i18n
by fdesbois@users.chorem.org 20 May '10
by fdesbois@users.chorem.org 20 May '10
20 May '10
Author: fdesbois
Date: 2010-05-20 19:36:51 +0200 (Thu, 20 May 2010)
New Revision: 3007
Url: http://chorem.org/repositories/revision/pollen/3007
Log:
Create service to manage PollUri
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -4,6 +4,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.ui.components.Border;
+import org.chorem.pollen.ui.services.ServicePollUri;
import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -41,6 +41,7 @@
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.pages.Index;
import org.chorem.pollen.ui.services.PollenManager;
+import org.chorem.pollen.ui.services.ServicePollUri;
import org.nuiton.web.tapestry5.components.FeedBack;
import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
@@ -58,6 +59,9 @@
@Inject
private Logger logger;
+ @Inject
+ private ServicePollUri servicePollUri;
+
/**
* Chaine définissant le style de la page
*/
@@ -178,6 +182,8 @@
} else {
logo = "pollen" + pageLogo + "_en.png";
}
+
+ servicePollUri.setContextPath(getServerPath());
}
boolean afterRender() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -20,7 +20,7 @@
protected String accountUid;
- protected PollUri() {
+ public PollUri() {
}
@@ -32,23 +32,14 @@
// }
// }
- public static PollUri newUri(String stringUri) {
- PollUri uri = new PollUri();
+ public void setUri(String stringUri) {
String[] tab = stringUri.split(SEPARATOR);
- uri.setPollUid(tab[0]);
+ setPollUid(tab[0]);
if (tab.length == 2) {
- uri.setAccountUid(tab[1]);
+ setAccountUid(tab[1]);
}
- return uri;
}
- public static PollUri newUri(String accountUid, String pollUid) {
- PollUri uri = new PollUri();
- uri.setAccountUid(accountUid);
- uri.setPollUid(pollUid);
- return uri;
- }
-
public String getAccountUid() {
return accountUid;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -21,6 +21,8 @@
import org.apache.tapestry5.services.ComponentSource;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.bean.PollenEmail;
+import org.chorem.pollen.bean.PollenEmailImpl;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
@@ -31,6 +33,7 @@
import org.chorem.pollen.entity.PreventRule;
import org.chorem.pollen.entity.PreventRuleImpl;
import org.chorem.pollen.mail.PreventRuleManager;
+import org.chorem.pollen.service.ServiceEmail;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
@@ -42,6 +45,7 @@
import org.chorem.pollen.ui.models.PollFormModel;
import org.chorem.pollen.ui.services.PollenManager;
import org.chorem.pollen.ui.services.ServiceImage;
+import org.chorem.pollen.ui.services.ServicePollUri;
import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
@@ -632,23 +636,49 @@
@InjectPage
private PollLinks pollLinks;
- public void prepareSuccessLinks(Poll newPoll) {
- String creatorUid = newPoll.getCreator().getUid();
- String pollUid = newPoll.getUid();
- PollUri uri = PollUri.newUri(creatorUid, pollUid);
-// successLink = linkSource.createPageRenderLinkWithContext(
-// PollLinks.class, uri);
- pollLinks.setPollUri(uri);
- }
+ @Inject
+ private ServiceEmail serviceEmail;
+ @Inject
+ private ServicePollUri servicePollUri;
+
+// public void prepareSuccessLinks(Poll newPoll) {
+// String creatorUid = newPoll.getCreator().getUid();
+// String pollUid = newPoll.getUid();
+// PollUri uri = servicePollUri.getNewPollUri(creatorUid, pollUid);
+//// successLink = linkSource.createPageRenderLinkWithContext(
+//// PollLinks.class, uri);
+// pollLinks.setPollUri(uri);
+// }
+
@Log
Object onSuccess() {
if (!edited) {
PollAccount creator = getPoll().getCreator();
- PollUri uri = PollUri.newUri(creator.getUid(), getPoll().getUid());
+ PollUri uri = servicePollUri.getNewPollUri(creator.getUid(),
+ getPoll().getUid());
+ pollLinks.setPollUri(uri);
pollLinks.addInfo("Sauvegarde OK !");
if (creator.getEmail() != null) {
- pollLinks.addInfo("Vous avez recu un mail !");
+ pollLinks.addInfo("Vous avez recu un mail !");
+ PollenEmail email = new PollenEmailImpl();
+ email.setTo(creator.getEmail());
+ email.setSubject(messages.format(
+ "pollen.email.createPoll.subject",
+ getPoll().getTitle()));
+ email.setContent(messages.format(
+ "pollen.email.createPoll.content",
+ getPoll().getTitle(),
+ servicePollUri.getVoteUrl(uri),
+ servicePollUri.getModerateVoteUrl(uri),
+ servicePollUri.getPollUpdateUrl(uri)));
+ try {
+ serviceEmail.sendEmail(email);
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(eee, messages, logger);
+ addError(message);
+ return mainZone;
+ }
}
if (getPoll().getPollType().isRestrictedOrGroup()) {
pollLinks.addInfo("Les votants ont reçu un mail !");
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -10,6 +10,7 @@
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.PollUri;
+import org.chorem.pollen.ui.services.ServicePollUri;
import org.slf4j.Logger;
/**
@@ -45,7 +46,7 @@
}
@Inject
- private PageRenderLinkSource linkSource;
+ private ServicePollUri servicePollUri;
private Poll poll;
@@ -83,23 +84,16 @@
return poll;
}
- public Link getPollLink() {
- Link link = linkSource.createPageRenderLinkWithContext(
- PollForm.class, pollUri);
- return link;
- }
-
public Link getVoteLink() {
- PollUri voteUri = PollUri.newUri(null, pollUri.getPollUid());
- Link link = linkSource.createPageRenderLinkWithContext(
- VoteForPoll.class, voteUri);
- return link;
+ return servicePollUri.getVoteLink(pollUri);
}
public Link getModerateVoteLink() {
- Link link = linkSource.createPageRenderLinkWithContext(
- VoteForPoll.class, pollUri);
- return link;
+ return servicePollUri.getModerateVoteLink(pollUri);
}
+ public Link getPollLink() {
+ return servicePollUri.getPollUpdateLink(pollUri);
+ }
+
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -29,6 +29,7 @@
import org.apache.tapestry5.services.ApplicationStateCreator;
import org.apache.tapestry5.services.ApplicationStateManager;
import org.apache.tapestry5.services.ComponentRequestFilter;
+import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.entity.UserAccount;
@@ -97,6 +98,11 @@
return new ServiceImageImpl(manager.getContext());
}
+ public static ServicePollUri buildServicePollUri(
+ PageRenderLinkSource linkSource) {
+ return new ServicePollUriImpl(linkSource);
+ }
+
public ServiceAuthentication<UserAccount> buildServiceAuthentication(
ApplicationStateManager stateManager) {
ServiceAuthentication<UserAccount> instance =
@@ -187,7 +193,9 @@
@Override
public PollUri coerce(String input) {
- return PollUri.newUri(input);
+ PollUri uri = new PollUri();
+ uri.setUri(input);
+ return uri;
}
};
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -0,0 +1,35 @@
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.chorem.pollen.ui.data.PollUri;
+import org.chorem.pollen.ui.pages.poll.PollForm;
+import org.chorem.pollen.ui.pages.poll.VoteForPoll;
+
+/**
+ * Created: 20 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public interface ServicePollUri {
+
+ Link getPollUpdateLink(PollUri uri);
+
+ Link getVoteLink(PollUri uri);
+
+ Link getModerateVoteLink(PollUri uri);
+
+ String getPollUpdateUrl(PollUri uri);
+
+ String getVoteUrl(PollUri uri);
+
+ String getModerateVoteUrl(PollUri uri);
+
+ PollUri getNewPollUri(String accountUid, String pollUid);
+
+ PollUri getNewPollUri(String uri);
+
+ void setContextPath(String contextPath);
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUri.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java 2010-05-20 17:36:51 UTC (rev 3007)
@@ -0,0 +1,82 @@
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.chorem.pollen.ui.data.PollUri;
+import org.chorem.pollen.ui.pages.poll.PollForm;
+import org.chorem.pollen.ui.pages.poll.VoteForPoll;
+
+/**
+ * Created: 20 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ServicePollUriImpl implements ServicePollUri {
+
+ private PageRenderLinkSource linkSource;
+
+ private String contextPath;
+
+ public ServicePollUriImpl(PageRenderLinkSource linkSource) {
+ this.linkSource = linkSource;
+ }
+
+ @Override
+ public Link getPollUpdateLink(PollUri uri) {
+ Link link = linkSource.createPageRenderLinkWithContext(
+ PollForm.class, uri);
+ return link;
+ }
+
+ @Override
+ public Link getVoteLink(PollUri uri) {
+ PollUri voteUri = getNewPollUri(null, uri.getPollUid());
+ Link link = linkSource.createPageRenderLinkWithContext(
+ VoteForPoll.class, voteUri);
+ return link;
+ }
+
+ @Override
+ public Link getModerateVoteLink(PollUri uri) {
+ Link link = linkSource.createPageRenderLinkWithContext(
+ VoteForPoll.class, uri);
+ return link;
+ }
+
+ @Override
+ public String getPollUpdateUrl(PollUri uri) {
+ return contextPath + getPollUpdateLink(uri);
+ }
+
+ @Override
+ public String getVoteUrl(PollUri uri) {
+ return contextPath + getVoteLink(uri);
+ }
+
+ @Override
+ public String getModerateVoteUrl(PollUri uri) {
+ return contextPath + getModerateVoteLink(uri);
+ }
+
+ @Override
+ public PollUri getNewPollUri(String accountUid, String pollUid) {
+ PollUri pollUri = new PollUri();
+ pollUri.setAccountUid(accountUid);
+ pollUri.setPollUid(pollUid);
+ return pollUri;
+ }
+
+ @Override
+ public PollUri getNewPollUri(String uri) {
+ PollUri pollUri = new PollUri();
+ pollUri.setUri(uri);
+ return pollUri;
+ }
+
+ @Override
+ public void setContextPath(String contextPath) {
+ this.contextPath = contextPath;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServicePollUriImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-20 16:50:54 UTC (rev 3006)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-20 17:36:51 UTC (rev 3007)
@@ -6,6 +6,8 @@
############################ EMAIL #############################################
pollen.email.userRegister.subject=[Pollen] Confirmation de cr\u00e9ation du compte %s
pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de cr\u00e9er un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant : %2$s\nMot de passe : %3$s\n\nVous pouvez d\u00e8s maintenant g\u00e9rer vos sondages en vous identifiant sur le site : \n%4$s
+pollen.email.createPoll.subject=[Pollen] Cr\u00e9ation d'un sondage (%1$s)
+pollen.email.createPoll.content=Vous venez de cr\u00e9er le sondage "%1$s".\nVous pouvez y acc\u00e9der en suivant les liens ci-dessous.\n\nPage de vote : \n%2$s\nMod\u00e9ration des votes : \n%3$s\nPage de modification : \n%4$s
############################ GLOBAL ############################################
pollen.ui.tooltip.help=Aide
@@ -33,7 +35,8 @@
pollen.ui.user.update.cancel=Annuler les changements
pollen.ui.user.delete=Supprimer cet utilisateur
pollen.ui.user.delete.confirmMessage=Etes-vous s\u00fbr de vouloir d\u00e9finitivement supprimer cet utilisateur ?
-############################ USER ##############################################
+
+############################ LIST ##############################################
pollen.ui.list.create.title=Cr\u00e9er une nouvelle liste
pollen.ui.list.create.success=La liste %1$s a \u00e9t\u00e9 cr\u00e9\u00e9e avec succ\u00e8s.
pollen.ui.list.create.weightHelp=Ce chiffre correspond au poids du vote de la personne, c'est \u00e0 dire le nombre de voix que poss\u00e8de la personne dans le sondage.
@@ -58,7 +61,10 @@
pollen.ui.participant.weight-label=Poids
pollen.ui.participant.add=Nouveau participant
+############################ POLL ##############################################
pollen.ui.poll.form.confirmlistChange=Des changements ont \u00e9t\u00e9 effectu\u00e9s sur la/les liste(s), un changement de restriction supprimera les modifications. Voulez-vous continuer ?
+
+
pollen.ui.poll.links.pollName=%1$s par %2$s
pollen.ui.poll.links.uriNotDefined=Page inaccessible sans identifiant du sondage dans l'url !
pollen.ui.poll.links.notAllowed=L'url est incorrect, vous n'\u00eates pas autoris\u00e9 \u00e0 acc\u00e9der aux liens du sondage.
1
0
Author: fdesbois
Date: 2010-05-20 18:50:54 +0200 (Thu, 20 May 2010)
New Revision: 3006
Url: http://chorem.org/repositories/revision/pollen/3006
Log:
- Add PageLinks
- Evo #196 : add link for moderation without user account
- Improve QueryBuilder
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
trunk/pollen-ui/src/main/webapp/poll/PollLinks.tml
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml
trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContext.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -4,6 +4,8 @@
import org.chorem.pollen.service.ServiceUser;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.util.ApplicationConfig;
@@ -121,5 +123,7 @@
*/
void closeTransaction(TopiaContext transaction);
+ PollenQueryBuilder newQueryBuilder(TopiaQuery query);
+
} //PollenContext
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -13,6 +13,8 @@
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import static org.nuiton.i18n.I18n._;
@@ -388,4 +390,13 @@
return null;
}
+ @Override
+ public PollenQueryBuilder newQueryBuilder(TopiaQuery query) {
+ PollenQueryBuilder builder = new PollenQueryBuilder();
+ if (query != null) {
+ builder.setQuery(query);
+ }
+ return builder;
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -4,6 +4,7 @@
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.PollAccount;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaDAO;
@@ -20,14 +21,10 @@
*/
public class PollenQueryBuilder extends TopiaQueryBuilder {
- public PollenQueryBuilder() {
+ protected PollenQueryBuilder() {
super();
}
- public PollenQueryBuilder(TopiaDAO<?> dao) {
- super(dao);
- }
-
public EntityQueryProperty getFavoriteListProperty(String alias) {
return getEntityProperty(FavoriteList.class, alias);
}
@@ -37,6 +34,11 @@
return getEntityProperty(FavoriteParticipant.class, alias);
}
+ public EntityQueryProperty getPollCreatorProperty(
+ String alias) {
+ return getEntityProperty(PollAccount.class, alias);
+ }
+
public TopiaQuery createQueryFindFavoriteParticipantsByFavoriteList(
Filter filter) {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -20,9 +20,7 @@
* </ul>
* <br />
* To use directly {@code prepare} methods, you have to set the query using
- * {@link #setQuery(TopiaQuery)} or instantiate the builder with the entity
- * dao using {@link #TopiaQueryBuilder(TopiaDAO)}, this will create a new query
- * from dao.
+ * {@link #setQuery(TopiaQuery)}.
*
* Created: 28 avr. 2010
*
@@ -34,33 +32,13 @@
protected TopiaQuery query;
- public TopiaQueryBuilder() {
+ protected TopiaQueryBuilder() {
}
- /**
- * This will create a new TopiaQuery from the {@code dao} in argument.
- *
- * @param dao used to create a new TopiaQuery in the builder
- */
- public TopiaQueryBuilder(TopiaDAO<?> dao) {
- setQuery(dao.createQuery());
- }
-
public static TopiaQueryBuilder newInstance() {
return new TopiaQueryBuilder();
}
- /**
- * This will create a new TopiaQueryBuilder with a new TopiaQuery from
- * the {@code dao} in argument.
- *
- * @param dao used to create a new TopiaQuery in the builder
- * @return a new instance of TopiaQueryBuilder
- */
- public static TopiaQueryBuilder newInstance(TopiaDAO<?> dao) {
- return new TopiaQueryBuilder(dao);
- }
-
public void setQuery(TopiaQuery query) {
this.query = query;
}
@@ -90,7 +68,7 @@
* @param element
* @param collection
* @return the TopiaQuery created
- * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid)
+ * @see #prepareQuery(Filter, EntityQueryProperty)
*/
public TopiaQuery createQueryFindElementsByCollection(
EntityQueryProperty element,
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -244,7 +244,7 @@
protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants(
TopiaContext transaction, Filter filter) throws TopiaException {
- PollenQueryBuilder builder = new PollenQueryBuilder();
+ PollenQueryBuilder builder = context.newQueryBuilder(null);
TopiaQuery query =
builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
@@ -268,7 +268,7 @@
protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
Filter filter) throws TopiaException {
- PollenQueryBuilder builder = new PollenQueryBuilder();
+ PollenQueryBuilder builder = context.newQueryBuilder(null);
TopiaQuery query =
builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -1,11 +1,14 @@
package org.chorem.pollen.service;
import org.apache.commons.collections.CollectionUtils;
+import org.chorem.pollen.EntityQueryProperty;
import org.chorem.pollen.PollenBinderHelper;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
+import org.chorem.pollen.PollenQueryBuilder;
+import org.chorem.pollen.TopiaQueryBuilder;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.ChoiceDAO;
@@ -21,6 +24,7 @@
import org.chorem.pollen.entity.UserAccount;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
import java.util.ArrayList;
import java.util.Collection;
@@ -86,7 +90,7 @@
}
@Override
- protected void executeCreatePoll(TopiaContext transaction,
+ protected Poll executeCreatePoll(TopiaContext transaction,
List<Object> errorArgs, Poll poll, Collection<ParticipantList> lists)
throws TopiaException,
IllegalArgumentException,
@@ -122,6 +126,8 @@
dao.update(newPoll);
transaction.commitTransaction();
+
+ return newPoll;
}
protected Poll createBasicPoll(TopiaContext transaction, Poll source)
@@ -339,4 +345,51 @@
return participant;
}
+ @Override
+ protected boolean executeCanAdminPoll(TopiaContext transaction,
+ String accountUid, String pollUid)
+ throws TopiaException {
+
+ PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
+
+ // No need alias managment so, no need of queryBuilder
+// PollenQueryBuilder builder = context.newQueryBuilder(dao);
+//
+// EntityQueryProperty creatorProperty =
+// builder.getPollCreatorProperty(Poll.CREATOR);
+//
+// int count = builder.getQuery().
+// add(Poll.UID, pollUid).
+// add(creatorProperty.nameProperty(PollAccount.UID), accountUid).
+// executeCount();
+
+ String creatorUidProperty =
+ TopiaQuery.getProperty(Poll.CREATOR, PollAccount.UID);
+
+ int count = dao.createQuery().
+ add(Poll.UID, pollUid).
+ add(creatorUidProperty, accountUid).
+ executeCount();
+
+ // Note a boolean admin exist in PollAccount, maybe
+ // find the account in lists
+
+ return count > 0;
+ }
+
+ @Override
+ protected Poll executeGetPoll(TopiaContext transaction,
+ String pollUid, String... properties)
+ throws TopiaException {
+
+ PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
+
+ TopiaQuery query = dao.createQuery().
+ add(Poll.UID, pollUid).
+ addLoad(properties);
+
+ Poll result = dao.findByQuery(query);
+ return result;
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -268,11 +268,11 @@
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
- TopiaQueryBuilder builder = new TopiaQueryBuilder(dao);
- builder.prepareQuery(filter);
+ TopiaQuery query = dao.createQuery();
+ context.newQueryBuilder(query).prepareQuery(filter);
Map<String, UserAccount> results = dao.findAllMappedByQuery(
- builder.getQuery(), UserAccount.LOGIN, String.class);
+ query, UserAccount.LOGIN, String.class);
return results;
}
@@ -282,10 +282,10 @@
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
- TopiaQueryBuilder builder = new TopiaQueryBuilder(dao);
- builder.prepareQuery(filter);
+ TopiaQuery query = dao.createQuery();
+ context.newQueryBuilder(query).prepareQuery(filter);
- int result = builder.getQuery().executeCount();
+ int result = query.executeCount();
return result;
}
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-20 16:50:54 UTC (rev 3006)
@@ -22,6 +22,7 @@
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.serviceMail.sendEmail=
pollen.error.servicePoll.addComment=
+pollen.error.servicePoll.canAdminPoll=
pollen.error.servicePoll.createChoice=
pollen.error.servicePoll.createPoll=
pollen.error.servicePoll.createUpdateVote=
@@ -40,7 +41,7 @@
pollen.error.servicePoll.getPollForUpdate=
pollen.error.servicePoll.getPollForVote=
pollen.error.servicePoll.getPollsByUser=
-pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUId \= %1$s and poll with uid \= %2$s
+pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUid \= %1$s and poll with uid \= %2$s
pollen.error.servicePoll.getRunningPolls=
pollen.error.servicePoll.getVotes=
pollen.error.servicePoll.savePoll=
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-20 16:50:54 UTC (rev 3006)
@@ -22,6 +22,7 @@
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.serviceMail.sendEmail=Erreur lors de l'envoi de l'email sur le serveur %1$s\:%2$d pour %3$s de la part de %4$s
pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire cr\u00E9\u00E9 par %1$s pour le sondage %2$s (%3$s)
+pollen.error.servicePoll.canAdminPoll=
pollen.error.servicePoll.createChoice=
pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s cr\u00E9\u00E9 par %2$s
pollen.error.servicePoll.createUpdateVote=
@@ -39,7 +40,7 @@
pollen.error.servicePoll.getPollForUpdate=
pollen.error.servicePoll.getPollForVote=
pollen.error.servicePoll.getPollsByUser=
-pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUId \= %1$s and poll with uid \= %2$s
+pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUid \= %1$s and poll with uid \= %2$s
pollen.error.servicePoll.getRunningPolls=
pollen.error.servicePoll.getVotes=
pollen.error.servicePoll.savePoll=
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollsPage.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -113,7 +113,7 @@
// public String getAdminId() {
// PollAccount creator = servicePollAccount.findPollAccountById(poll
// .getCreatorId());
-// return poll.getPollUId() + ":" + creator.getAccountUId();
+// return poll.getPollUid() + ":" + creator.getAccountUid();
// }
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -1,8 +1,6 @@
package org.chorem.pollen.ui.data;
-import org.apache.tapestry5.ValueEncoder;
-
/**
* PollUri
*
@@ -18,30 +16,59 @@
private static final String SEPARATOR = ":";
- protected String pollUId;
+ protected String pollUid;
- protected String accountUId;
+ protected String accountUid;
- public PollUri(String uri) {
- String[] tab = uri.split(SEPARATOR);
- pollUId = tab[0];
+ protected PollUri() {
+
+ }
+
+// public PollUri(String uri) {
+// String[] tab = uri.split(SEPARATOR);
+// pollUid = tab[0];
+// if (tab.length == 2) {
+// accountUid = tab[1];
+// }
+// }
+
+ public static PollUri newUri(String stringUri) {
+ PollUri uri = new PollUri();
+ String[] tab = stringUri.split(SEPARATOR);
+ uri.setPollUid(tab[0]);
if (tab.length == 2) {
- accountUId = tab[1];
+ uri.setAccountUid(tab[1]);
}
+ return uri;
}
- public String getAccountUId() {
- return accountUId;
+ public static PollUri newUri(String accountUid, String pollUid) {
+ PollUri uri = new PollUri();
+ uri.setAccountUid(accountUid);
+ uri.setPollUid(pollUid);
+ return uri;
}
- public String getPollUId() {
- return pollUId;
+ public String getAccountUid() {
+ return accountUid;
}
+ public void setAccountUid(String accountUid) {
+ this.accountUid = accountUid;
+ }
+
+ public String getPollUid() {
+ return pollUid;
+ }
+
+ public void setPollUid(String pollUid) {
+ this.pollUid = pollUid;
+ }
+
public String getUri() {
- String uri = getPollUId();
- if (getAccountUId() != null) {
- uri += SEPARATOR + getAccountUId();
+ String uri = getPollUid();
+ if (getAccountUid() != null) {
+ uri += SEPARATOR + getAccountUid();
}
return uri;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -101,7 +101,7 @@
if (logger.isDebugEnabled()) {
logger.debug("Get existing poll with pollUID = " + uid);
}
- poll = servicePoll.getPollForUpdate(uid);
+ poll = servicePoll.getPoll(uid, Poll.CHOICE, Poll.POLL_ACCOUNT);
// TODO : init advancedOptions
// TODO-fdesbois-2010-05-19 : exception need to be throw if uid not correspond to an existing poll
} else {
@@ -319,7 +319,7 @@
choiceField.saveName(serviceImage);
poll.addChoice(choiceField.getChoice());
}
- servicePoll.createPoll(poll, getLists());
+ poll = servicePoll.createPoll(poll, getLists());
}
public void validate(Messages messages) throws FieldValidationException {
@@ -366,13 +366,6 @@
}
}
- public Date getBeginDate() {
- if (poll.getBeginDate() == null) {
- poll.setBeginDate(new Date());
- }
- return poll.getBeginDate();
- }
-
/**
* ValueEncoder toClient is used to convert {@code value} to the list name.
*
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -9,6 +9,7 @@
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
@@ -18,6 +19,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
@@ -25,6 +27,7 @@
import org.chorem.pollen.entity.Participant;
import org.chorem.pollen.entity.ParticipantList;
import org.chorem.pollen.entity.Poll;
+import org.chorem.pollen.entity.PollAccount;
import org.chorem.pollen.entity.PreventRule;
import org.chorem.pollen.entity.PreventRuleImpl;
import org.chorem.pollen.mail.PreventRuleManager;
@@ -34,6 +37,7 @@
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.ChoiceField;
import org.chorem.pollen.ui.data.FieldValidationException;
+import org.chorem.pollen.ui.data.PollUri;
import org.chorem.pollen.ui.models.ParticipantListModel;
import org.chorem.pollen.ui.models.PollFormModel;
import org.chorem.pollen.ui.services.PollenManager;
@@ -80,9 +84,6 @@
@InjectComponent
private Zone mainZone;
- @Inject
- private Logger logger;
-
@Override
public Border getBorder() {
return border;
@@ -90,7 +91,7 @@
/** Services injected */
@Inject
- private Logger log;
+ private Logger logger;
@Inject
private Messages messages;
@@ -125,6 +126,7 @@
initOptions();
listsFeedback.clearErrors();
step = PollStep.MAIN;
+ mainForm.clearErrors();
}
/**
@@ -148,8 +150,8 @@
*/
public PollFormModel getModel() {
if (model == null) {
- if (log.isDebugEnabled()) {
- log.debug("-------- NEW POLL FORM MODEL --------");
+ if (logger.isDebugEnabled()) {
+ logger.debug("-------- NEW POLL FORM MODEL --------");
}
model = new PollFormModel();
model.initPoll(servicePoll, pollUID, getUserConnected());
@@ -211,8 +213,8 @@
@Log
void onPrepareForRender() {
String formId = mainForm.getClientId();
- if (log.isDebugEnabled()) {
- log.debug("form id : " + formId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("form id : " + formId);
}
if (formId != null) {
// Script for form interactions : see "webapp/js/pollForm.js"
@@ -387,8 +389,8 @@
public ParticipantList getListSelected() {
ParticipantList result = getModel().getCurrentList();
- if (log.isDebugEnabled() && result != null) {
- log.debug("List selected : " + result.getName());
+ if (logger.isDebugEnabled() && result != null) {
+ logger.debug("List selected : " + result.getName());
}
return result;
}
@@ -410,7 +412,7 @@
// A dialog box will appeared for user confirmation on changing poll
// type with data unsaved.
json.put("confirm",
- messages.get("pollen.ui.poll.listChanged.confirmMessage"));
+ messages.get("pollen.ui.poll.form.confirmlistChange"));
}
return json;
}
@@ -622,10 +624,44 @@
}
}
+ @Inject
+ private PageRenderLinkSource linkSource;
+
+ private Link successLink;
+
+ @InjectPage
+ private PollLinks pollLinks;
+
+ public void prepareSuccessLinks(Poll newPoll) {
+ String creatorUid = newPoll.getCreator().getUid();
+ String pollUid = newPoll.getUid();
+ PollUri uri = PollUri.newUri(creatorUid, pollUid);
+// successLink = linkSource.createPageRenderLinkWithContext(
+// PollLinks.class, uri);
+ pollLinks.setPollUri(uri);
+ }
+
@Log
Object onSuccess() {
+ if (!edited) {
+ PollAccount creator = getPoll().getCreator();
+ PollUri uri = PollUri.newUri(creator.getUid(), getPoll().getUid());
+ pollLinks.addInfo("Sauvegarde OK !");
+ if (creator.getEmail() != null) {
+ pollLinks.addInfo("Vous avez recu un mail !");
+ }
+ if (getPoll().getPollType().isRestrictedOrGroup()) {
+ pollLinks.addInfo("Les votants ont reçu un mail !");
+ }
+ return pollLinks;
+ }
return mainZone;
}
+ @Log
+ Object onFailure() {
+ return mainZone;
+ }
+
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -0,0 +1,105 @@
+package org.chorem.pollen.ui.pages.poll;
+
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.chorem.pollen.entity.Poll;
+import org.chorem.pollen.service.ServicePoll;
+import org.chorem.pollen.ui.base.AbstractPollenPage;
+import org.chorem.pollen.ui.components.Border;
+import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.data.PollUri;
+import org.slf4j.Logger;
+
+/**
+ * Created: 20 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class PollLinks extends AbstractPollenPage {
+
+ public static final String URI_SEPARATOR = "/";
+
+ @InjectComponent
+ private Border border;
+
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private ServicePoll servicePoll;
+
+ @Override
+ public Border getBorder() {
+ return border;
+ }
+
+ public String getTitle() {
+ return "Liens d'accès au sondage";
+ }
+
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar().appendCurrent(getTitle());
+ }
+
+ @Inject
+ private PageRenderLinkSource linkSource;
+
+ private Poll poll;
+
+ private PollUri pollUri;
+
+ void onActivate(PollUri pollUri) {
+ this.pollUri = pollUri;
+ }
+
+ PollUri onPassivate() {
+ return pollUri;
+ }
+
+ void setupRender() {
+ if (pollUri == null) {
+ addFatal("pollen.ui.poll.links.uriNotDefined");
+ } else if (!servicePoll.canAdminPoll(
+ pollUri.getAccountUid(), pollUri.getPollUid())) {
+ addFatal("pollen.ui.poll.links.notAllowed");
+ }
+ }
+
+ public boolean isPollNull() {
+ return getPoll() == null;
+ }
+
+ public void setPollUri(PollUri pollUri) {
+ this.pollUri = pollUri;
+ }
+
+ public Poll getPoll() {
+ if (pollUri != null) {
+ poll = servicePoll.getPoll(pollUri.getPollUid());
+ }
+ return poll;
+ }
+
+ public Link getPollLink() {
+ Link link = linkSource.createPageRenderLinkWithContext(
+ PollForm.class, pollUri);
+ return link;
+ }
+
+ public Link getVoteLink() {
+ PollUri voteUri = PollUri.newUri(null, pollUri.getPollUid());
+ Link link = linkSource.createPageRenderLinkWithContext(
+ VoteForPoll.class, voteUri);
+ return link;
+ }
+
+ public Link getModerateVoteLink() {
+ Link link = linkSource.createPageRenderLinkWithContext(
+ VoteForPoll.class, pollUri);
+ return link;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -372,9 +372,9 @@
// ResultListDTO resultListDTO = null;
//
// if (byGroup) {
-// resultListDTO = serviceResults.getGroupResults(poll.getPollUId());
+// resultListDTO = serviceResults.getGroupResults(poll.getPollUid());
// } else {
-// resultListDTO = serviceResults.getNormalResults(poll.getPollUId());
+// resultListDTO = serviceResults.getNormalResults(poll.getPollUid());
// }
//
// results = resultListDTO.getResultDTOs();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -421,10 +421,10 @@
////
//// // Check for restricted poll
//// if (!alreadyVoted && !isFreePoll()) {
-//// if (uri.getAccountUId() != null) {
-//// // The accountUId must be valid for the poll
+//// if (uri.getAccountUid() != null) {
+//// // The accountUid must be valid for the poll
//// PollAccountDTO restrictedAccount =
-//// servicePoll.getRestrictedAccount(uri.getAccountUId(), getPoll());
+//// servicePoll.getRestrictedAccount(uri.getAccountUid(), getPoll());
////
//// if (restrictedAccount != null) {
//// // PollAccount is replaced by the good account from db
@@ -435,7 +435,7 @@
//// } else {
//// restrictedListsForbidden = true;
//// }
-//// // Not allowed to vote without an accountUId
+//// // Not allowed to vote without an accountUid
//// } else {
//// restrictedListsForbidden = true;
//// }
@@ -525,8 +525,8 @@
// /** Ajout d'une entrée dans le flux de syndication */
// private void addFeedEntry(PollAction pollAction, String titleStr,
// String contentStr) throws PollenBusinessException {
-// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUId();
-// File feedFile = getFeedContext().getFile(getPoll().getPollUId());
+// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUid();
+// File feedFile = getFeedContext().getFile(getPoll().getPollUid());
// String title = null;
// String content = null;
//
@@ -558,8 +558,8 @@
//
// /** Envoi du mail de notification */
// private void sendMailNotification() throws PollenBusinessException {
-// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUId();
-// String modifURL = siteURL + "poll/Modification/" + getPoll().getPollUId()
+// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUid();
+// String modifURL = siteURL + "poll/Modification/" + getPoll().getPollUid()
// + ":" + MD5.encode(getPoll().getCreatorId());
// Map<String, String> data = new HashMap<String, String>();
// data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
@@ -669,7 +669,7 @@
// */
// @Log
// public boolean isFeedFileExisting() throws PollenBusinessException {
-// File feedFile = getFeedContext().getFile(getPoll().getPollUId());
+// File feedFile = getFeedContext().getFile(getPoll().getPollUid());
// if (log.isDebugEnabled()) {
// log.debug("feed context path : " + getFeedContext().getContextPath());
// log.debug("feed absolute path : " + feedFile.getAbsolutePath());
@@ -777,7 +777,7 @@
// if (isTextType()) {
// if (newChoice.getName() != null) {
// newChoice.setValidate(true);
-// newChoice.setPollUId(getPoll().getPollUId());
+// newChoice.setPollUid(getPoll().getPollUid());
// getPoll().getChoices().add(newChoice);
// choiceName = newChoice.getName();
// choiceDesc = newChoice.getDescription();
@@ -785,7 +785,7 @@
// } else if (isDateType()) {
// if (newDateChoice.getDate() != null) {
// newDateChoice.setValidate(true);
-// newDateChoice.setPollUId(getPoll().getPollUId());
+// newDateChoice.setPollUid(getPoll().getPollUid());
// newDateChoice.setName(String.valueOf(newDateChoice.getDate()
// .getTime()));
// getPoll().getChoices().add(newDateChoice);
@@ -796,7 +796,7 @@
// } else if (isImageType()) {
// if (newImageChoice.getImg() != null) {
// newImageChoice.setValidate(true);
-// newImageChoice.setPollUId(getPoll().getPollUId());
+// newImageChoice.setPollUid(getPoll().getPollUid());
// newImageChoice.setName(newImageChoice.getImg().getFileName()
// .replace(' ', '_'));
// getPoll().getChoices().add(newImageChoice);
@@ -904,9 +904,9 @@
// if (getPoll().getContinuousResults()) {
//
// if (isGroupPoll()) {
-// resultListDTO = serviceResults.getGroupResults(getPoll().getPollUId());
+// resultListDTO = serviceResults.getGroupResults(getPoll().getPollUid());
// } else {
-// resultListDTO = serviceResults.getNormalResults(getPoll().getPollUId());
+// resultListDTO = serviceResults.getNormalResults(getPoll().getPollUid());
// }
//
// results = resultListDTO.getResultDTOs();
@@ -1048,7 +1048,7 @@
public Poll getPoll() throws PollenBusinessException {
if (poll == null) {
- poll = servicePoll.getPollForVote(uri.getPollUId());
+ poll = servicePoll.getPollForVote(uri.getPollUid());
if (poll != null) {
@@ -1082,7 +1082,7 @@
/**
* Use a PollAccount to represent the current session user.
- * The existing account is used if accountUId is present in the uri.
+ * The existing account is used if accountUid is present in the uri.
* Otherwise a new account is instanciate with user properties
* (for vote name).
*
@@ -1091,8 +1091,8 @@
public PollAccount getPollAccount() throws PollenBusinessException {
if (pollAccount == null) {
// Identification du votant
- if (uri.getAccountUId() != null) {
- // pollAccount = serviceUser.getPerson(uri.getAccountUId());
+ if (uri.getAccountUid() != null) {
+ // pollAccount = serviceUser.getPerson(uri.getAccountUid());
// pollAccountId = pollAccount.getId();
@@ -1314,7 +1314,7 @@
// break;
// case IMAGE:
// newChoice = ChoiceField.getChoiceImage(
-// getPoll().getPollUId());
+// getPoll().getPollUid());
// break;
// case TEXT:
// default:
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -73,7 +73,7 @@
// for (VotingListDTO list : poll.getVotingListDTOs()) {
// for (PollAccountDTO account : list.getPollAccountDTOs()) {
// if (account.getEmail().equals(user.getEmail())) {
-// return poll.getPollUId() + ":" + account.getAccountUId();
+// return poll.getPollUid() + ":" + account.getAccountUid();
// }
// }
// }
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -107,7 +107,7 @@
/**
* Execute PollenManager when registry startup.
* The manager will be instantiated using
- * {@link #buildPollenManager(org.apache.tapestry5.ioc.services.RegistryShutdownHub) }.
+ * {@link #buildPollenManager() }.
* The serviceUser is needed to start the application.
*
* @param configuration to add the manager to registry startup
@@ -187,7 +187,7 @@
@Override
public PollUri coerce(String input) {
- return new PollUri(input);
+ return PollUri.newUri(input);
}
};
@@ -249,12 +249,12 @@
/**
* Contribution to ComponentRequestHandler service. The
- * {@link AuthenticationFilter} is added to the configuration of
+ * {@link PollenAuthenticationFilter} is added to the configuration of
* the service to provide authentication managment on user connected.
*
* @param configuration of ComponentRequestHandler
* @see ServiceAuthentication
- * @see AuthenticationFilter
+ * @see PollenAuthenticationFilter
* @see ComponentRequestFilter
*/
public static void contributeComponentRequestHandler(
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-20 16:50:54 UTC (rev 3006)
@@ -2,11 +2,13 @@
package org.chorem.pollen.ui.services;
import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.services.ApplicationStateManager;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountImpl;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
import org.chorem.pollen.ui.pages.admin.AdminUsers;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.nuiton.web.tapestry5.services.ServiceAuthenticationImpl;
/**
@@ -27,6 +29,8 @@
public class PollenAuthentication extends
ServiceAuthenticationImpl<UserAccount, PollenRequiresAuthentication> {
+ protected Class<?> pageClass;
+
public PollenAuthentication(ApplicationStateManager stateManager) {
super(stateManager, UserAccount.class,
PollenRequiresAuthentication.class);
@@ -53,7 +57,7 @@
* in AppModule.
*
* @return a new instance of UserAccount.
- * @see AppModule#contributeApplicationStateManager(MappedConfiguration, ServiceAuthentication)
+ * @see AppModule#contributeApplicationStateManager(MappedConfiguration , ServiceAuthentication)
*/
@Override
public UserAccount getNewUserInstance() {
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-20 16:50:54 UTC (rev 3006)
@@ -1,6 +1,7 @@
############################ PAGES #############################################
pollen.page.AdminUsers.title=Gestion des utilisateurs
pollen.page.UserLists.title=Vos listes de votants
+pollen.page.PollLinks.title=Liens d'acc\u00e8s au sondage
############################ EMAIL #############################################
pollen.email.userRegister.subject=[Pollen] Confirmation de cr\u00e9ation du compte %s
@@ -57,8 +58,20 @@
pollen.ui.participant.weight-label=Poids
pollen.ui.participant.add=Nouveau participant
-pollen.ui.poll.listChanged.confirmMessage=Des changements ont été effectués sur la/les liste(s), un changement de restriction supprimera les modifications. Voulez-vous continuer ?
+pollen.ui.poll.form.confirmlistChange=Des changements ont \u00e9t\u00e9 effectu\u00e9s sur la/les liste(s), un changement de restriction supprimera les modifications. Voulez-vous continuer ?
+pollen.ui.poll.links.pollName=%1$s par %2$s
+pollen.ui.poll.links.uriNotDefined=Page inaccessible sans identifiant du sondage dans l'url !
+pollen.ui.poll.links.notAllowed=L'url est incorrect, vous n'\u00eates pas autoris\u00e9 \u00e0 acc\u00e9der aux liens du sondage.
+#pollen.ui.poll.links.votePage=Le lien ci-dessous m\u00e8ne \u00e0 la page de votes. Enregistrez-le et envoyez-le \u00e0 ceux que vous voulez voir voter :
+#pollen.ui.poll.links.adminVotePage=Le lien ci-dessous m\u00e8ne \u00e0 la page de votes avec un acc\u00e8s mod\u00e9rateur. Enregistrez-le pour pouvoir mod\u00e9rer les votes si besoin :
+#pollen.ui.poll.links.editPage=Le lien ci-dessous m\u00e8ne \u00e0 la page de modification du sondage. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore :
+pollen.ui.poll.links.votePage=Lien d'acc\u00e8s publique \u00e0 la page des votes :
+pollen.ui.poll.links.adminVotePage=Lien d'acc\u00e8s mod\u00e9rateur \u00e0 la page des votes :
+pollen.ui.poll.links.editPage=Lien d'acc\u00e8s \u00e0 la modification du sondage :
+pollen.ui.poll.links.register=Si vous \u00eates un utilisateur identifi\u00e9, vous pouvez retrouver ces liens dans la page
+pollen.ui.poll.links.myPolls=Mes sondages
+
# OLD LOGIN_COMPONENT
connectionLegend=Connexion
loginSubmit=Me connecter
@@ -70,6 +83,8 @@
# FORM:: poll
groupName-label=Nom du groupe
+participantEmail-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
+participantEmail-regexp-message=Adresse email invalide.
# FORM:: user
firstName-label=Pr\u00e9nom
Modified: trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml 2010-05-20 16:50:54 UTC (rev 3006)
@@ -8,8 +8,8 @@
<img src="${asset:context:img/vote.png}" alt="${message:vote}" style="margin-right: 18px;"/>
${message:votePage}
<br />
- <t:PageLink t:context="poll.pollUId" t:page="poll/VoteForPoll" style="margin-left:50px;">
- ${siteURL}poll/VoteFor/${poll.pollUId}
+ <t:PageLink t:context="poll.pollUid" t:page="poll/VoteForPoll" style="margin-left:50px;">
+ ${siteURL}poll/VoteFor/${poll.pollUid}
</t:PageLink>
</div>
<div style="margin-top: 10px;">
Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-05-20 16:50:54 UTC (rev 3006)
@@ -275,7 +275,7 @@
</div>
</t:formfragment>
<t:formfragment t:id="imgChoiceFragment" visible="isImgChoices()">
- <t:ImageContextLink t:id="imgContext" t:dir="poll.pollUId" />
+ <t:ImageContextLink t:id="imgContext" t:dir="poll.pollUid" />
<div t:type="loop" t:source="imgTypeChoices" t:value="imgTypeChoice" t:volatile="true">
<div class="fleft choiceName">
<t:label for="imgFile" />
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-20 16:50:54 UTC (rev 3006)
@@ -337,7 +337,8 @@
<td>
<t:textfield t:id="participantEmail"
value="participant.email"
- size="25" />
+ size="25"
+ t:validate="required,regexp" />
</td>
<td>
<t:textfield t:id="participantWeight"
Added: trunk/pollen-ui/src/main/webapp/poll/PollLinks.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollLinks.tml (rev 0)
+++ trunk/pollen-ui/src/main/webapp/poll/PollLinks.tml 2010-05-20 16:50:54 UTC (rev 3006)
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html t:type="border" t:addressBar="addressBar" t:pageLogo="literal:Creation" t:pageTitle="prop:title"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+ <!--<t:feedback t:id="feedback"/>-->
+ <t:unless t:test="pollNull">
+ <h1 class="titleCreation">${title}</h1>
+
+ <h3>${format:pollen.ui.poll.links.pollName=poll.title,poll.creator.name}</h3>
+ <t:unless t:test="poll.pollType.restrictedOrGroup">
+ <div style="margin-top: 10px;">
+ <img src="${asset:context:img/vote.png}" alt="${message:vote}" style="margin-right: 20px;"/>
+ ${message:pollen.ui.poll.links.votePage}
+ <br />
+ <a href="${voteLink}" style="margin-left:50px;">
+ ${url}${voteLink.toAbsoluteUri()}
+ </a>
+ </div>
+ <!--<p:else>-->
+ <!--${message:pollen.ui.poll.links.noVoteLinkForRestriction}-->
+ <!--</p:else>-->
+ </t:unless>
+ <div style="margin-top: 10px;">
+ <img src="${asset:context:img/edit.png}" alt="${message:edit}" />
+ <img src="${asset:context:img/vote.png}" alt="${message:vote}" style="margin-right: 1px;" />
+ ${message:pollen.ui.poll.links.adminVotePage}
+ <br />
+ <a href="${moderateVoteLink}" style="margin-left:50px;">
+ ${url}${moderateVoteLink.toAbsoluteUri()}
+ </a>
+ </div>
+ <div style="margin-top: 10px;">
+ <img src="${asset:context:img/edit.png}" alt="${message:edit}" style="margin-right: 26px;" />
+ ${message:pollen.ui.poll.links.editPage}
+ <br />
+ <a href="${pollLink}" style="margin-left:50px;">
+ ${url}${pollLink.toAbsoluteUri()}
+ </a>
+ </div>
+ <div style="margin-top: 30px;">
+ ${message:pollen.ui.poll.links.register}
+ <t:PageLink t:page="user/PollsCreated">${message:pollen.ui.poll.links.myPolls}</t:PageLink>.
+ </div>
+ </t:unless>
+</html>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/webapp/poll/PollLinks.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-20 16:50:54 UTC (rev 3006)
@@ -1,5 +1,5 @@
-<t:border t:address="address.items" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUId"
+<t:border t:address="address.items" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUid"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<t:feedback t:id="feedback"/>
@@ -14,13 +14,13 @@
<legend>${message:about}</legend>
<div style="float: right">
<t:if test="poll.publicResults">
- <t:PageLink t:page="poll/Results" t:context="poll.pollUId">
+ <t:PageLink t:page="poll/Results" t:context="poll.pollUid">
<img src="${asset:context:img/count.png}" title="${message:results-help}" alt="${message:results}"/>
</t:PageLink>
</t:if>
<t:FeedContextLink t:id="feedContext" />
<t:if test="feedFileExisting">
- <t:FileLink filename="${poll.pollUId}" type="literal:application/atom+xml" t:context="feedContext">
+ <t:FileLink filename="${poll.pollUid}" type="literal:application/atom+xml" t:context="feedContext">
<img src="${asset:context:img/feed.png}" title="Atom" alt="Atom"/>
</t:FileLink>
</t:if>
@@ -204,7 +204,7 @@
<t:if test="poll.continuousResults">
<tr>
<td>
- <t:PageLink t:page="poll/results" t:context="${poll.pollUId}">${message:results}</t:PageLink>
+ <t:PageLink t:page="poll/results" t:context="${poll.pollUid}">${message:results}</t:PageLink>
</td>
<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
<t:if test="!isChoiceHidden()">
@@ -233,7 +233,7 @@
<!-- Ajout de choix -->
- <!--<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUId"/>-->
+ <!--<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUid"/>-->
<t:if test="canAddChoice">
<h4>${message:pollen.ui.choice.add.title}</h4>
<div id="choiceFormDiv">
Modified: trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml 2010-05-20 10:55:16 UTC (rev 3005)
+++ trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml 2010-05-20 16:50:54 UTC (rev 3006)
@@ -10,7 +10,7 @@
<t:grid t:id="pollsGrid" t:source="polls" t:row="poll" model="pollsModel" t:inPlace="true"
t:rowsPerPage="10" t:pagerPosition="bottom" t:rowClass="prop:evenodd.next">
<p:functionsCell>
- <t:PageLink t:page="poll/VoteForPoll" t:context="poll.pollUId">
+ <t:PageLink t:page="poll/VoteForPoll" t:context="poll.pollUid">
<img src="${asset:context:img/vote.png}" title="${message:vote-help}" alt="${message:vote}" />
</t:PageLink>
<t:PageLink t:page="poll/results" t:context="adminId">
@@ -21,18 +21,18 @@
<t:PageLink t:page="poll/modification" t:context="adminId">
<img src="${asset:context:img/edit.png}" title="${message:edit-help}" alt="${message:edit}" />
</t:PageLink>
- <t:ActionLink t:id="close" t:context="poll.pollUId">
+ <t:ActionLink t:id="close" t:context="poll.pollUid">
<img src="${asset:context:img/close.png}" title="${message:close-help}" alt="${message:close}" />
</t:ActionLink>
</t:unless>
- <t:ActionLink t:id="export" t:context="poll.pollUId">
+ <t:ActionLink t:id="export" t:context="poll.pollUid">
<img src="${asset:context:img/export.png}" title="${message:export-help}" alt="${message:export}" />
</t:ActionLink>
- <t:PageLink t:page="poll/creation" t:context="poll.pollUId">
+ <t:PageLink t:page="poll/creation" t:context="poll.pollUid">
<img src="${asset:context:img/copy.png}" title="${message:copy-help}" alt="${message:copy}" />
</t:PageLink>
- <t:ActionLink t:id="deletePoll" t:context="poll.pollUId">
+ <t:ActionLink t:id="deletePoll" t:context="poll.pollUid">
<img src="${asset:context:img/delete.png}" title="${message:delete-help}" alt="${message:delete}" />
</t:ActionLink>
</p:functionsCell>
1
0