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
r3005 - in trunk/pollen-business/src/test/java/org/chorem/pollen: . service test
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 12:55:16 +0200 (Thu, 20 May 2010)
New Revision: 3005
Url: http://chorem.org/repositories/revision/pollen/3005
Log:
missing refactor for tests
Modified:
trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java
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-20 10:42:31 UTC (rev 3004)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-05-20 10:55:16 UTC (rev 3005)
@@ -53,7 +53,7 @@
Assert.assertEquals(builder.getQuery().fullQuery(),
"FROM " + UserAccount.class.getName() +
- " ORDER BY " + TopiaEntity.CREATE_DATE + " DESC");
+ " ORDER BY " + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
}
@@ -98,7 +98,7 @@
"SELECT P FROM " + FavoriteParticipant.class.getName() + " P, "
+ FavoriteList.class.getName() + " L" +
" WHERE P IN elements (L." + FavoriteList.FAVORITE_PARTICIPANT +
- ") ORDER BY P." + TopiaEntity.CREATE_DATE + " DESC");
+ ") ORDER BY P." + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
log.info("test3 : orderBy name and email desc");
String orderBy = FavoriteParticipant.NAME + ", " + FavoriteParticipant.EMAIL + " desc";
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-20 10:42:31 UTC (rev 3004)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-20 10:55:16 UTC (rev 3005)
@@ -108,7 +108,7 @@
try {
newPoll = servicePoll.createBasicPoll(transaction, poll);
Assert.assertNotNull(newPoll);
- Assert.assertNotNull(newPoll.getId());
+ Assert.assertNotNull(newPoll.getTopiaId());
Assert.assertNotNull(newPoll.getUid());
Assert.assertEquals("Poll", newPoll.getTitle());
@@ -130,7 +130,7 @@
try {
PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
- Poll pollFound = dao.findByTopiaId(newPoll.getId());
+ Poll pollFound = dao.findByTopiaId(newPoll.getTopiaId());
Assert.assertNotNull(pollFound);
Assert.assertNotNull(pollFound.getCreator());
Assert.assertEquals(user, pollFound.getCreator().getUserAccount());
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java 2010-05-20 10:42:31 UTC (rev 3004)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java 2010-05-20 10:55:16 UTC (rev 3005)
@@ -232,7 +232,7 @@
PollenDAOHelper.getFavoriteListDAO(transaction);
TopiaQuery query = dao.createQuery().
- add(TopiaEntity.ID, id).
+ add(TopiaEntity.TOPIA_ID, id).
addLoad(propertiesLoad);
FavoriteList result = dao.findByQuery(query);
1
0
Author: fdesbois
Date: 2010-05-20 12:42:31 +0200 (Thu, 20 May 2010)
New Revision: 3004
Url: http://chorem.org/repositories/revision/pollen/3004
Log:
- Refactor from Topia ID in TOPIA_ID
- Add error managment for form validation (not tested yet)
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ErrorReport.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FieldValidationException.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.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/ParticipantListModel.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/services/PollenManager.java
trunk/pollen-ui/src/main/webapp/poll/PollForm.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-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -1,66 +1,65 @@
-
package org.chorem.pollen;
-import org.nuiton.topia.framework.*;
+import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaEntity;
/**
* EntityQueryProperty is used to simplify property concatenation in TopiaQuery.
- * The usage is simple, the EntityQueryProperty need a mainAlias which represents
- * the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
- * is called to retrieve the correct property name used for the query.
- * Exemple :
+ * The usage is simple, the EntityQueryProperty need a mainAlias which
+ * represents the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
+ * is called to retrieve the correct property name used for the query. Exemple
+ * :
* <pre>
* BoatDAO dao = AppDAOHelper.getBoatDAO(topiaContext);
- *
+ * <p/>
* // Property used in the query
* EntityQueryProperty boatProperty = new EntityQueryProperty("B");
- *
+ * <p/>
* // It's better to create the query with the property name
* TopiaQuery query = dao.createQuery(boatProperty.name());
- *
+ * <p/>
* // The property NAME of the boat need to be find equals to "ULUBERLU"
* query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU");
- *
+ * <p/>
* // It's avoid doing this :
* query.add("B." + Boat.NAME, "ULUBERLU");
* </pre>
* This last exemple is a simple case but for a more complex query with more
* than one entity, it's obvious that concatenation using + is not a good
- * practice.<br />
- * You can also use this class as a superclass for each entity, ex :
+ * practice.<br /> You can also use this class as a superclass for each entity,
+ * ex :
* <pre>
* public class BoatProperty extends EntityQueryProperty {
- *
+ * <p/>
* public BoatProperty(String mainAlias) {
* super(mainAlias);
* }
- *
+ * <p/>
* public String namePropertyName() {
* return nameProperty(Boat.NAME);
* }
- * }
+ * }
* </pre>
- *
+ * <p/>
* Created: 14 avr. 2010
*
* @author fdesbois <fdesbois(a)codelutin.com>
*/
public class EntityQueryProperty {
- /** alias of the entity **/
+ /** alias of the entity * */
protected String mainAlias;
- /** name of the property used for join in query **/
+ /** name of the property used for join in query * */
protected String propertyJoin;
- /** class of the entity **/
+ /** class of the entity * */
protected Class<? extends TopiaEntity> entityClass;
/**
* Default constructor. mainAlias, propertyJoin and entityClass are null.
- * You can use setters to initalize these three properties.
- * You can use {@link #nameProperty(String)} method with a mainAlias null.
+ * You can use setters to initalize these three properties. You can use
+ * {@link #nameProperty(String)} method with a mainAlias null.
*/
public EntityQueryProperty() {
}
@@ -77,13 +76,13 @@
/**
* Constructor with mainAlias and entityClass.
*
- * @param mainAlias alias 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
+ * EntityQueryProperty
*/
public EntityQueryProperty(String mainAlias,
- Class<? extends TopiaEntity> entityClass) {
+ Class<? extends TopiaEntity> entityClass) {
this(mainAlias);
setEntityClass(entityClass);
}
@@ -111,15 +110,15 @@
* Setter for entityClass.
*
* @param entityClass class of the entity corresponding to this
- * EntityQueryProperty
+ * EntityQueryProperty
*/
public void setEntityClass(Class<? extends TopiaEntity> entityClass) {
this.entityClass = entityClass;
}
/**
- * Name the entity as a property for a TopiaQuery. Careful, this name can
- * be null if no mainAlias is properly set.
+ * Name the entity as a property for a TopiaQuery. Careful, this name can be
+ * null if no mainAlias is properly set.
*
* @return the entity name to use in a TopiaQuery
*/
@@ -144,7 +143,7 @@
* @return the property name to use in a TopiaQuery
*/
public String namePropertyId() {
- return nameProperty(TopiaEntity.ID);
+ return nameProperty(TopiaEntity.TOPIA_ID);
}
/**
@@ -153,7 +152,7 @@
* @return the property name to use in a TopiaQuery
*/
public String namePropertyCreateDate() {
- return nameProperty(TopiaEntity.CREATE_DATE);
+ return nameProperty(TopiaEntity.TOPIA_CREATE_DATE);
}
/**
@@ -170,11 +169,10 @@
}
/**
- * Get the entityClass associated with this EntityQueryProperty.
- * Can be useful in some case, to create other query for exemple or to
- * use it in {@link TopiaQuery#addFrom(Class)} method.
- * The entityClass need to be set before calling this method to avoid
- * NullPointerException.
+ * Get the entityClass associated with this EntityQueryProperty. Can be
+ * useful in some case, to create other query for exemple or to use it in
+ * {@link TopiaQuery#addFrom(Class)} method. The entityClass need to be set
+ * before calling this method to avoid NullPointerException.
*
* @return the entity class corresponding to this EntityQueryProperty.
*/
@@ -191,7 +189,7 @@
* instantiate.
*
* @return a new TopiaQuery with the main entity as the EntityQueryProperty
- * provides it.
+ * provides it.
*/
public TopiaQuery newQuery() {
return new TopiaQuery(getEntityClass(), name());
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-05-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -1,13 +1,13 @@
-
package org.chorem.pollen.bean;
+import org.nuiton.topia.persistence.TopiaEntity;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import org.nuiton.topia.persistence.TopiaEntity;
/**
* Filter
- *
+ * <p/>
* Created: 23 avr. 2010
*
* @author fdesbois
@@ -109,11 +109,11 @@
/**
* Set the value of referenceId
*
- * @param entity
+ * @param entity
*/
public void setReference(TopiaEntity entity) {
String oldReferenceId = this.referenceId;
- this.referenceId = entity.getId();
+ this.referenceId = entity.getTopiaId();
propertyChangeSupport.firePropertyChange(PROP_REFERENCE_ID,
oldReferenceId, referenceId);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -48,4 +48,9 @@
addFavoriteParticipant(favorite);
return null;
}
+
+ @Override
+ public String getId() {
+ return getTopiaId();
+ }
}
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -0,0 +1,15 @@
+package org.chorem.pollen.entity;
+
+/**
+ * Created: 20 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class FavoriteParticipantImpl extends FavoriteParticipantAbstract {
+
+ @Override
+ public String getId() {
+ return getTopiaId();
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -61,4 +61,9 @@
addChild(account);
return null;
}
+
+ @Override
+ public String getId() {
+ return getTopiaId();
+ }
}
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-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -1,7 +1,5 @@
package org.chorem.pollen.service;
-import java.util.List;
-import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -25,18 +23,23 @@
import org.nuiton.topia.framework.TopiaQuery.Op;
import org.nuiton.topia.persistence.TopiaEntity;
+import java.util.List;
+import java.util.Map;
+
/**
* ServiceFavorite
- *
+ * <p/>
* Created: 5 mai 2010
*
- * @author fdesbois
- * $Id$
+ * @author fdesbois $Id: ServiceFavoriteImpl.java 2996 2010-05-14 12:06:15Z
+ * fdesbois $
*/
public class ServiceFavoriteImpl extends ServiceFavoriteAbstract {
private Log log = LogFactory.getLog(ServiceUserImpl.class);
+
private static final String BINDER_CONTEXT_FAVORITE_LIST = "favoriteList";
+
private PollenContext context;
public void setContext(PollenContext context) {
@@ -50,7 +53,7 @@
@Override
protected void treateError(TopiaContext transaction, Exception eee,
- String message, Object... args) throws PollenException {
+ String message, Object... args) throws PollenException {
context.treateError(transaction, eee, message, args);
}
@@ -68,7 +71,7 @@
@Override
protected void executeCreateFavoriteList(TopiaContext transaction,
- FavoriteList list) throws TopiaException, PollenBusinessException {
+ FavoriteList list) throws TopiaException, PollenBusinessException {
FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
@@ -92,10 +95,10 @@
@Override
protected void executeDeleteFavoriteList(TopiaContext transaction,
- FavoriteList list) throws TopiaException {
+ FavoriteList list) throws TopiaException {
FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
- FavoriteList listLoaded = dao.findById(list.getId());
+ FavoriteList listLoaded = dao.findByTopiaId(list.getId());
dao.delete(listLoaded);
transaction.commitTransaction();
@@ -113,28 +116,28 @@
}
/**
- * Check if the {@code participant} doesn't already exists with same
- * email, name and favoriteList.
+ * Check if the {@code participant} doesn't already exists with same email,
+ * name and favoriteList.
*
- * @param dao used to verify the existing participant
+ * @param dao used to verify the existing participant
* @param participant FavoriteParticipant to check
* @throws PollenBusinessException if FavoriteParticipant already exists
- * @throws TopiaException for technical errors from ToPIA
+ * @throws TopiaException for technical errors from ToPIA
*/
protected void checkFavoriteParticipant(FavoriteParticipantDAO dao,
- FavoriteParticipant participant)
+ FavoriteParticipant participant)
throws PollenBusinessException, TopiaException {
FavoriteList list = participant.getFavoriteList();
TopiaQuery query = dao.createQuery().
- add(FavoriteParticipant.FAVORITE_LIST, list).
- add(FavoriteParticipant.NAME, participant.getName()).
- add(FavoriteParticipant.EMAIL, participant.getEmail());
+ add(FavoriteParticipant.FAVORITE_LIST, list).
+ add(FavoriteParticipant.NAME, participant.getName()).
+ add(FavoriteParticipant.EMAIL, participant.getEmail());
// Check only on entities different from the one in argument
if (StringUtils.isNotEmpty(participant.getId())) {
- query.add(TopiaEntity.ID, Op.NEQ, participant.getId());
+ query.add(TopiaEntity.TOPIA_ID, Op.NEQ, participant.getId());
}
// existing participant found
@@ -166,7 +169,7 @@
@Override
protected void executeCreateFavoriteParticipant(TopiaContext transaction,
- FavoriteParticipant participant)
+ FavoriteParticipant participant)
throws PollenBusinessException, TopiaException {
FavoriteParticipantDAO dao =
@@ -177,8 +180,8 @@
// Create newParticipant with naturalId
FavoriteParticipant newParticipant =
dao.create(participant.getName(),
- participant.getEmail(),
- participant.getFavoriteList());
+ participant.getEmail(),
+ participant.getFavoriteList());
// Set other field
newParticipant.setWeight(participant.getWeight());
@@ -188,12 +191,12 @@
@Override
protected void executeDeleteFavoriteParticipant(TopiaContext transaction,
- String id) throws TopiaException {
+ String id) throws TopiaException {
FavoriteParticipantDAO dao =
PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- FavoriteParticipant participantLoaded = dao.findById(id);
+ FavoriteParticipant participantLoaded = dao.findByTopiaId(id);
dao.delete(participantLoaded);
@@ -202,7 +205,7 @@
@Override
protected void executeUpdateFavoriteParticipant(TopiaContext transaction,
- FavoriteParticipant participant)
+ FavoriteParticipant participant)
throws TopiaException, PollenBusinessException {
FavoriteParticipantDAO dao =
@@ -211,7 +214,7 @@
checkFavoriteParticipant(dao, participant);
FavoriteParticipant participantLoaded =
- dao.findById(participant.getId());
+ dao.findByTopiaId(participant.getId());
// Set all fields except favoriteList that can't be changed
participantLoaded.setName(participant.getName());
@@ -230,7 +233,7 @@
FavoriteParticipantDAO dao =
PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- FavoriteParticipant result = dao.findById(id);
+ FavoriteParticipant result = dao.findByTopiaId(id);
// Load parent list
result.getFavoriteList();
@@ -263,7 +266,7 @@
@Override
protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
- Filter filter) throws TopiaException {
+ Filter filter) throws TopiaException {
PollenQueryBuilder builder = new PollenQueryBuilder();
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -3,7 +3,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenDAOHelper;
-import org.chorem.pollen.test.AbstractServiceTest;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.entity.FavoriteList;
@@ -15,8 +14,8 @@
import org.chorem.pollen.entity.PollDAO;
import org.chorem.pollen.entity.PollImpl;
import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.test.AbstractServiceTest;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
@@ -45,6 +44,7 @@
private Poll poll;
//@Before
+
public void init() throws Exception {
// Initialize service and default user
getServicePoll();
@@ -130,7 +130,7 @@
try {
PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
- Poll pollFound = dao.findById(newPoll.getId());
+ Poll pollFound = dao.findByTopiaId(newPoll.getId());
Assert.assertNotNull(pollFound);
Assert.assertNotNull(pollFound.getCreator());
Assert.assertEquals(user, pollFound.getCreator().getUserAccount());
@@ -140,7 +140,7 @@
}
log.info("test 2 : create poll with new creator");
- poll.getCreator().setUserAccount(null);
+ poll.getCreator().setUserAccount(null);
transaction = beginTransaction();
newPoll = null;
@@ -193,7 +193,7 @@
log.info("test 2 : createPollAccounts from two lists : GROUP." +
" One of the list is an existing favorite one");
-
+
transaction = beginTransaction();
try {
// Create only list accounts
@@ -211,7 +211,7 @@
// Check on list1
if (account.getName().equals(list1.getName())) {
Assert.assertEquals(2, account.getChild().size());
- // Check on list2
+ // Check on list2
} else if (account.getName().equals(list2.getName())) {
Assert.assertEquals(3, account.getChild().size());
// Child are person accounts
@@ -252,7 +252,7 @@
PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
Assert.assertTrue(dao.existByNaturalId(poll.getUid()));
Poll pollFound = dao.findByNaturalId(poll.getUid());
-
+
// Check pollType and accounts
Assert.assertEquals(PollType.FREE, pollFound.getPollType());
Assert.assertEquals(0, pollFound.getPollAccount().size());
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-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -1,7 +1,5 @@
-
package org.chorem.pollen.ui.data;
-import java.util.Date;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.upload.services.UploadedFile;
@@ -13,28 +11,30 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Date;
+
/**
- * This class extends ChoiceDTO to have the same properties. It had the
- * behavior to be an image or a date depends on the choice type.
- * You have to set the type when needed (changing) or using static methods :
+ * This class extends ChoiceDTO to have the same properties. It had the behavior
+ * to be an image or a date depends on the choice type. You have to set the type
+ * when needed (changing) or using static methods :
* <pre>
* - {@link #getChoiceDate(java.lang.String)} : need the date pattern to format
* - {@link #getChoiceImage(java.lang.String)} : need the pollId to save the
* image
* - {@link #getChoiceText()}
* </pre>
- *
+ * <p/>
* Before saving choices using servicePoll, you have to save the name using
* {@link #saveName()} method : the name to save depends on the choice type.
- *
+ * <p/>
* Created: 6 mars 2010
*
* @author fdesbois
* @version $Revision$
* @since 1.3
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * <p/>
+ * Mise a jour: $Date$ par
+ * : $Author$
*/
public class ChoiceField {
@@ -74,8 +74,8 @@
this.choice = choice;
if (log.isDebugEnabled()) {
log.debug("Instanciate ChoiceField : " +
- "type = " + getChoiceType() +
- " _ name = " + getName());
+ "type = " + getChoiceType() +
+ " _ name = " + getName());
}
switch (getChoiceType()) {
case DATE:
@@ -105,7 +105,7 @@
* Instantiate a new choiceField for an Image ChoiceType.
*
* @param pollUId used to save the image (corresponding to the folder where
- * the image will be saved).
+ * the image will be saved).
* @return the ChoiceField which is image typed
* @see #setImageType(java.lang.String)
*/
@@ -119,7 +119,7 @@
* Instantiate a new choiceField for a Text ChoiceType.
*
* @return the ChoiceField which is text typed
- * @see #setTextType()
+ * @see #setTextType()
*/
public static ChoiceField getChoiceText() {
ChoiceField result = new ChoiceField();
@@ -128,8 +128,8 @@
}
/**
- * Change type of the choice to date type. The date type need a
- * {@code pattern} to format the date when saving the choice.
+ * 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()
*/
@@ -151,9 +151,7 @@
date = null;
}
- /**
- * Change type of the choice to text type.
- */
+ /** Change type of the choice to text type. */
public void setTextType() {
setChoiceType(ChoiceType.TEXT);
date = null;
@@ -173,7 +171,7 @@
this.image = image;
String contentType = StringUtils.lowerCase(image.getContentType());
if (!contentType.contains("image")) {
- throw new FileUploadException("wrong type " +
+ throw new FileUploadException("wrong type " +
image.getContentType() + " for image upload " +
image.getFileName());
}
@@ -215,9 +213,10 @@
* correspond to the image file name ;
* - TEXT : the text becomes the choice name.
* </pre>
+ *
* @param serviceImage used to save the image
*/
- public void saveName(ServiceImage serviceImage) {
+ public void saveName(ServiceImage serviceImage) {
String name = "";
switch (getChoiceType()) {
case DATE:
@@ -232,7 +231,7 @@
setName(name);
}
- protected Choice getChoice() {
+ public Choice getChoice() {
if (choice == null) {
choice = new ChoiceImpl();
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ErrorReport.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ErrorReport.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ErrorReport.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -0,0 +1,57 @@
+package org.chorem.pollen.ui.data;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created: 20 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ErrorReport {
+
+ protected Map<String, String> fieldErrors;
+
+ protected Collection<String> errors;
+
+ public void recordFieldError(String field, String message) {
+ getFieldErrors().put(field, message);
+ }
+
+ public void recordError(String message) {
+ getErrors().add(message);
+ }
+
+ public Map<String, String> getFieldErrors() {
+ if (fieldErrors == null) {
+ fieldErrors = new HashMap<String, String>();
+ }
+ return fieldErrors;
+ }
+
+ public Collection<String> getErrors() {
+ if (errors == null) {
+ errors = new ArrayList<String>();
+ }
+ return errors;
+ }
+
+ public Collection<String> getAllErrors() {
+ Collection<String> allErrors = new ArrayList<String>(getErrors());
+ allErrors.addAll(getFieldErrors().values());
+ return allErrors;
+ }
+
+ public void clear() {
+ errors = null;
+ fieldErrors = null;
+ }
+
+ public boolean hasErrors() {
+ return !getAllErrors().isEmpty();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ErrorReport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FieldValidationException.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FieldValidationException.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FieldValidationException.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -0,0 +1,27 @@
+package org.chorem.pollen.ui.data;
+
+import org.apache.tapestry5.ValidationException;
+
+/**
+ * Created: 20 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class FieldValidationException extends ValidationException {
+
+ protected String field;
+
+ public FieldValidationException(String message) {
+ super(message);
+ }
+
+ public FieldValidationException(String field, String message) {
+ super(message);
+ this.field = field;
+ }
+
+ public String getField() {
+ return field;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FieldValidationException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java 2010-05-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -31,10 +31,10 @@
public static final String PROPERTY_PARTICIPANTS = "participants";
- protected ServicePoll service;
+// protected ServicePoll service;
+//
+// protected PollenManager manager;
- protected PollenManager manager;
-
protected ParticipantList list;
protected ParticipantMap participants;
@@ -49,14 +49,23 @@
}
};
- public ParticipantListModel(ServicePoll service, PollenManager manager) {
- this.service = service;
- this.manager = manager;
+ public ParticipantListModel() {
+// this.service = service;
+// this.manager = manager;
participants = new ParticipantMap();
}
- public Participant addNewParticipant() {
- Participant newParticipant = service.getNewPollParticipant();
+ /**
+ * Instantiate a new participant and add it to the current participants
+ * list.
+ *
+ * @param servicePoll Service used to instantiate a new participant
+ * @param manager Service to manage temporary id if needed
+ * @return a new Participant
+ */
+ public Participant addNewParticipant(ServicePoll servicePoll,
+ PollenManager manager) {
+ Participant newParticipant = servicePoll.getNewPollParticipant();
String id = manager.createPollenId();
participants.put(id, newParticipant);
((TopiaEntity) newParticipant).addPropertyListener(participantsListener);
@@ -77,7 +86,14 @@
return participants.values();
}
- public void setList(ParticipantList participantList) {
+ /**
+ * Set a {@code participantList} for current usage. Will initialize
+ * participants from the list.
+ *
+ * @param manager Service used to manage temporary id if needed
+ * @param participantList ParticipantList to set as current one
+ */
+ public void setList(PollenManager manager, ParticipantList participantList) {
if (logger.isDebugEnabled()) {
logger.debug("Set current list : " + participantList.getName());
}
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-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -2,21 +2,29 @@
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.ValueEncoder;
+import org.apache.tapestry5.ioc.Messages;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.ParticipantList;
import org.chorem.pollen.entity.Poll;
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.pages.poll.PollForm;
import org.chorem.pollen.ui.services.PollenManager;
+import org.chorem.pollen.ui.services.ServiceImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -43,7 +51,7 @@
public static final String PROPERTY_LISTS = "lists";
/** Service to manage poll */
- protected ServicePoll service;
+// protected ServicePoll service;
/** Current poll in edition */
protected Poll poll;
@@ -51,6 +59,8 @@
/** Current lists in edition */
protected Map<String, ParticipantList> lists;
+ protected List<ChoiceField> choices;
+
/** Current listModel that contains current edited list and its participants */
protected ParticipantListModel listModel;
@@ -67,18 +77,13 @@
};
/**
- * Constructor of PollFormModel. Need services {@code servicePoll} and
- * {@code manager} to manage the current edited poll. Use {@link
- * #initPoll(String, UserAccount)} to initialize the poll.
- *
- * @param servicePoll ServicePoll to manage poll
- * @param manager PollenManager to manage ids
+ * Constructor of PollFormModel. Use {@link #initPoll(ServicePoll, String,
+ * UserAccount)} to initialize the poll.
*/
- public PollFormModel(ServicePoll servicePoll,
- PollenManager manager) {
- this.service = servicePoll;
+ public PollFormModel() {
+// this.service = servicePoll;
lists = new LinkedHashMap<String, ParticipantList>();
- listModel = new ParticipantListModel(service, manager);
+ listModel = new ParticipantListModel();
listModel.addPropertyChangeListener(listsListener);
}
@@ -91,26 +96,26 @@
* @param user Connected user as creator of a new poll (can be null if no
* user is connected).
*/
- public void initPoll(String uid, UserAccount user) {
+ public void initPoll(ServicePoll servicePoll, String uid, UserAccount user) {
if (StringUtils.isNotEmpty(uid)) {
if (logger.isDebugEnabled()) {
logger.debug("Get existing poll with pollUID = " + uid);
}
- poll = service.getPollForUpdate(uid);
+ poll = servicePoll.getPollForUpdate(uid);
// TODO : init advancedOptions
// TODO-fdesbois-2010-05-19 : exception need to be throw if uid not correspond to an existing poll
} else {
if (logger.isDebugEnabled()) {
logger.debug("Init new poll");
}
- poll = service.getNewPoll(user);
+ poll = servicePoll.getNewPoll(user);
createMode = true;
}
}
/**
* Get the current poll. Will be null if initializion with {@link
- * #initPoll(String, UserAccount)} has not been called.
+ * #initPoll(ServicePoll, String, UserAccount)} has not been called.
*
* @return the current poll.
*/
@@ -127,20 +132,43 @@
return createMode;
}
+ public List<ChoiceField> getChoices() {
+ 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());
+ }
+ } else {
+ for (Choice current : poll.getChoice()) {
+ choices.add(new ChoiceField(poll, current));
+ }
+ }
+ }
+ return choices;
+ }
+
/**
* 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
* automatically added and set for current usage. For a {@link
* PollType#GROUP} poll, the listModel is simply reset.
*
- * @param type PollType to change
+ * @param servicePoll Service used to add a new list for restricted poll
+ * @param manager Service to manage temporary id on participants of the
+ * unique restricted list
+ * @param type PollType to change
+ * @see #addNewList(ServicePoll, String)
+ * @see ParticipantListModel#setList(PollenManager, ParticipantList)
*/
- public void setPollType(PollType type) {
+ public void setPollType(ServicePoll servicePoll, PollenManager manager,
+ PollType type) {
lists.clear();
if (type.isRestricted()) {
- addNewList(DEFAULT_LIST_NAME);
+ addNewList(servicePoll, DEFAULT_LIST_NAME);
// Set automatically the current list to the unique one
- listModel.setList(lists.get(DEFAULT_LIST_NAME));
+ listModel.setList(manager, lists.get(DEFAULT_LIST_NAME));
} else if (type.isGroup()) {
listModel.reset();
}
@@ -166,14 +194,15 @@
* be added if the {@code listName} is empty or if a list with this {@code
* listName} already exists.
*
- * @param listName for the new list to add
+ * @param servicePoll Service used to instantiate a new ParticipantList
+ * @param listName for the new list to add
* @return true if the list has been added, false otherwise
* @see #addList(ParticipantList)
*/
- public boolean addNewList(String listName) {
+ public boolean addNewList(ServicePoll servicePoll, String listName) {
boolean result = false;
if (StringUtils.isNotEmpty(listName)) {
- ParticipantList newList = service.getNewPollList();
+ ParticipantList newList = servicePoll.getNewPollList();
newList.setName(listName);
return addList(newList);
}
@@ -220,11 +249,14 @@
* list will be automatically saved. If error occurs during save, the
* previous list will be refresh (no list change will be done).
*
+ * @param manager Service used to manage temporary id on participants from
+ * the list to set
* @param listName name of the list to set (empty name will be ignored)
* @throws PollenBusinessException for saving error (doubloons)
* @see #saveCurrentList()
*/
- public void setCurrentList(String listName) throws PollenBusinessException {
+ public void setCurrentList(PollenManager manager, String listName)
+ throws PollenBusinessException {
if (StringUtils.isNotEmpty(listName)) {
ParticipantList list = getCurrentList();
try {
@@ -237,7 +269,7 @@
} finally {
// Previous list will be keeped if error occurs during save.
// Apply change in listModel
- listModel.setList(list);
+ listModel.setList(manager, list);
}
}
}
@@ -272,10 +304,75 @@
listModel.persistParticipants();
}
- public void create() throws PollenBusinessException {
- service.createPoll(poll, getLists());
+ /**
+ * Create the poll in business. This will generate choice name to be persist
+ * and used the current lists for restriction.
+ *
+ * @param servicePoll Service used to create the poll.
+ * @param serviceImage Service used to manage image choices save.
+ * @throws PollenBusinessException
+ */
+ public void create(ServicePoll servicePoll, ServiceImage serviceImage)
+ throws PollenBusinessException {
+ poll.clearChoice();
+ for (ChoiceField choiceField : getChoices()) {
+ choiceField.saveName(serviceImage);
+ poll.addChoice(choiceField.getChoice());
+ }
+ servicePoll.createPoll(poll, getLists());
}
+ public void validate(Messages messages) throws FieldValidationException {
+
+ // Initialize beginDate if needed
+ Date beginDate = poll.getBeginDate();
+ if (beginDate == null) {
+ beginDate = new Date();
+ poll.setBeginDate(beginDate);
+ }
+
+ // Check endDate
+ Date endDate = poll.getEndDate();
+ if (endDate != null && endDate.before(beginDate)) {
+ throw new FieldValidationException(
+ PollForm.FORM_FIELD_END_DATE,
+ "error endDate before beginDate");
+ }
+
+ // Add choices is allowed after creation
+ if (poll.getChoiceAddAllowed()) {
+
+ // Initialize beginChoiceDate if needed
+ Date beginChoiceDate = poll.getBeginChoiceDate();
+ if (beginChoiceDate == null) {
+ beginChoiceDate = new Date();
+ poll.setBeginChoiceDate(beginChoiceDate);
+ }
+
+ // Check beginChoiceDate
+ if (endDate != null && 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,
+ "error endChoiceDate before beginChoiceDate");
+ }
+ }
+ }
+
+ 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-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -17,11 +17,11 @@
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
+import org.apache.tapestry5.services.ComponentSource;
import org.chorem.pollen.PollenBusinessException;
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.Participant;
import org.chorem.pollen.entity.ParticipantList;
import org.chorem.pollen.entity.Poll;
@@ -33,15 +33,16 @@
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.FieldValidationException;
import org.chorem.pollen.ui.models.ParticipantListModel;
import org.chorem.pollen.ui.models.PollFormModel;
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;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -150,8 +151,8 @@
if (log.isDebugEnabled()) {
log.debug("-------- NEW POLL FORM MODEL --------");
}
- model = new PollFormModel(servicePoll, manager);
- model.initPoll(pollUID, getUserConnected());
+ model = new PollFormModel();
+ model.initPoll(servicePoll, pollUID, getUserConnected());
}
return model;
}
@@ -342,7 +343,7 @@
return getPoll().getPollType().isFree();
}
- /** ******************* LISTS **************************************** */
+ /** ****************** LISTS **************************************** */
@Inject
private ComponentResources resources;
@@ -416,7 +417,7 @@
@Log
Object onUpdatePollType(String value) {
- getModel().setPollType(PollType.valueOf(value));
+ getModel().setPollType(servicePoll, manager, PollType.valueOf(value));
return refreshListZone();
}
@@ -439,9 +440,9 @@
@Log
void onSelectedFromAddList() {
// Set flag for editing lists
- setEditListsFlag();
+ edited = true;
// Add new list in model
- getModel().addNewList(listName);
+ getModel().addNewList(servicePoll, listName);
// Set the new list as selected one
setSelectedList(listName);
// Reset form field before refresh form
@@ -451,7 +452,7 @@
@Log
void onSelectedFromEditList(String listName) {
// Set flag for editing lists
- setEditListsFlag();
+ edited = true;
// Set the selected list
setSelectedList(listName);
}
@@ -460,7 +461,7 @@
// Change current list, will save the previous current one
// Errors can appear during saving previous participants.
try {
- getModel().setCurrentList(listName);
+ getModel().setCurrentList(manager, listName);
} catch (PollenBusinessException eee) {
String message = manager.getErrorMessage(eee, messages, logger);
listsFeedback.addError(message);
@@ -476,7 +477,7 @@
/** PARTICIPANTS FOR LIST ** */
Object onAddRowFromParticipants() {
- return getListModel().addNewParticipant();
+ return getListModel().addNewParticipant(servicePoll, manager);
}
void onRemoveRowFromParticipants(Participant participant) {
@@ -488,12 +489,8 @@
return listsZone.getBody();
}
- protected void setEditListsFlag() {
- editLists = true;
- }
+ /** ********************** CHOIX **************************************** */
- /** *********************** CHOIX **************************************** */
-
@Property
private ChoiceField choice;
@@ -518,20 +515,21 @@
* @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;
+// 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();
}
public Block getChoiceTypeBlock() {
@@ -552,12 +550,17 @@
private PollStep step;
+ private boolean edited;
+
@Property
private boolean refreshChoicesZone;
@InjectComponent
private Zone choicesZone;
+ @Inject
+ private ServiceImage serviceImage;
+
@Log
Object onChangeFromChoiceType(String value) {
ChoiceType type = ChoiceType.valueOf(value);
@@ -575,11 +578,13 @@
@Log
void onSelectedFromChoiceStep() {
step = PollStep.CHOICES;
+ edited = true;
}
@Log
void onSelectedFromMainStep() {
step = PollStep.MAIN;
+ edited = true;
}
public boolean isChoiceStep() {
@@ -590,11 +595,35 @@
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);
+ }
+ }
+ }
+
+ @Log
Object onSuccess() {
-// if (!editLists) {
-// saveCurrentList();
-// }
return mainZone;
}
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-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-05-20 10:42:31 UTC (rev 3004)
@@ -21,14 +21,20 @@
package org.chorem.pollen.ui.services;
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.ioc.util.CaseInsensitiveMap;
+import org.apache.tapestry5.runtime.Component;
+import org.apache.tapestry5.services.ComponentSource;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenContext;
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;
@@ -123,19 +129,53 @@
return context.createPollenUrlId();
}
- public String getErrorMessage(PollenBusinessException eee,
+ public String getErrorMessage(PollenBusinessException error,
Messages messages, Logger logger) {
if (logger.isDebugEnabled()) {
- logger.debug("ERROR from business : " + eee.getMessage() +
- " _ args = " + Arrays.toString(eee.getArgs()));
+ logger.debug("ERROR from business : " + error.getMessage() +
+ " _ args = " + Arrays.toString(error.getArgs()));
}
String message = null;
- if (eee.getArgs() != null) {
- message = messages.format(eee.getMessage(), eee.getArgs());
+ if (error.getArgs() != null) {
+ message = messages.format(error.getMessage(), error.getArgs());
} else {
- message = messages.get(eee.getMessage());
+ message = messages.get(error.getMessage());
}
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());
+ }
+ }
+
+ public void recordFormErrors(ErrorReport report,
+ Form form, ComponentSource componentSource)
+ throws ClassCastException {
+
+ for (Map.Entry<String, String> entry : report.getFieldErrors().entrySet()) {
+ Field field = getFieldByName(entry.getKey(), componentSource);
+ form.recordError(field, entry.getValue());
+ }
+ for (String message : report.getErrors()) {
+ form.recordError(message);
+ }
+ }
+
+ protected Field getFieldByName(String field, ComponentSource componentSource)
+ throws ClassCastException {
+ Component component = componentSource.getComponent(field);
+ if (!(component instanceof Field)) {
+ throw new ClassCastException("invalid cast to Field from : " +
+ component.getClass().getName());
+ }
+ return (Field) component;
+ }
+
}
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-19 18:25:58 UTC (rev 3003)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-20 10:42:31 UTC (rev 3004)
@@ -5,50 +5,57 @@
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
-<h1 class="titlePoll">
+ <h1 class="titlePoll">
<t:if t:test="createMode">
- ${message:mainTitle-create}
- <p:else>${poll.title}</p:else>
+ ${message:mainTitle-create}
+ <p:else>${poll.title}</p:else>
</t:if>
-</h1>
+ </h1>
-<t:zone t:id="mainZone" t:update="show">
-<form t:type="form" t:id="mainForm" t:zone="mainZone" action="post">
-<t:errors />
-<t:formFragment t:id="mainFormFragment" t:visible="mainStep">
+ <t:zone t:id="mainZone" t:update="show">
+ <form t:type="form" t:id="mainForm" t:zone="mainZone" action="post">
+ <t:errors />
+ <t:formFragment t:id="mainFormFragment" t:visible="mainStep">
-<!-- MAIN INFOS -->
-<div id="p-pollForm-mainInfos">
- <fieldset>
- <legend>
- <img class="form-toggle" src="${asset:context:img/1uparrow.png}" /> ${message:legend-mainInfos}
- </legend>
- <div class="form-block">
- <p>
- <span><label t:type="label" t:for="title" />:</span>
+ <!-- MAIN INFOS -->
+ <div id="p-pollForm-mainInfos">
+ <fieldset>
+ <legend>
+ <img class="form-toggle"
+ src="${asset:context:img/1uparrow.png}" alt="toggle" /> ${message:legend-mainInfos}
+ </legend>
+ <div class="form-block">
+ <p>
+ <span><label t:type="label" t:for="title" />:
+ </span>
<input type="text" t:type="textfield" class="title" t:id="title"
value="poll.title" t:validate="required" />
- </p>
+ </p>
- <p>
- <span><label t:type="label" t:for="creatorName" />:</span>
+ <p>
+ <span><label t:type="label" t:for="creatorName" />:
+ </span>
<input type="text" t:type="textfield" t:id="creatorName"
value="poll.creator.name"
t:validate="required,minlength=2" />
<label t:type="label" t:for="email" />:
<input type="text" t:type="textfield" class="email" t:id="email"
value="poll.creator.email" t:validate="regexp" />
- </p>
+ </p>
- <p>
- <span><label t:type="label" t:for="description" />: </span>
+ <p>
+ <span><label t:type="label" t:for="description" />:
+ </span>
<textarea t:type="textarea" cols="80" rows="2"
- t:id="description" t:value="poll.description">${poll.description}</textarea>
- </p>
+ t:id="description" t:value="poll.description">
+ ${poll.description}
+ </textarea>
+ </p>
- <p>
+ <p>
<!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
- <span><label t:type="label" t:for="beginDate" />: </span>
+ <span><label t:type="label" t:for="beginDate" />:
+ </span>
<input t:type="ck/dateTimeField" t:id="beginDate"
value="poll.beginDate" t:validate="regexp"
t:datePattern="message:date-pattern" t:timePicker="true"
@@ -62,370 +69,371 @@
<label t:type="label" t:for="voteCountingType" />:
<select t:type="select" t:id="voteCountingType"
t:value="poll.voteCountingType" t:validate="required">
- <option></option>
+ <option></option>
</select>
- <span t:type="ck/Tooltip" title="${message:help}"
- t:value="${message:voteCounting-help}"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="${message:help}" />
- </span>
- </p>
+ <span t:type="ck/Tooltip" title="${message:help}"
+ t:value="${message:voteCounting-help}"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="${message:help}" />
+ </span>
+ </p>
+ </div>
+ </fieldset>
</div>
- </fieldset>
-</div>
-<!-- OPTIONS -->
-<div id="p-pollForm-options">
- <fieldset>
- <legend>
- <!--<input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/>-->
- <!--<label t:type="label" t:for="advancedOptions"/>-->
- <img class="form-toggle"
- src="${asset:context:img/1downarrow.png}" /> ${message:legend-options}
- </legend>
- <div class="form-block clearfix" style="display:none;">
- <!--<t:formFragment t:id="optionsFragment" visible="advancedOptions">-->
- <!-- LEFT COLUMN -->
- <div class="left-column fleft">
+ <!-- OPTIONS -->
+ <div id="p-pollForm-options">
+ <fieldset>
+ <legend>
+ <!--<input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/>-->
+ <!--<label t:type="label" t:for="advancedOptions"/>-->
+ <img class="form-toggle"
+ src="${asset:context:img/1downarrow.png}" /> ${message:legend-options}
+ </legend>
+ <div class="form-block clearfix" style="display:none;">
+ <!--<t:formFragment t:id="optionsFragment" visible="advancedOptions">-->
+ <!-- LEFT COLUMN -->
+ <div class="left-column fleft">
<p>
- <input t:type="checkbox" t:id="anonymous"
- value="poll.anonymous" />
- <label t:type="label" t:for="anonymous" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:anonymous-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="anonymous"
+ value="poll.anonymous" />
+ <label t:type="label" t:for="anonymous" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:anonymous-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <input t:type="checkbox" t:id="continuousResults"
- value="poll.continuousResults" />
- <label t:type="label" t:for="continuousResults" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:continuousResults-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="continuousResults"
+ value="poll.continuousResults" />
+ <label t:type="label" t:for="continuousResults" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:continuousResults-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <input t:type="checkbox" t:id="choiceAddAllowed"
- value="poll.choiceAddAllowed"
- t:mixins="triggerfragment"
- t:fragment="choiceDateFragment" />
- <label t:type="label" t:for="choiceAddAllowed" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:choiceAddAllowed-help}"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="choiceAddAllowed"
+ value="poll.choiceAddAllowed"
+ t:mixins="triggerfragment"
+ t:fragment="choiceDateFragment" />
+ <label t:type="label" t:for="choiceAddAllowed" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:choiceAddAllowed-help}"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <t:formFragment t:id="choiceDateFragment"
- t:visible="poll.choiceAddAllowed">
- <label t:type="label" t:for="beginChoiceDate" />
- <input t:type="ck/dateTimeField" t:id="beginChoiceDate"
- value="poll.beginChoiceDate" t:validate="regexp"
- t:datePattern="message:date-pattern"
- t:timePicker="true"
- t:timePickerAdjacent="true" />
- <br />
- <label t:type="label" t:for="endChoiceDate" />
- <input t:type="ck/dateTimeField" t:id="endChoiceDate"
- value="poll.endChoiceDate" t:validate="regexp"
- t:datePattern="message:date-pattern"
- t:timePicker="true"
- t:timePickerAdjacent="true" />
- </t:formFragment>
+ <t:formFragment t:id="choiceDateFragment"
+ t:visible="poll.choiceAddAllowed">
+ <label t:type="label" t:for="beginChoiceDate" />
+ <input t:type="ck/dateTimeField" t:id="beginChoiceDate"
+ value="poll.beginChoiceDate" t:validate="regexp"
+ t:datePattern="message:date-pattern"
+ t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ <br />
+ <label t:type="label" t:for="endChoiceDate" />
+ <input t:type="ck/dateTimeField" t:id="endChoiceDate"
+ value="poll.endChoiceDate" t:validate="regexp"
+ t:datePattern="message:date-pattern"
+ t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ </t:formFragment>
</p>
<p>
- <input t:type="checkbox" t:id="sendNotification"
- value="hasNotification"
- disabled="notificationDisabled"
- t:mixins="triggerfragment"
- t:fragment="notificationFragment" />
- <label t:type="label" t:for="sendNotification" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:sendNotification-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="sendNotification"
+ value="hasNotification"
+ disabled="notificationDisabled"
+ t:mixins="triggerfragment"
+ t:fragment="notificationFragment" />
+ <label t:type="label" t:for="sendNotification" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:sendNotification-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <t:formFragment id="notificationHidden"
- t:id="notificationFragment"
- t:visible="hasNotification">
- <label t:type="label" t:for="notification" />
- <input t:type="textfield" t:id="notification"
- value="notification.sensibility" t:size="3"
- t:validate="min=0" />
- ${message:notification-label2}
- </t:formFragment>
+ <t:formFragment id="notificationHidden"
+ t:id="notificationFragment"
+ t:visible="hasNotification">
+ <label t:type="label" t:for="notification" />
+ <input t:type="textfield" t:id="notification"
+ value="notification.sensibility" t:size="3"
+ t:validate="min=0" />
+ ${message:notification-label2}
+ </t:formFragment>
</p>
- </div>
- <!-- RIGHT COLUMN -->
- <div class="fleft">
+ </div>
+ <!-- RIGHT COLUMN -->
+ <div class="fleft">
<p>
- <input t:type="checkbox" t:id="anonymousVoteAllowed"
- value="poll.anonymousVoteAllowed"
- disabled="anonymousVoteAllowedDisabled" />
- <label t:type="label" t:for="anonymousVoteAllowed" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:anonymousVoteAllowed-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="anonymousVoteAllowed"
+ value="poll.anonymousVoteAllowed"
+ disabled="anonymousVoteAllowedDisabled" />
+ <label t:type="label" t:for="anonymousVoteAllowed" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:anonymousVoteAllowed-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <input t:type="checkbox" t:id="publicResults"
- value="poll.publicResults"
- disabled="publicResultsDisabled" />
- <label t:type="label" t:for="publicResults" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:publicResults-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="publicResults"
+ value="poll.publicResults"
+ disabled="publicResultsDisabled" />
+ <label t:type="label" t:for="publicResults" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:publicResults-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb"
- disabled="choiceNbDisabled"
- t:mixins="triggerFragment"
- t:fragment="choiceNbFragment" />
- <label t:type="label" t:for="choiceNb" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:choiceNb-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb"
+ disabled="choiceNbDisabled"
+ t:mixins="triggerFragment"
+ t:fragment="choiceNbFragment" />
+ <label t:type="label" t:for="choiceNb" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:choiceNb-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <t:formFragment id="choiceNbHidden" t:id="choiceNbFragment"
- t:visible="hasChoiceNb">
- <label t:type="label" t:for="maxChoiceNb" />
- <input t:type="textfield" t:id="maxChoiceNb"
- t:value="poll.maxChoiceNb" t:size="1"
- t:validate="min=0" />
- </t:formFragment>
+ <t:formFragment id="choiceNbHidden" t:id="choiceNbFragment"
+ t:visible="hasChoiceNb">
+ <label t:type="label" t:for="maxChoiceNb" />
+ <input t:type="textfield" t:id="maxChoiceNb"
+ t:value="poll.maxChoiceNb" t:size="1"
+ t:validate="min=0" />
+ </t:formFragment>
</p>
<p>
- <input t:type="checkbox" t:id="sendReminder"
- t:value="hasReminder" disabled="reminderDisabled"
- t:mixins="triggerfragment"
- t:fragment="reminderFragment" />
- <label t:type="label" t:for="sendReminder" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:sendReminder-help"
- t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <input t:type="checkbox" t:id="sendReminder"
+ t:value="hasReminder" disabled="reminderDisabled"
+ t:mixins="triggerfragment"
+ t:fragment="reminderFragment" />
+ <label t:type="label" t:for="sendReminder" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:sendReminder-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
+ </span>
</p>
<p>
- <t:formFragment id="reminderHidden" t:id="reminderFragment"
- t:visible="hasReminder">
- <input t:type="textfield" t:id="reminder"
- t:value="reminder.sensibility" t:size="1"
- t:validate="min=0" />
- <label t:type="label" t:for="reminder" />
- </t:formFragment>
+ <t:formFragment id="reminderHidden" t:id="reminderFragment"
+ t:visible="hasReminder">
+ <input t:type="textfield" t:id="reminder"
+ t:value="reminder.sensibility" t:size="1"
+ t:validate="min=0" />
+ <label t:type="label" t:for="reminder" />
+ </t:formFragment>
</p>
+ </div>
+ <!--</t:formFragment>-->
</div>
- <!--</t:formFragment>-->
+ </fieldset>
</div>
- </fieldset>
-</div>
-<!-- LISTS -->
-<div id="p-pollForm-lists">
- <fieldset>
- <legend>
- <label t:type="label" t:for="pollType" />:
- <!--<select t:type="select" t:id="pollType" class="list-select" t:value="poll.pollType" t:validate="required"-->
- <!--t:mixins="nuiton/zoneUpdater" t:event="change" t:zone="p-pollForm-lists-zone" />-->
- <select t:type="select" t:id="pollType" t:value="poll.pollType"
- t:validate="required"
- t:mixins="ck/onEvent" t:event="change"
- t:onCompleteCallback="onConfirmRefreshZone" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:pollType-help" t:effect="appear">
+ <!-- LISTS -->
+ <div id="p-pollForm-lists">
+ <fieldset>
+ <legend>
+ <label t:type="label" t:for="pollType" />:
+ <!--<select t:type="select" t:id="pollType" class="list-select" t:value="poll.pollType" t:validate="required"-->
+ <!--t:mixins="nuiton/zoneUpdater" t:event="change" t:zone="p-pollForm-lists-zone" />-->
+ <select t:type="select" t:id="pollType" t:value="poll.pollType"
+ t:validate="required"
+ t:mixins="ck/onEvent" t:event="change"
+ t:onCompleteCallback="onConfirmRefreshZone" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:pollType-help" t:effect="appear">
<img src="${asset:context:img/help.png}" alt="message:help" />
- </span>
- </legend>
- <div t:type="zone" t:id="listsZone" id="p-pollForm-lists-zone"
- class="form-block" t:update="show">
- <t:if t:test="canDisplayLists()">
+ </span>
+ </legend>
+ <div t:type="zone" t:id="listsZone" id="p-pollForm-lists-zone"
+ class="form-block" t:update="show">
+ <t:if t:test="canDisplayLists()">
<t:nuiton.feedback t:id="listsFeedback" />
<br />
<t:subForm t:visible="refreshListsZone">
- <t:if t:test="poll.pollType.group">
- <p>
- <label t:type="label" t:for="groupName" />:
- <input t:type="textfield" t:id="groupName"
- value="listName" />
- <input t:type="submit" t:id="addList"
- value="${message:pollen.ui.button.add}" />
- </p>
+ <t:if t:test="poll.pollType.group">
+ <p>
+ <label t:type="label" t:for="groupName" />:
+ <input t:type="textfield" t:id="groupName"
+ value="listName" />
+ <input t:type="submit" t:id="addList"
+ value="${message:pollen.ui.button.add}" />
+ </p>
- <p class="center">
- <t:loop t:source="lists" t:value="list"
- t:encoder="model">
- <input class="list-edition${styleSelected}"
- t:type="nuiton/submitContext"
- t:context="list.name" t:id="editList"
- value="${list.name}" />
- <t:if t:test="currentListSelected">
- <a t:type="actionlink" t:id="removeList"
- t:zone="p-pollForm-lists-zone">
- <span t:type="any"
- t:mixins="nuiton/confirm">
- <img src="${asset:context:img/delete.png}"
- alt="${message:delete}" />
- </span>
- </a>
- </t:if>
- </t:loop>
- </p>
- </t:if>
- <t:if t:test="listSelected">
- <div class="t-data-grid">
- <table class="t-data-grid">
- <thead>
- <tr>
- <th>
- ${message:pollen.ui.participant.name-label}
- </th>
- <th>
- ${message:pollen.ui.participant.email-label}
- </th>
- <th>
- ${message:pollen.ui.participant.weight-label}
- </th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <tr t:type="ajaxformloop" t:id="participants"
- source="listModel.participants"
- value="participant" t:encoder="listModel">
- <td>
- <t:textfield t:id="participantName"
- value="participant.name"
- size="20"
- t:validate="required" />
- </td>
- <td>
- <t:textfield t:id="participantEmail"
- value="participant.email"
- size="25" />
- </td>
- <td>
- <t:textfield t:id="participantWeight"
- value="participant.weight"
- size="1" />
- </td>
- <td>
- <t:removerowlink>
- <img src="${asset:context:img/delete.png}"
- alt="${message:delete}" />
- </t:removerowlink>
- </td>
- <p:addRow>
- <td colspan="4" class="center">
- <t:addrowlink>
- ${message:pollen.ui.participant.add}
- </t:addrowlink>
- </td>
- </p:addRow>
- </tr>
- </tbody>
- </table>
- </div>
- </t:if>
+ <p class="center">
+ <t:loop t:source="lists" t:value="list"
+ t:encoder="model">
+ <input class="list-edition${styleSelected}"
+ t:type="nuiton/submitContext"
+ t:context="list.name" t:id="editList"
+ value="${list.name}" />
+ <t:if t:test="currentListSelected">
+ <a t:type="actionlink" t:id="removeList"
+ t:zone="p-pollForm-lists-zone">
+ <span t:type="any"
+ t:mixins="nuiton/confirm">
+ <img src="${asset:context:img/delete.png}"
+ alt="${message:delete}" />
+ </span>
+ </a>
+ </t:if>
+ </t:loop>
+ </p>
+ </t:if>
+ <t:if t:test="listSelected">
+ <div class="t-data-grid">
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <th>
+ ${message:pollen.ui.participant.name-label}
+ </th>
+ <th>
+ ${message:pollen.ui.participant.email-label}
+ </th>
+ <th>
+ ${message:pollen.ui.participant.weight-label}
+ </th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="ajaxformloop" t:id="participants"
+ source="listModel.participants"
+ value="participant" t:encoder="listModel">
+ <td>
+ <t:textfield t:id="participantName"
+ value="participant.name"
+ size="20"
+ t:validate="required" />
+ </td>
+ <td>
+ <t:textfield t:id="participantEmail"
+ value="participant.email"
+ size="25" />
+ </td>
+ <td>
+ <t:textfield t:id="participantWeight"
+ value="participant.weight"
+ size="1" />
+ </td>
+ <td>
+ <t:removerowlink>
+ <img src="${asset:context:img/delete.png}"
+ alt="${message:delete}" />
+ </t:removerowlink>
+ </td>
+ <p:addRow>
+ <td colspan="4" class="center">
+ <t:addrowlink>
+ ${message:pollen.ui.participant.add}
+ </t:addrowlink>
+ </td>
+ </p:addRow>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </t:if>
</t:subForm>
- </t:if>
+ </t:if>
+ </div>
+ </fieldset>
+ <p class="center">
+ <input t:type="submit" t:id="choiceStep" value="CHOICE" />
+ </p>
</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">
+ </t:formFragment>
+ <t:formFragment t:id="choiceFormFragment" t:visible="choiceStep">
- <!-- CHOICES -->
- <div id="p-pollForm-choices">
- <fieldset>
+ <!-- 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" />
+ <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: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" />
- </p>
-</t:formFragment>
-</form>
-</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" />
+ </p>
+ </t:formFragment>
+ </form>
+ </t:zone>
</html>
1
0
r3003 - in trunk: pollen-business/src/main/xmi pollen-ui/src/main/java/org/chorem/pollen/ui/components pollen-ui/src/main/java/org/chorem/pollen/ui/data pollen-ui/src/main/java/org/chorem/pollen/ui/models pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll pollen-ui/src/main/resources/i18n pollen-ui/src/main/webapp/js pollen-ui/src/main/webapp/poll
by fdesbois@users.chorem.org 19 May '10
by fdesbois@users.chorem.org 19 May '10
19 May '10
Author: fdesbois
Date: 2010-05-19 20:25:58 +0200 (Wed, 19 May 2010)
New Revision: 3003
Url: http://chorem.org/repositories/revision/pollen/3003
Log:
- Use listeners to check changes on lists
- Uncomment choices managment -> other formFragment
- Inversion of subForm boolean
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollStep.java
Modified:
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.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/js/pollen.js
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java 2010-05-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java 2010-05-19 18:25:58 UTC (rev 3003)
@@ -30,8 +30,8 @@
logger.debug("form already visible : " + visible);
}
if (visible) {
- return noFormBlock;
+ return formBlock;
}
- return formBlock;
+ return noFormBlock;
}
}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollStep.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollStep.java 2010-05-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollStep.java 2010-05-19 18:25:58 UTC (rev 3003)
@@ -1,32 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.ui.data;
-
-/** Énumération représentant les étapes du formulaire de création de sondage. */
-public enum PollStep {
- POLL(1), OPTIONS(2), LISTS(3), CHOICES(4);
-
- protected Integer index;
-
- private PollStep(Integer index) {
- this.index = index;
- }
-
- public Integer getIndex() {
- return index;
- }
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java 2010-05-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java 2010-05-19 18:25:58 UTC (rev 3003)
@@ -6,9 +6,13 @@
import org.chorem.pollen.entity.ParticipantList;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.ui.services.PollenManager;
+import org.nuiton.topia.persistence.TopiaEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -25,6 +29,8 @@
private static final Logger logger =
LoggerFactory.getLogger(ParticipantListModel.class);
+ public static final String PROPERTY_PARTICIPANTS = "participants";
+
protected ServicePoll service;
protected PollenManager manager;
@@ -33,6 +39,16 @@
protected ParticipantMap participants;
+ protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ protected final PropertyChangeListener participantsListener =
+ new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ firePropertyChange(PROPERTY_PARTICIPANTS, participants);
+ }
+ };
+
public ParticipantListModel(ServicePoll service, PollenManager manager) {
this.service = service;
this.manager = manager;
@@ -43,6 +59,8 @@
Participant newParticipant = service.getNewPollParticipant();
String id = manager.createPollenId();
participants.put(id, newParticipant);
+ ((TopiaEntity) newParticipant).addPropertyListener(participantsListener);
+ firePropertyChange(PROPERTY_PARTICIPANTS, participants);
return newParticipant;
}
@@ -51,6 +69,8 @@
logger.debug("Remove participant : " + participant);
}
participants.remove(participant);
+ ((TopiaEntity) participant).removePropertyListener(participantsListener);
+ firePropertyChange(PROPERTY_PARTICIPANTS, participants);
}
public Collection<Participant> getParticipants() {
@@ -115,6 +135,34 @@
}
/**
+ * addPropertyChangeListener :
+ *
+ * @param listener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * removePropertyChangeListener :
+ *
+ * @param listener
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * firePropertyChange :
+ *
+ * @param propertyName
+ * @param newValue
+ */
+ protected void firePropertyChange(String propertyName, Object newValue) {
+ pcs.firePropertyChange(propertyName, null, newValue);
+ }
+
+ /**
* Participant map is a BidiMap ordered on values inserted using a {@link
* LinkedHashMap}.
*/
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-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-19 18:25:58 UTC (rev 3003)
@@ -13,6 +13,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -38,6 +40,8 @@
/** Default listName for Restricted Poll */
private static final String DEFAULT_LIST_NAME = "LIST";
+ public static final String PROPERTY_LISTS = "lists";
+
/** Service to manage poll */
protected ServicePoll service;
@@ -52,6 +56,16 @@
protected boolean createMode;
+ protected boolean listsChanged;
+
+ protected final PropertyChangeListener listsListener =
+ new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ listsChanged = true;
+ }
+ };
+
/**
* Constructor of PollFormModel. Need services {@code servicePoll} and
* {@code manager} to manage the current edited poll. Use {@link
@@ -64,7 +78,8 @@
PollenManager manager) {
this.service = servicePoll;
lists = new LinkedHashMap<String, ParticipantList>();
- this.listModel = new ParticipantListModel(service, manager);
+ listModel = new ParticipantListModel(service, manager);
+ listModel.addPropertyChangeListener(listsListener);
}
/**
@@ -130,8 +145,13 @@
listModel.reset();
}
poll.setPollType(type);
+ listsChanged = false;
}
+ public boolean isListsChanged() {
+ return listsChanged;
+ }
+
/**
* Retrieve a collection of {@link ParticipantList} of current lists.
*
@@ -176,6 +196,7 @@
logger.debug("Add list : " + listName);
}
lists.put(listName, list);
+ listsChanged = true;
result = true;
} else if (logger.isDebugEnabled()) {
logger.debug("Refuse adding list : " + listName);
@@ -238,6 +259,7 @@
getLists().remove(listModel.getList());
listModel.reset();
+ listsChanged = true;
}
/**
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-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-19 18:25:58 UTC (rev 3003)
@@ -1,7 +1,9 @@
package org.chorem.pollen.ui.pages.poll;
import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
import org.apache.tapestry5.RenderSupport;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
@@ -14,9 +16,12 @@
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.json.JSONObject;
import org.chorem.pollen.PollenBusinessException;
+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.Participant;
import org.chorem.pollen.entity.ParticipantList;
import org.chorem.pollen.entity.Poll;
@@ -27,6 +32,7 @@
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.ChoiceField;
import org.chorem.pollen.ui.models.ParticipantListModel;
import org.chorem.pollen.ui.models.PollFormModel;
import org.chorem.pollen.ui.services.PollenManager;
@@ -35,8 +41,10 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.List;
/**
* PollForm : Creation and Modification.
@@ -115,6 +123,7 @@
model = null;
initOptions();
listsFeedback.clearErrors();
+ step = PollStep.MAIN;
}
/**
@@ -206,7 +215,8 @@
}
if (formId != null) {
// Script for form interactions : see "webapp/js/pollForm.js"
- renderSupport.addScript("new PollForm('%s', '%s', '%s', '%s');",
+ renderSupport.addScript("var pollForm = " +
+ "new PollForm('%s', '%s', '%s', '%s');",
formId,
VoteCountingType.NORMAL,
PollType.FREE,
@@ -225,71 +235,6 @@
// advancedOptions = false;
// }
- /************************** CHOIX *****************************************/
-
-// @Property
-// private ChoiceField choice;
-//
-// private List<ChoiceField> choices;
-//
-// @Inject
-// private Block choiceText;
-//
-// @Inject
-// private Block choiceDate;
-//
-// @Inject
-// private Block choiceImage;
-//
-// private boolean refresh;
-//
-// /**
-// * 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 {
-// 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;
-// }
-//
-// public Block getChoiceTypeBlock() {
-// switch(poll.getChoiceType()) {
-// case DATE:
-// return choiceDate;
-// case IMAGE:
-// return choiceImage;
-// default:
-// return choiceText;
-// }
-// }
-//
-// void onSelectedFromRefreshOptions() {
-// refresh = true;
-// }
-//
-// // TEMP
-// @Log
-// Object onSuccessFromMainForm() {
-// if (!refresh) {
-//
-// }
-// return mainForm;
-// }
-
/************************** OPTIONS ***************************************/
/** Synchronization with anonymous and anonymousVoteAllowed options * */
@@ -397,7 +342,7 @@
return getPoll().getPollType().isFree();
}
- /** ******************** LISTS **************************************** */
+ /** ******************* LISTS **************************************** */
@Inject
private ComponentResources resources;
@@ -422,11 +367,13 @@
/** Flag for subForm used for lists managment */
@Property
- private boolean formActivate;
+ private boolean refreshListsZone;
/** Flag if submit comes from lists edition */
private boolean editLists;
+ protected static final String EVENT_UPDATE_POLL_TYPE = "updatePollType";
+
/** DATA ** */
public ParticipantListModel getListModel() {
@@ -448,14 +395,28 @@
/** PollType change ** */
@Log
- Object onChangeFromPollType(String value) {
- PollType type = PollType.valueOf(value);
- getModel().setPollType(type);
- if (type.isRestrictedOrGroup()) {
- listsFeedback.addInfo("Edition en cours d'une liste restreinte. " +
- "Attention un changement de type de restriction provoquera" +
- " une remise à zéro de la/les liste(s) en cours d'édition.");
+ JSONObject onChangeFromPollType(String value) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Lists changed : " + getModel().isListsChanged());
}
+ // Prepare Json response for javascript callback method
+ JSONObject json = new JSONObject();
+ Link link = resources.createEventLink(EVENT_UPDATE_POLL_TYPE, value);
+ json.put("link", link.toAbsoluteURI());
+ json.put("zoneId", "p-pollForm-lists-zone");
+ // Add confirm message only if changed appears
+ if (getModel().isListsChanged()) {
+ // 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"));
+ }
+ return json;
+ }
+
+ @Log
+ Object onUpdatePollType(String value) {
+ getModel().setPollType(PollType.valueOf(value));
return refreshListZone();
}
@@ -522,17 +483,114 @@
getListModel().removeParticipant(participant);
}
- protected Object refreshListZone() {
- formActivate = false;
+ Object refreshListZone() {
+ refreshListsZone = true;
return listsZone.getBody();
}
protected void setEditListsFlag() {
- formActivate = true;
editLists = true;
}
+ /** *********************** CHOIX **************************************** */
+
+ @Property
+ private ChoiceField choice;
+
+ private List<ChoiceField> choices;
+
+ @Inject
+ private Block choiceText;
+
+ @Inject
+ private Block choiceDate;
+
+ @Inject
+ private Block choiceImage;
+
+ private boolean refresh;
+
+ /**
+ * 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
+ *
+ * @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;
+ }
+
+ public Block getChoiceTypeBlock() {
+ switch (getPoll().getChoiceType()) {
+ case DATE:
+ return choiceDate;
+ case IMAGE:
+ return choiceImage;
+ default:
+ return choiceText;
+ }
+ }
+
+ private enum PollStep {
+
+ MAIN, CHOICES;
+ }
+
+ private PollStep step;
+
+ @Property
+ private boolean refreshChoicesZone;
+
+ @InjectComponent
+ private Zone choicesZone;
+
@Log
+ Object onChangeFromChoiceType(String value) {
+ ChoiceType type = ChoiceType.valueOf(value);
+ getPoll().setChoiceType(type);
+ refreshChoicesZone = true;
+ return choicesZone.getBody();
+ }
+
+ @Log
+ void onSelected() {
+ refreshListsZone = false;
+ refreshChoicesZone = false;
+ }
+
+ @Log
+ void onSelectedFromChoiceStep() {
+ step = PollStep.CHOICES;
+ }
+
+ @Log
+ void onSelectedFromMainStep() {
+ step = PollStep.MAIN;
+ }
+
+ public boolean isChoiceStep() {
+ return step.equals(PollStep.CHOICES);
+ }
+
+ public boolean isMainStep() {
+ return step.equals(PollStep.MAIN);
+ }
+
+ @Log
Object onSuccess() {
// if (!editLists) {
// saveCurrentList();
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-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-19 18:25:58 UTC (rev 3003)
@@ -51,11 +51,14 @@
pollen.ui.list.update.removeParticipant=Supprimer ce votant
pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous s\u00fbr de vouloir supprimer %1$s de la liste ?
pollen.ui.list.update.removeParticipant.success=Le votant a \u00e9t\u00e9 supprim\u00e9 avec succ\u00e8s.
+
pollen.ui.participant.name-label=Nom
pollen.ui.participant.email-label=Email
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 ?
+
# OLD LOGIN_COMPONENT
connectionLegend=Connexion
loginSubmit=Me connecter
@@ -65,6 +68,9 @@
passwordComp-required-message=Vous devez entrer votre mot de passe.
loginFailed=Mauvais identifiant ou mot de passe.
+# FORM:: poll
+groupName-label=Nom du groupe
+
# FORM:: user
firstName-label=Pr\u00e9nom
lastName-label=Nom
Modified: trunk/pollen-ui/src/main/webapp/js/pollen.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/pollen.js 2010-05-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/webapp/js/pollen.js 2010-05-19 18:25:58 UTC (rev 3003)
@@ -38,6 +38,19 @@
zoneManager.updateFromURL(response.link);
}
+function onConfirmRefreshZone(response) {
+ var zoneManager = Tapestry.findZoneManagerForZone(response.zoneId);
+
+ if (response.confirm) {
+ // Show confirm dialog for refresh
+ if (confirm(response.confirm)) {
+ zoneManager.updateFromURL(response.link);
+ }
+ } else {
+ zoneManager.updateFromURL(response.link);
+ }
+}
+
function triggerFragment(checkbox, fragment) {
fragment.toggle();
}
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-19 13:25:45 UTC (rev 3002)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-19 18:25:58 UTC (rev 3003)
@@ -15,6 +15,8 @@
<t:zone t:id="mainZone" t:update="show">
<form t:type="form" t:id="mainForm" t:zone="mainZone" action="post">
<t:errors />
+<t:formFragment t:id="mainFormFragment" t:visible="mainStep">
+
<!-- MAIN INFOS -->
<div id="p-pollForm-mainInfos">
<fieldset>
@@ -247,74 +249,35 @@
</div>
</fieldset>
</div>
-<!-- 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">-->
-<!--<option></option>-->
-<!--</select> -->
-<!--<input type="image" t:type="submit" class="ico refresh" t:id="refreshChoices" value="Refresh choices" title="${message:refreshChoices-button}"/>-->
-<!--</legend>-->
-<!--<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>-->
-<!--</fieldset>-->
-<!--</div>-->
<!-- LISTS -->
<div id="p-pollForm-lists">
<fieldset>
<legend>
<label t:type="label" t:for="pollType" />:
- <select t:type="select" class="list-select" t:id="pollType"
- t:value="poll.pollType" t:validate="required"
- t:mixins="nuiton/zoneUpdater" t:event="change"
- t:zone="p-pollForm-lists-zone" />
- <span t:type="ck/Tooltip" title="message:help"
- t:value="message:pollType-help" t:effect="appear">
- <img src="${asset:context:img/help.png}"
- alt="message:help" />
- </span>
+ <!--<select t:type="select" t:id="pollType" class="list-select" t:value="poll.pollType" t:validate="required"-->
+ <!--t:mixins="nuiton/zoneUpdater" t:event="change" t:zone="p-pollForm-lists-zone" />-->
+ <select t:type="select" t:id="pollType" t:value="poll.pollType"
+ t:validate="required"
+ t:mixins="ck/onEvent" t:event="change"
+ t:onCompleteCallback="onConfirmRefreshZone" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:pollType-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help" />
+ </span>
</legend>
- <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone"
+ <div t:type="zone" t:id="listsZone" id="p-pollForm-lists-zone"
class="form-block" t:update="show">
<t:if t:test="canDisplayLists()">
<t:nuiton.feedback t:id="listsFeedback" />
<br />
- <t:subForm t:visible="formActivate">
+ <t:subForm t:visible="refreshListsZone">
<t:if t:test="poll.pollType.group">
<p>
- <label t:type="label" t:for="listName" />:
- <input t:type="textfield" t:id="listName"
+ <label t:type="label" t:for="groupName" />:
+ <input t:type="textfield" t:id="groupName"
value="listName" />
- <input t:type="submit" t:id="addList" value="ADD" />
- <!--<a t:type="actionlink" t:id="addList" t:zone="p-pollForm-lists-zone">-->
- <!--ADD-->
- <!--</a>-->
+ <input t:type="submit" t:id="addList"
+ value="${message:pollen.ui.button.add}" />
</p>
<p class="center">
@@ -324,18 +287,14 @@
t:type="nuiton/submitContext"
t:context="list.name" t:id="editList"
value="${list.name}" />
- <!--<span t:type="any" t:mixins="nuiton/confirm">-->
- <!--<input t:type="nuiton/submitContext" t:id="removeList" t:image="context:img/delete.png" t:context="list.name" value="${message:delete}" />-->
- <!--</span>-->
<t:if t:test="currentListSelected">
- <!--<input t:type="submit" t:id="saveList" t:image="context:img/save.png" />-->
<a t:type="actionlink" t:id="removeList"
t:zone="p-pollForm-lists-zone">
- <span t:type="any"
- t:mixins="nuiton/confirm">
- <img src="${asset:context:img/delete.png}"
- alt="${message:delete}" />
- </span>
+ <span t:type="any"
+ t:mixins="nuiton/confirm">
+ <img src="${asset:context:img/delete.png}"
+ alt="${message:delete}" />
+ </span>
</a>
</t:if>
</t:loop>
@@ -398,32 +357,75 @@
</t:if>
</t:subForm>
</t:if>
- <!--<t:delegate t:to="listsBlock" />-->
- <!--<t:block t:id="listsForm">-->
- <!--<form t:type="form" action="tapestry">-->
- <!--<t:delegate t:to="listsFields" />-->
- <!--</form>-->
- <!--</t:block>-->
- <!--<t:block t:id="listsFields">-->
- <!--<t:if t:test="poll.pollType.group">-->
- <!--<p>-->
- <!--<label t:type="label" t:for="listName" />: -->
- <!--<input t:type="textfield" t:id="listName" value="listName"/> -->
- <!--<input t:type="submit" t:id="addList" value="ADD"/>-->
- <!--</p>-->
- <!--<p>-->
- <!--<t:loop t:source="lists.values()" t:value="list" t:volatile="true">-->
- <!--${list.name} -->
- <!--</t:loop>-->
- <!--</p>-->
- <!--<p:else>-->
- <!--COOL-->
- <!--</p:else>-->
- <!--</t:if>-->
- <!--</t:block> -->
</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" />
+ </p>
+</t:formFragment>
</form>
</t:zone>
</html>
1
0
r3002 - in trunk/pollen-ui/src/main/java/org/chorem/pollen/ui: . components data models pages/admin pages/poll pages/user
by fdesbois@users.chorem.org 19 May '10
by fdesbois@users.chorem.org 19 May '10
19 May '10
Author: fdesbois
Date: 2010-05-19 15:25:45 +0200 (Wed, 19 May 2010)
New Revision: 3002
Url: http://chorem.org/repositories/revision/pollen/3002
Log:
- Move models in a new package 'models'.
- Add poll instantiation in PollFormModel
- Add javadoc
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/FavoriteParticipantDataSource.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/GenericSelectModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.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
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericSelectModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java
Modified:
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/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -1,4 +1,3 @@
-
package org.chorem.pollen.ui.components;
import org.apache.tapestry5.annotations.InjectComponent;
@@ -15,7 +14,7 @@
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.service.ServiceFavorite;
import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.data.FavoriteParticipantDataSource;
+import org.chorem.pollen.ui.models.FavoriteParticipantDataSource;
import org.chorem.pollen.ui.services.PollenManager;
import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
@@ -27,7 +26,7 @@
* participant in the Grid and one to edit a participant directly in the grid.
* Each action will return the {@code updateZone} to refresh data loaded by
* {@link #getParticipants()} method.
- *
+ * <p/>
* Created: 27 avr. 2010
*
* @author fdesbois <fdesbois(a)codelutin.com>
@@ -35,11 +34,11 @@
*/
public class UserListsUpdate {
- /** Parameters of the component **/
+ /** Parameters of the component * */
@Parameter(required = true)
private FavoriteList source;
- /** Services injected **/
+ /** Services injected * */
@Inject
private Logger logger;
@@ -52,7 +51,7 @@
@Inject
private Messages messages;
- /** Main properties for Grid **/
+ /** Main properties for Grid * */
private EvenOdd evenOdd;
private FavoriteParticipantDataSource participants;
@@ -75,11 +74,11 @@
}
/**
- * Load participants data from serviceFavorite in a
- * {@link FavoriteParticipantDataSource} to manage pagination and order.
- * The filter added contains data for serviceFavorite (startIndex, endIndex,
- * orderBy and referenceId). The reference is set to the source FavoriteList
- * of the component, i.e. all FavoriteParticipants need to be part of the
+ * Load participants data from serviceFavorite in a {@link
+ * FavoriteParticipantDataSource} to manage pagination and order. The filter
+ * added contains data for serviceFavorite (startIndex, endIndex, orderBy
+ * and referenceId). The reference is set to the source FavoriteList of the
+ * component, i.e. all FavoriteParticipants need to be part of the
* FavoriteList source.
*
* @return the DataSource that contains participants.
@@ -100,20 +99,13 @@
/***************************** EDIT PARTICIPANT FORM **********************/
/**
- * FORM EVENTS ORDER -> RENDER :
- * load size of participants dataSource
- * call prepareForRender
- * load participants data
- *
- * FORM EVENTS ORDER -> SUBMIT :
- * call prepareForSubmit
- * load size of participants dataSource
- * load participants data
- * load participantEdited to push form data (hidden fields in first)
- * call selected on submit button
- * call validateForm
- * call success or failure
- * call submit
+ * FORM EVENTS ORDER -> RENDER : load size of participants dataSource call
+ * prepareForRender load participants data
+ * <p/>
+ * FORM EVENTS ORDER -> SUBMIT : call prepareForSubmit load size of
+ * participants dataSource load participants data load participantEdited to
+ * push form data (hidden fields in first) call selected on submit button
+ * call validateForm call success or failure call submit
*/
@InjectComponent
@@ -131,7 +123,7 @@
* Test if the edited participant is the current one in the Grid.
*
* @return true if the participantEdited is defined and correspond to the
- * current participant in the Grid
+ * current participant in the Grid
*/
public boolean isEditionMode() {
// The current participant in the loop is equals to the edited one
@@ -140,8 +132,8 @@
}
/**
- * ON_ACTION :: Handler method for action on editParticipant actionLink.
- * The participantEdited will be set to the participant selected in the Grid
+ * ON_ACTION :: Handler method for action on editParticipant actionLink. The
+ * participantEdited will be set to the participant selected in the Grid
* with {@code id}.
*
* @param id key of the participant from the Grid
@@ -181,15 +173,13 @@
}
/**
- * Getter to retrieve participantEdited.
- * <br \>
- * The participantEditedId is needed and was provided for render by the
- * {@link #onActionFromEditParticipant(String)} method and for submit by
- * the hidden field in the form that keep the id after rendering the form.
- * The participantEdited is loaded from the participants dataSource that
- * contains all FavoriteParticipant displayed in the Grid. The submit will
- * reload the participants dataSource before saving modification on the
- * FavoriteParticipant edited.
+ * Getter to retrieve participantEdited. <br \> The participantEditedId is
+ * needed and was provided for render by the {@link #onActionFromEditParticipant(String)}
+ * method and for submit by the hidden field in the form that keep the id
+ * after rendering the form. The participantEdited is loaded from the
+ * participants dataSource that contains all FavoriteParticipant displayed
+ * in the Grid. The submit will reload the participants dataSource before
+ * saving modification on the FavoriteParticipant edited.
*
* @return the FavoriteParticipant in edition
*/
@@ -202,7 +192,7 @@
participantEdited = participants.get(participantEditedId);
}
return participantEdited;
- }
+ }
/**
* ON_VALIDATE_FORM :: Handler method for validateForm event of the
@@ -227,9 +217,9 @@
/**
* ON_SUCCESS :: Handler 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.
+ * Clean form data (participantEdited) and display a success message. {@link
+ * #onSubmitFromParticipantsForm()} will be called after it to refresh the
+ * updateZone.
*/
void onSuccessFromParticipantsForm() {
participantsFeedback.addInfo(
@@ -239,8 +229,8 @@
}
/**
- * Clean the form content, i.e. the favorite participant in edition and
- * its id.
+ * Clean the form content, i.e. the favorite participant in edition and its
+ * id.
*/
protected void cleanFormData() {
participantEditedId = null;
@@ -258,7 +248,7 @@
return updateZone;
}
- /***************************** NEW PARTICIPANT FORM ***********************/
+ /** ************************** NEW PARTICIPANT FORM ********************** */
@Property
private FavoriteParticipant newParticipant;
@@ -276,7 +266,7 @@
void onPrepareFromAddParticipant() {
if (newParticipant == null) {
newParticipant =
- serviceFavorite.getNewFavoriteParticipant(source);
+ serviceFavorite.getNewFavoriteParticipant(source);
}
}
@@ -301,14 +291,14 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the addParticipant form.
- * Will display a success message. {@link #onSubmitFromAddParticipant()}
+ * ON_SUCCESS :: Handler method for success event of the addParticipant
+ * form. Will display a success message. {@link #onSubmitFromAddParticipant()}
* will be called after it to refresh the updateZone.
*/
void onSuccessFromAddParticipant() {
participantsFeedback.addInfo(
messages.format("pollen.ui.list.update.addParticipant.success",
- newParticipant.getName()));
+ newParticipant.getName()));
}
/**
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-05-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -1,68 +0,0 @@
-
-package org.chorem.pollen.ui.data;
-
-import java.util.Map;
-import org.apache.tapestry5.grid.SortConstraint;
-import org.chorem.pollen.PollenException;
-import org.chorem.pollen.bean.Filter;
-import org.chorem.pollen.entity.FavoriteParticipant;
-import org.chorem.pollen.service.ServiceFavorite;
-import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * UserAccountDataSource
- *
- * Created: 23 avr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class FavoriteParticipantDataSource extends
- AbstractMappedGridDataSource<String, FavoriteParticipant> {
-
- private static final Logger logger =
- LoggerFactory.getLogger(FavoriteParticipantDataSource.class);
-
- private ServiceFavorite service;
-
- private Filter filter;
-
- public FavoriteParticipantDataSource(ServiceFavorite service,
- Filter filter) {
- this.service = service;
- this.filter = filter;
- }
-
- @Override
- protected Map<String, FavoriteParticipant> execute(
- int startIndex, int endIndex, SortConstraint orderBy)
- throws PollenException {
- filter.setStartIndex(startIndex);
- filter.setEndIndex(endIndex);
- filter.setOrderBy(resolveOrderBy(orderBy));
- if (logger.isDebugEnabled()) {
- logger.debug("LOAD DATA");
- }
- return service.getFavoriteParticipants(filter);
- }
-
- @Override
- protected int count() throws PollenException {
- int count = service.getNbFavoriteParticipants(filter);
- if (logger.isDebugEnabled()) {
- logger.debug("Nb elements : " + count);
- }
- return count;
- }
-
- @Override
- public Class<?> getRowType() {
- return FavoriteParticipant.class;
- }
-
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericSelectModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericSelectModel.java 2010-05-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericSelectModel.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -1,129 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.ui.data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tapestry5.OptionGroupModel;
-import org.apache.tapestry5.OptionModel;
-import org.apache.tapestry5.ValueEncoder;
-import org.apache.tapestry5.corelib.components.Select;
-import org.apache.tapestry5.internal.OptionModelImpl;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.ioc.services.PropertyAdapter;
-import org.apache.tapestry5.util.AbstractSelectModel;
-
-/**
- * Generic selection model for a list of Objects. Adadpted from
- * http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects
- *
- * use:
- *
- * <pre>
- * @Inject
- * private PropertyAccess _access;
- * </pre>
- *
- * in your page to ge the {@link PropertyAccess} service.<br>
- * !Notice: you must set the created instance both as model and encoder
- * parameter for the {@link Select} component.
- * @param <T>
- */
-public class GenericSelectModel<T> extends AbstractSelectModel implements
- ValueEncoder<T> {
-
- private PropertyAdapter labelFieldAdapter;
- private PropertyAdapter idFieldAdapter;
- private List<T> list;
-
- public GenericSelectModel(List<T> list, Class<T> clazz, String labelField,
- String idField, PropertyAccess access) {
- this.list = list;
- if (idField != null) {
- this.idFieldAdapter =
- access.getAdapter(clazz).getPropertyAdapter(idField);
- }
- if (labelField != null) {
- this.labelFieldAdapter =
- access.getAdapter(clazz).getPropertyAdapter(labelField);
- }
- }
-
- @Override
- public List<OptionGroupModel> getOptionGroups() {
- return null;
- }
-
- @Override
- public List<OptionModel> getOptions() {
- List<OptionModel> optionModelList = new ArrayList<OptionModel>();
- if (labelFieldAdapter == null) {
- for (T obj : list) {
- optionModelList.add(new OptionModelImpl(nvl(obj), obj));
- }
- } else {
- for (T obj : list) {
- optionModelList.add(new OptionModelImpl(nvl(labelFieldAdapter
- .get(obj)), obj));
- }
- }
- return optionModelList;
- }
-
- public List<T> getList() {
- return list;
- }
-
- // ValueEncoder methods
-
- @Override
- public String toClient(T obj) {
- if (idFieldAdapter == null) {
- return obj + "";
- } else {
- return idFieldAdapter.get(obj) + "";
- }
- }
-
- @Override
- public T toValue(String string) {
- if (idFieldAdapter == null) {
- for (T obj : list) {
- if (nvl(obj).equals(string)) {
- return obj;
- }
- }
- } else {
- for (T obj : list) {
- if (nvl(idFieldAdapter.get(obj)).equals(string)) {
- return obj;
- }
- }
- }
- return null;
- }
-
- private String nvl(Object o) {
- if (o == null) {
- return "";
- }
- else {
- return o.toString();
- }
- }
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java 2010-05-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -1,160 +0,0 @@
-package org.chorem.pollen.ui.data;
-
-import org.apache.tapestry5.ValueEncoder;
-import org.chorem.pollen.PollenBusinessException;
-import org.chorem.pollen.entity.Participant;
-import org.chorem.pollen.entity.ParticipantList;
-import org.chorem.pollen.service.ServicePoll;
-import org.chorem.pollen.ui.services.PollenManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Created: 18 mai 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- * @version $Id$
- */
-public class ParticipantListModel implements ValueEncoder<Participant> {
-
- private static final Logger logger =
- LoggerFactory.getLogger(ParticipantListModel.class);
-
- protected ServicePoll service;
-
- protected PollenManager manager;
-
- protected ParticipantList list;
-
- protected ParticipantMap participants;
-
- public ParticipantListModel(ServicePoll service, PollenManager manager) {
- this.service = service;
- this.manager = manager;
- participants = new ParticipantMap();
- }
-
- public Participant addNewParticipant() {
- Participant newParticipant = service.getNewPollParticipant();
- String id = manager.createPollenId();
- participants.put(id, newParticipant);
- return newParticipant;
- }
-
- public void removeParticipant(Participant participant) {
- if (logger.isDebugEnabled()) {
- logger.debug("Remove participant : " + participant);
- }
- participants.remove(participant);
- }
-
- public Collection<Participant> getParticipants() {
- return participants.values();
- }
-
- public void setList(ParticipantList participantList) {
- if (logger.isDebugEnabled()) {
- logger.debug("Set current list : " + participantList.getName());
- }
- list = participantList;
- participants.clear();
- for (Participant participant : participantList.getParticipants()) {
- String id = participant.getId() != null ? participant.getId() :
- manager.createPollenId();
- if (logger.isTraceEnabled()) {
- logger.trace("Push participant : " +
- participant.getName() +
- " (" + participant.getEmail() + ")" +
- " ID = " + id);
- }
- participants.put(id, participant);
- }
- }
-
- public ParticipantList getList() {
- return list;
- }
-
- public void reset() {
- if (logger.isDebugEnabled()) {
- logger.debug("Reset current list");
- }
- list = null;
- participants.clear();
- }
-
- public void persistParticipants() throws PollenBusinessException {
- if (logger.isDebugEnabled()) {
- logger.debug("Save current list : " + list.getName());
- }
- list.setParticipants(getParticipants());
- }
-
- @Override
- public String toClient(Participant value) {
- String key = participants.getKey(value);
- if (logger.isTraceEnabled()) {
- logger.trace("toClient key = " + key);
- }
- return key;
- }
-
- @Override
- public Participant toValue(String key) {
- Participant value = participants.getValue(key);
- if (logger.isTraceEnabled()) {
- logger.trace("toValue from : " + key + " = " + value.getName() +
- " (" + value.getEmail() + ")");
- }
- return value;
- }
-
- /**
- * Participant map is a BidiMap ordered on values inserted using a {@link
- * LinkedHashMap}.
- */
- protected class ParticipantMap {
-
- protected Map<String, Participant> participants;
-
- protected Map<Participant, String> keys;
-
- public ParticipantMap() {
- participants = new LinkedHashMap<String, Participant>();
- keys = new HashMap<Participant, String>();
- }
-
- public void put(String id, Participant participant) {
- participants.put(id, participant);
- keys.put(participant, id);
- }
-
- public String getKey(Participant participant) {
- return keys.get(participant);
- }
-
- public Participant getValue(String id) {
- return participants.get(id);
- }
-
- public void clear() {
- keys.clear();
- participants.clear();
- }
-
- public void remove(Participant participant) {
- String id = keys.remove(participant);
- participants.remove(id);
- }
-
- public Collection<Participant> values() {
- return participants.values();
- }
-
- }
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java 2010-05-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -1,241 +0,0 @@
-package org.chorem.pollen.ui.data;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.ValueEncoder;
-import org.chorem.pollen.PollenBusinessException;
-import org.chorem.pollen.common.PollType;
-import org.chorem.pollen.entity.ParticipantList;
-import org.chorem.pollen.entity.Poll;
-import org.chorem.pollen.service.ServicePoll;
-import org.chorem.pollen.ui.pages.poll.PollForm;
-import org.chorem.pollen.ui.services.PollenManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Model for PollForm page. Contains the current {@code poll} and its
- * participant {@code lists}. Use {@link ParticipantListModel} to manage current
- * edited list for restricted or group Poll. Implement a {@link ValueEncoder} to
- * manage ParticipantList client conversion in PollForm page.
- * <p/>
- * Created: 18 mai 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- * @version $Id$
- * @see PollForm
- * @see ValueEncoder
- */
-public class PollFormModel implements ValueEncoder<ParticipantList> {
-
- private static final Logger logger =
- LoggerFactory.getLogger(PollFormModel.class);
-
- /** Default listName for Restricted Poll */
- private static final String DEFAULT_LIST_NAME = "LIST";
-
- /** Service to manage poll */
- protected ServicePoll service;
-
- /** Current poll in edition */
- protected Poll poll;
-
- /** Current lists in edition */
- protected Map<String, ParticipantList> lists;
-
- /** Current listModel that contains current edited list and its participants */
- protected ParticipantListModel listModel;
-
- /**
- * Constructor of PollFormModel. Initialize with edited {@code poll}. Need
- * services {@code servicePoll} and {@code manager} to manage the {@code
- * poll}.
- *
- * @param poll Current poll in edition
- * @param servicePoll ServicePoll to manage poll
- * @param manager PollenManager to manage ids
- */
- public PollFormModel(Poll poll,
- ServicePoll servicePoll,
- PollenManager manager) {
- this.poll = poll;
- this.service = servicePoll;
- lists = new LinkedHashMap<String, ParticipantList>();
- this.listModel = new ParticipantListModel(service, manager);
- }
-
- /**
- * 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
- * automatically added and set for current usage. For a {@link
- * PollType#GROUP} poll, the listModel is simply reset.
- *
- * @param type PollType to change
- */
- public void setPollType(PollType type) {
- lists.clear();
- if (type.isRestricted()) {
- addNewList(DEFAULT_LIST_NAME);
- // Set automatically the current list to the unique one
- listModel.setList(lists.get(DEFAULT_LIST_NAME));
- } else if (type.isGroup()) {
- listModel.reset();
- }
- poll.setPollType(type);
- }
-
- /**
- * Retrieve a collection of {@link ParticipantList} of current lists.
- *
- * @return a Collection<ParticipantList>
- */
- public Collection<ParticipantList> getLists() {
- return lists.values();
- }
-
- /**
- * Add a new list to the poll using the {@code listName}. The list will not
- * be added if the {@code listName} is empty or if a list with this {@code
- * listName} already exists.
- *
- * @param listName for the new list to add
- * @return true if the list has been added, false otherwise
- * @see #addList(ParticipantList)
- */
- public boolean addNewList(String listName) {
- boolean result = false;
- if (StringUtils.isNotEmpty(listName)) {
- ParticipantList newList = service.getNewPollList();
- newList.setName(listName);
- return addList(newList);
- }
- return result;
- }
-
- /**
- * Add a {@code list} to the poll. The {@code list} will not be added if its
- * name already reference an exising list.
- *
- * @param list ParticipantList to add
- * @return true if the list has been added, false otherwise
- */
- public boolean addList(ParticipantList list) {
- boolean result = false;
- if (list != null) {
- String listName = list.getName();
- if (!lists.containsKey(listName)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Add list : " + listName);
- }
- lists.put(listName, list);
- result = true;
- } else if (logger.isDebugEnabled()) {
- logger.debug("Refuse adding list : " + listName);
- }
- }
- return result;
- }
-
- /**
- * Give the current {@link ParticipantListModel} that references the list
- * currently edited.
- *
- * @return the current listModel
- */
- public ParticipantListModel getListModel() {
- return listModel;
- }
-
- /**
- * Set the current list using its {@code listName}. The previous current
- * list will be automatically saved. If error occurs during save, the
- * previous list will be refresh (no list change will be done).
- *
- * @param listName name of the list to set (empty name will be ignored)
- * @throws PollenBusinessException for saving error (doubloons)
- * @see #saveCurrentList()
- */
- public void setCurrentList(String listName) throws PollenBusinessException {
- if (StringUtils.isNotEmpty(listName)) {
- ParticipantList list = getCurrentList();
- try {
- // Save previous list if not null
- if (list != null) {
- saveCurrentList();
- }
- // Change list
- list = lists.get(listName);
- } finally {
- // Previous list will be keeped if error occurs during save.
- // Apply change in listModel
- listModel.setList(list);
- }
- }
- }
-
- /**
- * Get the current list.
- *
- * @return the current list in edition.
- */
- public ParticipantList getCurrentList() {
- return listModel.getList();
- }
-
- /** Remove the current list. */
- public void removeCurrentList() {
- if (logger.isDebugEnabled()) {
- logger.debug("Remove list : " + listModel.getList().getName());
- }
-
- getLists().remove(listModel.getList());
- listModel.reset();
- }
-
- /**
- * Save the current participants from current list.
- *
- * @throws PollenBusinessException for saving errors (doubloons)
- * @see ParticipantListModel#persistParticipants()
- */
- public void saveCurrentList() throws PollenBusinessException {
- listModel.persistParticipants();
- }
-
- public void create() throws PollenBusinessException {
- service.createPoll(poll, getLists());
- }
-
- /**
- * ValueEncoder toClient is used to convert {@code value} to the list name.
- *
- * @param value ParticipantList to convert toClient
- * @return the list name as a unique key for the list
- * @see ValueEncoder#toClient(Object)
- */
- @Override
- public String toClient(ParticipantList value) {
- return value.getName();
- }
-
- /**
- * ValueEncoder toClient is used to convert {@code clientValue} key to the
- * list object.
- *
- * @param clientValue List name of the ParticipantList to retrieve.
- * @return the ParticipantList corresponding to its name in argument
- * @see ValueEncoder#toValue(String)
- */
- @Override
- public ParticipantList toValue(String clientValue) {
- for (ParticipantList curr : lists.values()) {
- if (clientValue.equals(curr.getName())) {
- return curr;
- }
- }
- return null;
- }
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java 2010-05-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/UserAccountDataSource.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -1,53 +0,0 @@
-
-package org.chorem.pollen.ui.data;
-
-import java.util.Map;
-import org.apache.tapestry5.grid.SortConstraint;
-import org.chorem.pollen.PollenException;
-import org.chorem.pollen.bean.Filter;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.service.ServiceUser;
-import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
-
-/**
- * UserAccountDataSource
- *
- * Created: 23 avr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class UserAccountDataSource extends AbstractMappedGridDataSource<String, UserAccount> {
-
- private ServiceUser service;
-
- private Filter filter;
-
- public UserAccountDataSource(ServiceUser service, Filter filter) {
- this.service = service;
- this.filter = filter;
- }
-
- @Override
- protected Map<String, UserAccount> execute(int startIndex, int endIndex,
- SortConstraint orderBy) throws PollenException {
- filter.setStartIndex(startIndex);
- filter.setEndIndex(endIndex);
- filter.setOrderBy(resolveOrderBy(orderBy));
- return service.getUsers(filter);
- }
-
- @Override
- protected int count() throws PollenException {
- return service.getNbUsers(filter);
- }
-
- @Override
- public Class<?> getRowType() {
- return UserAccount.class;
- }
-
-}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/FavoriteParticipantDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/FavoriteParticipantDataSource.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/FavoriteParticipantDataSource.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -0,0 +1,68 @@
+package org.chorem.pollen.ui.models;
+
+import org.apache.tapestry5.grid.SortConstraint;
+import org.chorem.pollen.PollenException;
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.service.ServiceFavorite;
+import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * UserAccountDataSource
+ * <p/>
+ * Created: 23 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class FavoriteParticipantDataSource extends
+ AbstractMappedGridDataSource<String, FavoriteParticipant> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(FavoriteParticipantDataSource.class);
+
+ private ServiceFavorite service;
+
+ private Filter filter;
+
+ public FavoriteParticipantDataSource(ServiceFavorite service,
+ Filter filter) {
+ this.service = service;
+ this.filter = filter;
+ }
+
+ @Override
+ protected Map<String, FavoriteParticipant> execute(
+ int startIndex, int endIndex, SortConstraint orderBy)
+ throws PollenException {
+ filter.setStartIndex(startIndex);
+ filter.setEndIndex(endIndex);
+ filter.setOrderBy(resolveOrderBy(orderBy));
+ if (logger.isDebugEnabled()) {
+ logger.debug("LOAD DATA");
+ }
+ return service.getFavoriteParticipants(filter);
+ }
+
+ @Override
+ protected int count() throws PollenException {
+ int count = service.getNbFavoriteParticipants(filter);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Nb elements : " + count);
+ }
+ return count;
+ }
+
+ @Override
+ public Class<?> getRowType() {
+ return FavoriteParticipant.class;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/FavoriteParticipantDataSource.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/GenericSelectModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/GenericSelectModel.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/GenericSelectModel.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -0,0 +1,131 @@
+/* *##% Pollen
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
+
+package org.chorem.pollen.ui.models;
+
+import org.apache.tapestry5.OptionGroupModel;
+import org.apache.tapestry5.OptionModel;
+import org.apache.tapestry5.ValueEncoder;
+import org.apache.tapestry5.corelib.components.Select;
+import org.apache.tapestry5.internal.OptionModelImpl;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.apache.tapestry5.ioc.services.PropertyAdapter;
+import org.apache.tapestry5.util.AbstractSelectModel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Generic selection model for a list of Objects. Adadpted from
+ * http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects
+ * <p/>
+ * use:
+ * <p/>
+ * <pre>
+ * @Inject
+ * private PropertyAccess _access;
+ * </pre>
+ * <p/>
+ * in your page to ge the {@link PropertyAccess} service.<br> !Notice: you must
+ * set the created instance both as model and encoder parameter for the {@link
+ * Select} component.
+ *
+ * @param <T>
+ */
+public class GenericSelectModel<T> extends AbstractSelectModel implements
+ ValueEncoder<T> {
+
+ private PropertyAdapter labelFieldAdapter;
+
+ private PropertyAdapter idFieldAdapter;
+
+ private List<T> list;
+
+ public GenericSelectModel(List<T> list, Class<T> clazz, String labelField,
+ String idField, PropertyAccess access) {
+ this.list = list;
+ if (idField != null) {
+ this.idFieldAdapter =
+ access.getAdapter(clazz).getPropertyAdapter(idField);
+ }
+ if (labelField != null) {
+ this.labelFieldAdapter =
+ access.getAdapter(clazz).getPropertyAdapter(labelField);
+ }
+ }
+
+ @Override
+ public List<OptionGroupModel> getOptionGroups() {
+ return null;
+ }
+
+ @Override
+ public List<OptionModel> getOptions() {
+ List<OptionModel> optionModelList = new ArrayList<OptionModel>();
+ if (labelFieldAdapter == null) {
+ for (T obj : list) {
+ optionModelList.add(new OptionModelImpl(nvl(obj), obj));
+ }
+ } else {
+ for (T obj : list) {
+ optionModelList.add(new OptionModelImpl(nvl(labelFieldAdapter
+ .get(obj)), obj));
+ }
+ }
+ return optionModelList;
+ }
+
+ public List<T> getList() {
+ return list;
+ }
+
+ // ValueEncoder methods
+
+ @Override
+ public String toClient(T obj) {
+ if (idFieldAdapter == null) {
+ return obj + "";
+ } else {
+ return idFieldAdapter.get(obj) + "";
+ }
+ }
+
+ @Override
+ public T toValue(String string) {
+ if (idFieldAdapter == null) {
+ for (T obj : list) {
+ if (nvl(obj).equals(string)) {
+ return obj;
+ }
+ }
+ } else {
+ for (T obj : list) {
+ if (nvl(idFieldAdapter.get(obj)).equals(string)) {
+ return obj;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String nvl(Object o) {
+ if (o == null) {
+ return "";
+ } else {
+ return o.toString();
+ }
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/GenericSelectModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -0,0 +1,160 @@
+package org.chorem.pollen.ui.models;
+
+import org.apache.tapestry5.ValueEncoder;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.entity.Participant;
+import org.chorem.pollen.entity.ParticipantList;
+import org.chorem.pollen.service.ServicePoll;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Created: 18 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ParticipantListModel implements ValueEncoder<Participant> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ParticipantListModel.class);
+
+ protected ServicePoll service;
+
+ protected PollenManager manager;
+
+ protected ParticipantList list;
+
+ protected ParticipantMap participants;
+
+ public ParticipantListModel(ServicePoll service, PollenManager manager) {
+ this.service = service;
+ this.manager = manager;
+ participants = new ParticipantMap();
+ }
+
+ public Participant addNewParticipant() {
+ Participant newParticipant = service.getNewPollParticipant();
+ String id = manager.createPollenId();
+ participants.put(id, newParticipant);
+ return newParticipant;
+ }
+
+ public void removeParticipant(Participant participant) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Remove participant : " + participant);
+ }
+ participants.remove(participant);
+ }
+
+ public Collection<Participant> getParticipants() {
+ return participants.values();
+ }
+
+ public void setList(ParticipantList participantList) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Set current list : " + participantList.getName());
+ }
+ list = participantList;
+ participants.clear();
+ for (Participant participant : participantList.getParticipants()) {
+ String id = participant.getId() != null ? participant.getId() :
+ manager.createPollenId();
+ if (logger.isTraceEnabled()) {
+ logger.trace("Push participant : " +
+ participant.getName() +
+ " (" + participant.getEmail() + ")" +
+ " ID = " + id);
+ }
+ participants.put(id, participant);
+ }
+ }
+
+ public ParticipantList getList() {
+ return list;
+ }
+
+ public void reset() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Reset current list");
+ }
+ list = null;
+ participants.clear();
+ }
+
+ public void persistParticipants() throws PollenBusinessException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Save current list : " + list.getName());
+ }
+ list.setParticipants(getParticipants());
+ }
+
+ @Override
+ public String toClient(Participant value) {
+ String key = participants.getKey(value);
+ if (logger.isTraceEnabled()) {
+ logger.trace("toClient key = " + key);
+ }
+ return key;
+ }
+
+ @Override
+ public Participant toValue(String key) {
+ Participant value = participants.getValue(key);
+ if (logger.isTraceEnabled()) {
+ logger.trace("toValue from : " + key + " = " + value.getName() +
+ " (" + value.getEmail() + ")");
+ }
+ return value;
+ }
+
+ /**
+ * Participant map is a BidiMap ordered on values inserted using a {@link
+ * LinkedHashMap}.
+ */
+ protected class ParticipantMap {
+
+ protected Map<String, Participant> participants;
+
+ protected Map<Participant, String> keys;
+
+ public ParticipantMap() {
+ participants = new LinkedHashMap<String, Participant>();
+ keys = new HashMap<Participant, String>();
+ }
+
+ public void put(String id, Participant participant) {
+ participants.put(id, participant);
+ keys.put(participant, id);
+ }
+
+ public String getKey(Participant participant) {
+ return keys.get(participant);
+ }
+
+ public Participant getValue(String id) {
+ return participants.get(id);
+ }
+
+ public void clear() {
+ keys.clear();
+ participants.clear();
+ }
+
+ public void remove(Participant participant) {
+ String id = keys.remove(participant);
+ participants.remove(id);
+ }
+
+ public Collection<Participant> values() {
+ return participants.values();
+ }
+
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/ParticipantListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -0,0 +1,286 @@
+package org.chorem.pollen.ui.models;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.ValueEncoder;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entity.ParticipantList;
+import org.chorem.pollen.entity.Poll;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.service.ServicePoll;
+import org.chorem.pollen.ui.pages.poll.PollForm;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Model for PollForm page. Contains the current {@code poll} and its
+ * participant {@code lists}. Use {@link ParticipantListModel} to manage current
+ * edited list for restricted or group Poll. Implement a {@link ValueEncoder} to
+ * manage ParticipantList client conversion in PollForm page.
+ * <p/>
+ * Created: 18 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ * @see PollForm
+ * @see ValueEncoder
+ */
+public class PollFormModel implements ValueEncoder<ParticipantList> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(PollFormModel.class);
+
+ /** Default listName for Restricted Poll */
+ private static final String DEFAULT_LIST_NAME = "LIST";
+
+ /** Service to manage poll */
+ protected ServicePoll service;
+
+ /** Current poll in edition */
+ protected Poll poll;
+
+ /** Current lists in edition */
+ protected Map<String, ParticipantList> lists;
+
+ /** Current listModel that contains current edited list and its participants */
+ protected ParticipantListModel listModel;
+
+ protected boolean createMode;
+
+ /**
+ * Constructor of PollFormModel. Need services {@code servicePoll} and
+ * {@code manager} to manage the current edited poll. Use {@link
+ * #initPoll(String, UserAccount)} to initialize the poll.
+ *
+ * @param servicePoll ServicePoll to manage poll
+ * @param manager PollenManager to manage ids
+ */
+ public PollFormModel(ServicePoll servicePoll,
+ PollenManager manager) {
+ this.service = servicePoll;
+ lists = new LinkedHashMap<String, ParticipantList>();
+ this.listModel = new ParticipantListModel(service, manager);
+ }
+
+ /**
+ * 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.
+ *
+ * @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(String uid, UserAccount user) {
+ if (StringUtils.isNotEmpty(uid)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Get existing poll with pollUID = " + uid);
+ }
+ poll = service.getPollForUpdate(uid);
+ // TODO : init advancedOptions
+ // TODO-fdesbois-2010-05-19 : exception need to be throw if uid not correspond to an existing poll
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Init new poll");
+ }
+ poll = service.getNewPoll(user);
+ createMode = true;
+ }
+ }
+
+ /**
+ * Get the current poll. Will be null if initializion with {@link
+ * #initPoll(String, UserAccount)} has not been called.
+ *
+ * @return the current poll.
+ */
+ public Poll getPoll() {
+ return poll;
+ }
+
+ /**
+ * Check if the current poll is in creation mode.
+ *
+ * @return true for create mode or false.
+ */
+ public boolean isCreateMode() {
+ return createMode;
+ }
+
+ /**
+ * 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
+ * automatically added and set for current usage. For a {@link
+ * PollType#GROUP} poll, the listModel is simply reset.
+ *
+ * @param type PollType to change
+ */
+ public void setPollType(PollType type) {
+ lists.clear();
+ if (type.isRestricted()) {
+ addNewList(DEFAULT_LIST_NAME);
+ // Set automatically the current list to the unique one
+ listModel.setList(lists.get(DEFAULT_LIST_NAME));
+ } else if (type.isGroup()) {
+ listModel.reset();
+ }
+ poll.setPollType(type);
+ }
+
+ /**
+ * Retrieve a collection of {@link ParticipantList} of current lists.
+ *
+ * @return a Collection<ParticipantList>
+ */
+ public Collection<ParticipantList> getLists() {
+ return lists.values();
+ }
+
+ /**
+ * Add a new list to the poll using the {@code listName}. The list will not
+ * be added if the {@code listName} is empty or if a list with this {@code
+ * listName} already exists.
+ *
+ * @param listName for the new list to add
+ * @return true if the list has been added, false otherwise
+ * @see #addList(ParticipantList)
+ */
+ public boolean addNewList(String listName) {
+ boolean result = false;
+ if (StringUtils.isNotEmpty(listName)) {
+ ParticipantList newList = service.getNewPollList();
+ newList.setName(listName);
+ return addList(newList);
+ }
+ return result;
+ }
+
+ /**
+ * Add a {@code list} to the poll. The {@code list} will not be added if its
+ * name already reference an exising list.
+ *
+ * @param list ParticipantList to add
+ * @return true if the list has been added, false otherwise
+ */
+ public boolean addList(ParticipantList list) {
+ boolean result = false;
+ if (list != null) {
+ String listName = list.getName();
+ if (!lists.containsKey(listName)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Add list : " + listName);
+ }
+ lists.put(listName, list);
+ result = true;
+ } else if (logger.isDebugEnabled()) {
+ logger.debug("Refuse adding list : " + listName);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Give the current {@link ParticipantListModel} that references the list
+ * currently edited.
+ *
+ * @return the current listModel
+ */
+ public ParticipantListModel getListModel() {
+ return listModel;
+ }
+
+ /**
+ * Set the current list using its {@code listName}. The previous current
+ * list will be automatically saved. If error occurs during save, the
+ * previous list will be refresh (no list change will be done).
+ *
+ * @param listName name of the list to set (empty name will be ignored)
+ * @throws PollenBusinessException for saving error (doubloons)
+ * @see #saveCurrentList()
+ */
+ public void setCurrentList(String listName) throws PollenBusinessException {
+ if (StringUtils.isNotEmpty(listName)) {
+ ParticipantList list = getCurrentList();
+ try {
+ // Save previous list if not null
+ if (list != null) {
+ saveCurrentList();
+ }
+ // Change list
+ list = lists.get(listName);
+ } finally {
+ // Previous list will be keeped if error occurs during save.
+ // Apply change in listModel
+ listModel.setList(list);
+ }
+ }
+ }
+
+ /**
+ * Get the current list.
+ *
+ * @return the current list in edition.
+ */
+ public ParticipantList getCurrentList() {
+ return listModel.getList();
+ }
+
+ /** Remove the current list. */
+ public void removeCurrentList() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Remove list : " + listModel.getList().getName());
+ }
+
+ getLists().remove(listModel.getList());
+ listModel.reset();
+ }
+
+ /**
+ * Save the current participants from current list.
+ *
+ * @throws PollenBusinessException for saving errors (doubloons)
+ * @see ParticipantListModel#persistParticipants()
+ */
+ public void saveCurrentList() throws PollenBusinessException {
+ listModel.persistParticipants();
+ }
+
+ public void create() throws PollenBusinessException {
+ service.createPoll(poll, getLists());
+ }
+
+ /**
+ * ValueEncoder toClient is used to convert {@code value} to the list name.
+ *
+ * @param value ParticipantList to convert toClient
+ * @return the list name as a unique key for the list
+ * @see ValueEncoder#toClient(Object)
+ */
+ @Override
+ public String toClient(ParticipantList value) {
+ return value.getName();
+ }
+
+ /**
+ * ValueEncoder toClient is used to convert {@code clientValue} key to the
+ * list object.
+ *
+ * @param clientValue List name of the ParticipantList to retrieve.
+ * @return the ParticipantList corresponding to its name in argument
+ * @see ValueEncoder#toValue(String)
+ */
+ @Override
+ public ParticipantList toValue(String clientValue) {
+ for (ParticipantList curr : lists.values()) {
+ if (clientValue.equals(curr.getName())) {
+ return curr;
+ }
+ }
+ return null;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/UserAccountDataSource.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -0,0 +1,53 @@
+package org.chorem.pollen.ui.models;
+
+import org.apache.tapestry5.grid.SortConstraint;
+import org.chorem.pollen.PollenException;
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.service.ServiceUser;
+import org.nuiton.web.tapestry5.data.AbstractMappedGridDataSource;
+
+import java.util.Map;
+
+/**
+ * UserAccountDataSource
+ * <p/>
+ * Created: 23 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class UserAccountDataSource extends AbstractMappedGridDataSource<String, UserAccount> {
+
+ private ServiceUser service;
+
+ private Filter filter;
+
+ public UserAccountDataSource(ServiceUser service, Filter filter) {
+ this.service = service;
+ this.filter = filter;
+ }
+
+ @Override
+ protected Map<String, UserAccount> execute(int startIndex, int endIndex,
+ SortConstraint orderBy) throws PollenException {
+ filter.setStartIndex(startIndex);
+ filter.setEndIndex(endIndex);
+ filter.setOrderBy(resolveOrderBy(orderBy));
+ return service.getUsers(filter);
+ }
+
+ @Override
+ protected int count() throws PollenException {
+ return service.getNbUsers(filter);
+ }
+
+ @Override
+ public Class<?> getRowType() {
+ return UserAccount.class;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/UserAccountDataSource.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -40,12 +40,12 @@
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
-import org.chorem.pollen.ui.data.UserAccountDataSource;
+import org.chorem.pollen.ui.models.UserAccountDataSource;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
/**
- * Management of users by an admin.
+ * Management of users by an admin.
*
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
@@ -57,9 +57,9 @@
@InjectComponent
private Border border;
- /** Page title from Messages **/
- @Parameter(defaultPrefix = BindingConstants.MESSAGE,
- value = "pollen.page.AdminUsers.title")
+ /** Page title from Messages * */
+ @Parameter(defaultPrefix = BindingConstants.MESSAGE,
+ value = "pollen.page.AdminUsers.title")
@Property
private String title;
@@ -72,13 +72,13 @@
return AddressBar.newBar().appendCurrent(title);
}
- /** Services used by the page **/
+ /** Services used by the page * */
@Inject
private Logger logger;
@Inject
private ComponentResources resources;
-
+
@Inject
private Messages messages;
@@ -93,25 +93,25 @@
/***************************** USERS GRID/FORM ****************************/
- /** Components of the page **/
+ /** Components of the page * */
@InjectComponent
private Form usersForm;
- /**
+ /**
* Users list : the {@link Persist} is used to keep current page and order
* from dataSource.
*/
@Persist
private UserAccountDataSource accounts;
- /** Current user from iteration on accounts **/
+ /** Current user from iteration on accounts * */
@Property
private UserAccount account;
- /** Edited user **/
+ /** Edited user * */
@Property
private UserAccount accountEdited;
-
+
/**
* Use the {@link UserAccountDataSource} to retrieve existing user accounts.
* This will manage pagination and order of the grid.
@@ -129,7 +129,7 @@
* Test if the edited account is the current one in the Grid.
*
* @return true if the accountEdited is defined and correspond to the
- * current account in the Grid
+ * current account in the Grid
*/
public boolean isEditionMode() {
// The current account in the loop is equals to the edited one
@@ -147,9 +147,9 @@
}
/**
- * ON_ACTION :: Handler method for action on editAccount actionLink.
- * The accountEdited will be set to the user selected in the Grid with
- * {@code login}.
+ * ON_ACTION :: Handler method for action on editAccount actionLink. The
+ * accountEdited will be set to the user selected in the Grid with {@code
+ * login}.
*
* @param login key of the user from the Grid
* @return the usersForm to display form with accountEdited
@@ -163,8 +163,8 @@
}
/**
- * ON_ACTION :: Handler method for action on deletedAccount actionLink.
- * The selected login from the Grid will be used to delete the user.
+ * ON_ACTION :: Handler 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
* @see ServiceUser#deleteUser(String)
@@ -188,7 +188,7 @@
* ON_VALIDATE_FORM :: Handler method for validateForm event of the
* usersForm. The accountEdited will be updated using serviceUser. Errors
* from service will be recorded into the usersForm.
- *
+ *
* @see ServiceUser#updateUser(UserAccount, boolean)
*/
public void onValidateFormFromUsersForm() {
@@ -201,20 +201,20 @@
}
/**
- * ON_SUCCESS :: Handler method for success event of the usersForm.
- * No error occurs from validation, a message will be displayed to client.
+ * ON_SUCCESS :: Handler 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
*/
- public Object onSuccessFromUsersForm() {
+ public Object onSuccessFromUsersForm() {
addInfo(messages.get("pollen.ui.user.update.success"));
return this;
}
/**
- * ON_FAILURE :: Handler method for failure event of the usersForm.
- * Errors were recorded into the usersForm. The usersForm will be refresh
- * to display error messages.
+ * ON_FAILURE :: Handler method for failure event of the usersForm. Errors
+ * were recorded into the usersForm. The usersForm will be refresh to
+ * display error messages.
*
* @return the usersForm to refresh (in the usersZone)
*/
@@ -224,11 +224,11 @@
/***************************** NEW USER FORM ******************************/
- /** newUser to create from newUserForm **/
+ /** newUser to create from newUserForm * */
@Property
private UserAccount newUser;
- /** Components used for refresh or validations **/
+ /** Components used for refresh or validations * */
@InjectComponent
private Form newUserForm;
@@ -238,13 +238,12 @@
@InjectComponent
private Field newEmail;
- /** newPassword created for the newUser **/
+ /** newPassword created for the newUser * */
private String newPassword;
/**
- * ON_PREPARE :: Handler method for prepare events of the newUserForm.
- * The newUser will be initialized if needed before render and before
- * submit.
+ * ON_PREPARE :: Handler method for prepare events of the newUserForm. The
+ * newUser will be initialized if needed before render and before submit.
*/
public void onPrepareFromNewUserForm() {
if (newUser == null) {
@@ -254,10 +253,10 @@
/**
* ON_VALIDATE_FORM :: Handler 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 be the same as the newUser login.
+ * 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
+ * be the same as the newUser login.
*
* @see ServiceUser#createUser(UserAccount)
*/
@@ -268,12 +267,12 @@
// Generate new password
newPassword = RandomStringUtils.randomAlphanumeric(8);
passwordInfo =
- messages.get("pollen.ui.user.create.passwordGenerated");
+ messages.get("pollen.ui.user.create.passwordGenerated");
} else {
// Password will be the same as the login
newPassword = newUser.getLogin();
passwordInfo =
- messages.get("pollen.ui.user.create.passwordSameAsLogin");
+ messages.get("pollen.ui.user.create.passwordSameAsLogin");
}
newUser.setNewPassword(newPassword);
@@ -283,7 +282,8 @@
String message = manager.getErrorMessage(eee, messages, logger);
switch (eee.getType()) {
case USER_EMAIL_EXIST:
- newUserForm.recordError(newEmail, message); break;
+ newUserForm.recordError(newEmail, message);
+ break;
case USER_LOGIN_EXIST:
newUserForm.recordError(newLogin, message);
}
@@ -291,11 +291,11 @@
}
/**
- * ON_SUCCESS :: Handler 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 page filter.
+ * ON_SUCCESS :: Handler 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
+ * page filter.
*
* @return the current page to refresh
* @see ServiceEmail#sendEmail(PollenEmail)
@@ -309,12 +309,12 @@
PollenEmail email = serviceEmail.getNewEmail(newUser);
email.setSubject(
messages.format("pollen.email.userRegister.subject",
- newUser.getLogin()));
+ newUser.getLogin()));
email.setContent(
messages.format("pollen.email.userRegister.content",
- newUser.getDisplayName(), newUser.getLogin(),
- newPassword, getUrl()));
-
+ newUser.getDisplayName(), newUser.getLogin(),
+ newPassword, getUrl()));
+
serviceEmail.sendEmail(email);
addInfo(messages.format("pollen.ui.user.create.sendEmail",
newUser.getLogin(), newUser.getEmail()));
@@ -334,9 +334,9 @@
}
/**
- * ON_FAILURE :: Handler method for failure event of the newUserForm.
- * Errors were recorded into the newUserForm. The newUserForm will be
- * refresh to display error messages.
+ * ON_FAILURE :: Handler method for failure event of the newUserForm. Errors
+ * were recorded into the newUserForm. The newUserForm will be refresh to
+ * display error messages.
*
* @return the newUserForm to refresh (in the newUserZone)
*/
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-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -27,8 +27,8 @@
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.ParticipantListModel;
-import org.chorem.pollen.ui.data.PollFormModel;
+import org.chorem.pollen.ui.models.ParticipantListModel;
+import org.chorem.pollen.ui.models.PollFormModel;
import org.chorem.pollen.ui.services.PollenManager;
import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
@@ -79,6 +79,7 @@
return border;
}
+ /** Services injected */
@Inject
private Logger log;
@@ -91,11 +92,17 @@
@Inject
private PollenManager manager;
+ /** Main page context */
private String pollUID;
+ /** Main page model */
@Persist
- private Poll poll;
+ private PollFormModel model;
+ /** Main page form component */
+ @InjectComponent
+ private Form mainForm;
+
void onActivate(String id) {
pollUID = id;
}
@@ -105,10 +112,8 @@
}
void setupRender() {
- poll = null;
- initMainInfos();
- initOptions();
model = null;
+ initOptions();
listsFeedback.clearErrors();
}
@@ -116,25 +121,30 @@
* Get the main poll used in the form. The existing poll is loaded if the
* pollUID exist.
*
- * @return poll existing or a new one
- * @throws PollenBusinessException
+ * @return the current poll in edition
+ * @see #getModel()
*/
public Poll getPoll() {
- if (poll == null) {
- if (StringUtils.isNotEmpty(pollUID)) {
- if (log.isDebugEnabled()) {
- log.debug("Get existing poll with pollUID = " + pollUID);
- }
- poll = servicePoll.getPollForUpdate(pollUID);
- // TODO : init advancedOptions
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Init new poll");
- }
- poll = servicePoll.getNewPoll(getUserConnected());
+ return getModel().getPoll();
+ }
+
+ /**
+ * Retrieve the current model for the PollForm or create a new one. The poll
+ * will be initialized depends on {@code pollUID} context : the existing
+ * poll corresponding will be retrieve or a new one will be instantiate with
+ * connected user as the creator.
+ *
+ * @return the model of this page
+ */
+ public PollFormModel getModel() {
+ if (model == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("-------- NEW POLL FORM MODEL --------");
}
+ model = new PollFormModel(servicePoll, manager);
+ model.initPoll(pollUID, getUserConnected());
}
- return poll;
+ return model;
}
/**
@@ -144,7 +154,7 @@
* @throws PollenBusinessException
*/
public boolean isCreateMode() {
- return StringUtils.isEmpty(getPoll().getId());
+ return getModel().isCreateMode();
}
/**
@@ -173,10 +183,6 @@
return AddressBar.newBar().appendCurrent(getPageTitle());
}
- public void setPollCopyFromPoll(Poll poll) {
- this.poll = servicePoll.getNewPoll(poll);
- }
-
public Date getCurrentDate() {
return new Date();
}
@@ -188,19 +194,15 @@
@Environmental
private RenderSupport renderSupport;
-// @InjectComponent
-// private FormFragment optionsFragment;
-
/**
* Action when rendering form. A script is added to manage form
- * interactions
+ * interactions.
*/
@Log
void onPrepareForRender() {
String formId = mainForm.getClientId();
if (log.isDebugEnabled()) {
log.debug("form id : " + formId);
-// log.debug("options fragment id : " + optionsFragment.getClientId());
}
if (formId != null) {
// Script for form interactions : see "webapp/js/pollForm.js"
@@ -214,17 +216,15 @@
/** *********************** MAIN INFOS ********************************* */
- @InjectComponent
- private Form mainForm;
- @Persist
- @Property
- private boolean advancedOptions;
+// @Persist
+// @Property
+// private boolean advancedOptions;
+//
+// protected void initMainInfos() {
+// advancedOptions = false;
+// }
- protected void initMainInfos() {
- advancedOptions = false;
- }
-
/************************** CHOIX *****************************************/
// @Property
@@ -397,57 +397,38 @@
return getPoll().getPollType().isFree();
}
- /** ********************* LISTS **************************************** */
+ /** ******************** LISTS **************************************** */
- @Persist
- private PollFormModel model;
+ @Inject
+ private ComponentResources resources;
-// @Persist
-// private Map<String, ParticipantList> lists;
+ @InjectComponent
+ private Zone listsZone;
+ @InjectComponent
+ private FeedBack listsFeedback;
+
+ /** Current list for loop (GROUP type) */
@Property
private ParticipantList list;
-// @Persist
-// private String listSelectedName;
-
-// @Persist
-// private ParticipantList listSelected;
-//
-// private Map<String, Participant> selectedParticipants;
-
+ /** Current participant for ajaxFormLoop (GROUP or RESTRICTED) types */
@Property
private Participant participant;
- @InjectComponent
- private Zone listsZone;
-
+ /** Field to add a new list */
@Property
private String listName;
- @Inject
- private ComponentResources resources;
-
+ /** Flag for subForm used for lists managment */
@Property
private boolean formActivate;
- @InjectComponent
- private FeedBack listsFeedback;
-
+ /** Flag if submit comes from lists edition */
private boolean editLists;
/** DATA ** */
- public PollFormModel getModel() {
- if (model == null) {
- if (log.isDebugEnabled()) {
- log.debug("-------- NEW MODEL --------");
- }
- model = new PollFormModel(getPoll(), servicePoll, manager);
- }
- return model;
- }
-
public ParticipantListModel getListModel() {
return getModel().getListModel();
}
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-19 12:59:57 UTC (rev 3001)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-19 13:25:45 UTC (rev 3002)
@@ -15,8 +15,6 @@
package org.chorem.pollen.ui.pages.user;
-import java.util.List;
-
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
@@ -33,18 +31,20 @@
import org.chorem.pollen.ui.components.UserListsCreate;
import org.chorem.pollen.ui.components.UserListsUpdate;
import org.chorem.pollen.ui.data.AddressBar;
-import org.chorem.pollen.ui.data.GenericSelectModel;
import org.chorem.pollen.ui.data.PollenRequiresAuthentication;
+import org.chorem.pollen.ui.models.GenericSelectModel;
+import java.util.List;
+
/**
* Page to manage favorite lists of the connected user only (managed thanks to
* {@link PollenRequiresAuthentication} annotation). This page use two main
* components, {@link UserListsCreate} to create a FavoriteList (from import
- * csv, ldap or an empty one) and {@link UserListsUpdate} to manage content
- * of the FavoriteList. This page will provide {@code favoriteListSelected}
- * from a form with only a SelectModel loaded by {@link #getFavoriteLists()}
- * with {@link #getFavoriteListModel()} as model. The delete action is also
- * manage by the page using {@code serviceFavorite}.
+ * csv, ldap or an empty one) and {@link UserListsUpdate} to manage content of
+ * the FavoriteList. This page will provide {@code favoriteListSelected} from a
+ * form with only a SelectModel loaded by {@link #getFavoriteLists()} with
+ * {@link #getFavoriteListModel()} as model. The delete action is also manage by
+ * the page using {@code serviceFavorite}.
*
* @author rannou
* @author fdesbois <fdesbois(a)codelutin.com>
@@ -56,7 +56,7 @@
/************************** PAGE CONFIGURATION ****************************/
- /** Border layout **/
+ /** Border layout * */
@InjectComponent
private Border border;
@@ -65,13 +65,13 @@
return border;
}
- /** Page title from Messages **/
+ /** Page title from Messages * */
@Parameter(defaultPrefix = BindingConstants.MESSAGE,
- value = "pollen.page.UserLists.title")
+ value = "pollen.page.UserLists.title")
@Property
private String title;
- /**
+ /**
* AddressBar for {@code border} component.
*
* @return a new AddressBar for the page.
@@ -80,7 +80,7 @@
return AddressBar.newBar().appendCurrent(title);
}
- /** Services injected **/
+ /** Services injected * */
@Inject
private ServiceFavorite serviceFavorite;
@@ -90,15 +90,16 @@
@Inject
private Messages messages;
- /************************** SELECT FAVORITE LIST **************************/
+ /** *********************** SELECT FAVORITE LIST ************************* */
private List<FavoriteList> favoriteLists;
+
private GenericSelectModel<FavoriteList> favoriteListModel;
/**
- * Main property favoriteListSelected is keeped in Session and was
- * used as parameter for UserListsUpdate component.
- **/
+ * Main property favoriteListSelected is keeped in Session and was used as
+ * parameter for UserListsUpdate component.
+ */
@Persist
@Property
private FavoriteList favoriteListSelected;
@@ -113,10 +114,10 @@
if (favoriteListModel == null) {
favoriteListModel =
new GenericSelectModel<FavoriteList>(getFavoriteLists(),
- FavoriteList.class,
- FavoriteList.NAME,
- FavoriteList.NAME,
- propertyAccess);
+ FavoriteList.class,
+ FavoriteList.NAME,
+ FavoriteList.NAME,
+ propertyAccess);
}
return favoriteListModel;
}
@@ -137,28 +138,28 @@
/************************** SELECT FAVORITE LIST **************************/
/**
- * Used to verify if the {@code favoriteListSelected} is set and ready
- * to be deleted using {@code deleteList} actionLink.
+ * Used to verify if the {@code favoriteListSelected} is set and ready to be
+ * deleted using {@code deleteList} actionLink.
*
* @return true if the {@code favoriteListSelected} is not null.
*/
public boolean canDeleteList() {
- return favoriteListSelected != null;
+ return favoriteListSelected != null;
}
/**
* ON_ACTION :: Handler 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}.
- *
+ * Check is done using {@link #canDeleteList()}, then the {@code
+ * serviceFavorite} is called to execute the delete on {@code
+ * favoriteListSelected}.
+ *
* @see ServiceFavorite#deleteFavoriteList(FavoriteList)
*/
void onActionFromDeleteList() {
if (canDeleteList()) {
serviceFavorite.deleteFavoriteList(favoriteListSelected);
addInfo(
- messages.get("pollen.ui.list.delete.success"));
+ messages.get("pollen.ui.list.delete.success"));
}
}
}
\ No newline at end of file
1
0
Author: fdesbois
Date: 2010-05-19 14:59:57 +0200 (Wed, 19 May 2010)
New Revision: 3001
Url: http://chorem.org/repositories/revision/pollen/3001
Log:
Create models to simplify lists managment in PollForm
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantsListener.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.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/pom.xml
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.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/services/PollenManager.java
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
trunk/pom.xml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,24 +1,24 @@
+package org.chorem.pollen;
-package org.chorem.pollen;
import static org.nuiton.i18n.I18n.n_;
/**
* PollenBusinessException
- *
+ * <p/>
* Created: 24 févr. 2010
*
* @author fdesbois
* @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
*/
public class PollenBusinessException extends Exception {
private static final long serialVersionUID = 1L;
protected PollenExceptionType type;
-
+
protected Object[] args;
public PollenBusinessException(PollenExceptionType type, Object... args) {
@@ -28,42 +28,48 @@
}
public PollenBusinessException(Throwable exception,
- PollenExceptionType type, Object... args) {
+ PollenExceptionType type, Object... args) {
super(type.getMessage(), exception);
this.args = args;
this.type = type;
}
public enum PollenExceptionType {
- /** Exception when poll is not found in data **/
+
+ /** Exception when poll is not found in data * */
POLL_NOT_EXIST(n_("pollen.exception.poll_not_exist")),
- /** Exception when user login exists in data **/
+ /** Exception when user login exists in data * */
USER_LOGIN_EXIST(n_("pollen.exception.user_login_exist")),
- /** Exception when user email exists in data **/
+ /** Exception when user email exists in data * */
USER_EMAIL_EXIST(n_("pollen.exception.user_email_exist")),
- /** Exception when user is not found in data **/
+ /** Exception when user is not found in data * */
USER_NOT_EXIST(n_("pollen.exception.user_not_exist")),
- /** Exception when password is not valid for some user **/
+ /** Exception when password is not valid for some user * */
USER_WRONG_PASSWORD(n_("pollen.exception.user_wrong_password")),
- /** Exception when stmp server is not available **/
+ /** Exception when stmp server is not available * */
SMTP_NOT_AVAILABLE(n_("pollen.exception.smtp_not_available")),
- /** Exception when favorite list name is already defined for user **/
+ /** Exception when favorite list name is already defined for user * */
FAVORITE_LIST_NAME_EXIST(
n_("pollen.exception.favorite_list_name_exist")),
/**
- * Exception when participant name ($2) and email ($3) are
- * already defined for the current list ($1).
- **/
+ * Exception when participant name ($2) and email ($3) are already
+ * defined for the current list ($1).
+ */
PARTICIPANT_EXIST(n_("pollen.exception.participant_exist")),
-
+
/**
* Exception when favorite participant name ($2) with no email is
* already defined for the current list ($1).
- **/
+ */
PARTICIPANT_EXIST_WITHOUT_EMAIL(
n_("pollen.exception.participant_exist_without_email")),
- /** Exception when poll already exist at creation **/
- POLL_EXIST(n_("pollen.exception.poll_exist"));
+ /** Exception when poll already exist at creation * */
+ POLL_EXIST(n_("pollen.exception.poll_exist")),
+ /**
+ * Exception when doubloons ($2) are found when adding participants in a
+ * list ($1).
+ */
+ PARTICIPANT_DOUBLOONS(n_("pollen.exception.participant_doubloons"));
private String message;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -13,7 +13,7 @@
*/
public class FavoriteListImpl extends FavoriteListAbstract {
- @Override
+ @Override
public Collection<Participant> getParticipants() {
Collection<Participant> results = new ArrayList<Participant>();
for (FavoriteParticipant account : getFavoriteParticipant()) {
@@ -26,23 +26,26 @@
public void setParticipants(Collection<Participant> participants)
throws PollenBusinessException {
setFavoriteParticipant(new ArrayList<FavoriteParticipant>());
- for (Participant participant : participants) {
- addParticipant(participant);
- }
+ ParticipantHelper.setParticipants(this, participants);
}
- protected void addParticipant(Participant participant)
- throws PollenBusinessException {
+ @Override
+ public String addParticipant(Participant participant) {
String name = participant.getName();
String email = participant.getEmail();
-
- ParticipantHelper.checkParticipantExist(this, name, email);
+ String error =
+ ParticipantHelper.checkParticipantExist(this, name, email);
+ if (error != null) {
+ return error;
+ }
+
FavoriteParticipant favorite = new FavoriteParticipantImpl();
favorite.setName(participant.getName());
favorite.setEmail(participant.getEmail());
favorite.setWeight(participant.getWeight());
favorite.setFavoriteList(this);
addFavoriteParticipant(favorite);
+ return null;
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,7 +1,11 @@
package org.chorem.pollen.entity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenBusinessException;
+import java.util.Collection;
+
/**
* Helper classes for common Participant manipulations.
*
@@ -12,6 +16,8 @@
*/
public class ParticipantHelper {
+ private static final Log log = LogFactory.getLog(ParticipantHelper.class);
+
/**
* Check the existence of participant from a {@code list}. The existence is
* tested on {@code name} and {@code email}. The {@code email} can be null.
@@ -19,12 +25,11 @@
* @param list ParticipantList which contains a list of Participant
* @param name Name of the participant to check
* @param email Email of the participant to check
- * @throws PollenBusinessException if name and email correspond to an
- * existing participant in the list.
+ * @return an error code if participant already exist : simply the
+ * concatenation of name and email.
*/
- public static void checkParticipantExist(
- ParticipantList list, String name, String email)
- throws PollenBusinessException {
+ public static String checkParticipantExist(
+ ParticipantList list, String name, String email) {
for (Participant participant : list.getParticipants()) {
boolean emailNull = (email == null && participant.getEmail() == null);
boolean emailCheck = emailNull ||
@@ -32,16 +37,48 @@
if (name != null && name.equals(participant.getName()) && emailCheck) {
if (emailNull) {
- throw new PollenBusinessException(
- PollenBusinessException.PollenExceptionType.PARTICIPANT_EXIST_WITHOUT_EMAIL,
- list.getName(), name);
+ return name;
} else {
- throw new PollenBusinessException(
- PollenBusinessException.PollenExceptionType.PARTICIPANT_EXIST,
- list.getName(), name, email);
+ return name + " (" + email + ")";
}
}
}
+ return null;
}
+ /**
+ * Set the {@code participants} in the {@code list}. Doubloons can be found
+ * during adding process. An exception will be thrown in case of doubloons.
+ *
+ * @param list where participants will be added
+ * @param participants to add to the list
+ * @throws PollenBusinessException for doubloons case
+ */
+ public static void setParticipants(ParticipantList list,
+ Collection<Participant> participants)
+ throws PollenBusinessException {
+ if (log.isDebugEnabled()) {
+ log.debug("Set participants for list : " + list.getName());
+ }
+ StringBuilder doubloons = new StringBuilder();
+ String separator = ", ";
+ for (Participant participant : participants) {
+ // Add the participant to the list
+ String doubloon = list.addParticipant(participant);
+ // Check error doubloon
+ if (doubloon != null) {
+ doubloons.append(separator).append(doubloon);
+ } else if (log.isDebugEnabled()) {
+ log.debug("Participant added : " + participant.getName() +
+ " _ " + participant.getEmail());
+ }
+ }
+ // If doubloons are found, throw an exception
+ if (!doubloons.toString().isEmpty()) {
+ throw new PollenBusinessException(
+ PollenBusinessException.PollenExceptionType.PARTICIPANT_DOUBLOONS,
+ list.getName(), doubloons.substring(separator.length()));
+ }
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,6 +1,7 @@
package org.chorem.pollen.entity;
-import org.chorem.pollen.PollenBinderHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenBusinessException;
import java.util.ArrayList;
@@ -14,6 +15,8 @@
*/
public class PollAccountImpl extends PollAccountAbstract {
+ private static final Log log = LogFactory.getLog(PollAccountImpl.class);
+
@Override
public Collection<Participant> getParticipants() {
// for a simple account, will return null
@@ -25,34 +28,37 @@
for (PollAccount account : getChild()) {
results.add(account);
}
- }
+ }
return results;
}
@Override
public void setParticipants(Collection<Participant> participants)
throws PollenBusinessException {
- if (!list) {
+ if (!list) {
throw new UnsupportedOperationException(
"Unable to set participants from a child account");
}
setChild(new ArrayList<PollAccount>());
- for (Participant participant : participants) {
- addParticipant(participant);
- }
+ ParticipantHelper.setParticipants(this, participants);
}
- protected void addParticipant(Participant participant)
- throws PollenBusinessException {
+ @Override
+ public String addParticipant(Participant participant) {
String name = participant.getName();
String email = participant.getEmail();
- ParticipantHelper.checkParticipantExist(this, name, email);
+ String error =
+ ParticipantHelper.checkParticipantExist(this, name, email);
+ if (error != null) {
+ return error;
+ }
PollAccount account = new PollAccountImpl();
account.setName(name);
account.setEmail(email);
account.setWeight(participant.getWeight());
addChild(account);
+ return null;
}
}
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-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,10 +1,5 @@
-
package org.chorem.pollen.service;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
import org.apache.commons.collections.CollectionUtils;
import org.chorem.pollen.PollenBinderHelper;
import org.chorem.pollen.PollenBusinessException;
@@ -26,18 +21,21 @@
import org.chorem.pollen.entity.UserAccount;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.util.TopiaEntityBinder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
/**
* ServicePoll
- *
+ * <p/>
* Created: 23 mars 2010
*
* @author fdesbois
* @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
*/
public class ServicePollImpl extends ServicePollAbstract {
@@ -54,7 +52,7 @@
@Override
protected void treateError(TopiaContext transaction, Exception eee,
- String message, Object... args) throws PollenException {
+ String message, Object... args) throws PollenException {
context.treateError(transaction, eee, message, args);
}
@@ -88,11 +86,11 @@
}
@Override
- protected void executeCreatePoll(TopiaContext transaction,
- List<Object> errorArgs, Poll poll, Collection<ParticipantList> lists)
+ protected void executeCreatePoll(TopiaContext transaction,
+ List<Object> errorArgs, Poll poll, Collection<ParticipantList> lists)
throws TopiaException,
- IllegalArgumentException,
- PollenBusinessException {
+ IllegalArgumentException,
+ PollenBusinessException {
errorArgs.add(poll.getTitle());
errorArgs.add(poll.getUid());
@@ -178,7 +176,7 @@
}
// Create accounts only on first participant list
results = createPersonAccounts(accountDAO,
- lists.iterator().next());
+ lists.iterator().next());
break;
case GROUP:
if (CollectionUtils.isEmpty(lists)) {
@@ -189,7 +187,7 @@
for (ParticipantList list : lists) {
// Create the accountList
PollAccount accountList = accountDAO.create(
- context.createPollenUrlId());
+ context.createPollenUrlId());
accountList.setList(true);
accountList.setName(list.getName());
@@ -206,7 +204,7 @@
}
protected List<PollAccount> createPersonAccounts(PollAccountDAO dao,
- ParticipantList list)
+ ParticipantList list)
throws TopiaException {
List<PollAccount> results = new ArrayList<PollAccount>();
@@ -234,7 +232,7 @@
for (Choice choice : source) {
Choice newChoice = dao.create();
PollenBinderHelper.getSimpleTopiaBinder(Choice.class).
- copy(choice, newChoice);
+ copy(choice, newChoice);
results.add(newChoice);
}
return results;
@@ -242,7 +240,7 @@
@Override
protected void executeUpdatePoll(TopiaContext transaction,
- Poll poll) throws TopiaException {
+ Poll poll) throws TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -266,19 +264,19 @@
@Override
protected void executeCreateUpdateVote(TopiaContext transaction,
- PollAccount person) throws TopiaException {
+ PollAccount person) throws TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- protected void executeDeleteVote(TopiaContext transaction, Poll poll,
- PollAccount person) throws TopiaException {
+ 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 {
+ protected Poll executeGetPollForUpdate(TopiaContext transaction,
+ String pollUId) throws PollenBusinessException, TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -296,33 +294,33 @@
@Override
protected List<Poll> executeGetPollsByUser(TopiaContext transaction,
- UserAccount user) throws TopiaException {
+ UserAccount user) throws TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
protected List<Comment> executeGetComments(TopiaContext transaction,
- Poll poll, int startIndex, int endIndex)
+ Poll poll, int startIndex, int endIndex)
throws TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
protected List<PollAccount> executeGetVotes(TopiaContext transaction,
- Poll poll, int startIndex, int endIndex)
+ 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 {
+ 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 {
+ protected Poll executeGetPollForVote(TopiaContext transaction,
+ String pollUId) throws PollenBusinessException, TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -337,6 +335,7 @@
@Override
protected Participant executeGetNewPollParticipant() {
PollAccount participant = new PollAccountImpl();
+ participant.setWeight(1.);
return participant;
}
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-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-19 12:59:57 UTC (rev 3001)
@@ -81,6 +81,7 @@
pollen.exception.favorite_participant_exist=
pollen.exception.favorite_participant_exist_without_email=
pollen.exception.load_configuration=
+pollen.exception.participant_doubloons=
pollen.exception.participant_exist=
pollen.exception.participant_exist_without_email=
pollen.exception.poll_exist=
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-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-19 12:59:57 UTC (rev 3001)
@@ -78,6 +78,7 @@
pollen.error.serviceVote.hasAlreadyVoted=
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
pollen.exception.participant_exist=La liste %1$s contient d\u00E9j\u00E0 un votant nomm\u00E9 %2$s avec un email %3$s
pollen.exception.participant_exist_without_email=La liste %1$s contient d\u00E9j\u00E0 un votant nomm\u00E9 %2$s avec aucun email
pollen.exception.poll_exist=
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/pom.xml
===================================================================
--- trunk/pollen-ui/pom.xml 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-ui/pom.xml 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,201 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
- <parent>
- <groupId>org.chorem</groupId>
- <artifactId>pollen</artifactId>
- <version>2.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.chorem</groupId>
+ <artifactId>pollen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
- <groupId>org.chorem.pollen</groupId>
- <artifactId>pollen-ui</artifactId>
+ <groupId>org.chorem.pollen</groupId>
+ <artifactId>pollen-ui</artifactId>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>pollen-business</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.nuiton.web</groupId>
- <artifactId>nuiton-tapestry-extra</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-upload</artifactId>
- </dependency>
- <dependency>
- <groupId>org.chenillekit</groupId>
- <artifactId>chenillekit-tapestry</artifactId>
- </dependency>
- <dependency>
- <groupId>jfree</groupId>
- <artifactId>jfreechart</artifactId>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- </dependency>
- <dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jvnet.hudson.winstone</groupId>
- <artifactId>winstone</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>pollen-business</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-tapestry-extra</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-upload</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.chenillekit</groupId>
+ <artifactId>chenillekit-tapestry</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jfree</groupId>
+ <artifactId>jfreechart</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
- <name>Pollen :: Web Interface</name>
- <description>Interface Web Tapestry pour Pollen</description>
+ <name>Pollen :: Web Interface</name>
+ <description>Interface Web Tapestry pour Pollen</description>
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
- <packaging>war</packaging>
+ <packaging>war</packaging>
- <properties>
- <redmine.releaseFiles>target/${project.build.finalName}.war</redmine.releaseFiles>
+ <properties>
+ <redmine.releaseFiles>target/${project.build.finalName}.war
+ </redmine.releaseFiles>
- <i18n.collectOutputName>app</i18n.collectOutputName>
- <i18n.bundleOutputName>app</i18n.bundleOutputName>
- </properties>
+ <i18n.collectOutputName>app</i18n.collectOutputName>
+ <i18n.bundleOutputName>app</i18n.bundleOutputName>
+ </properties>
- <reporting>
- <!-- Adds a report detailing the components, mixins and base classes defined by this module. -->
- <!-- <plugins>
- <plugin>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-component-report</artifactId>
- <version>${tapestry.version}</version>
- <configuration>
- <rootPackage>org.chorem.pollen.ui</rootPackage>
- </configuration>
- </plugin>
- </plugins> -->
- </reporting>
+ <reporting>
+ <!-- Adds a report detailing the components, mixins and base classes defined by this module. -->
+ <!-- <plugins>
+ <plugin>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-component-report</artifactId>
+ <version>${tapestry.version}</version>
+ <configuration>
+ <rootPackage>org.chorem.pollen.ui</rootPackage>
+ </configuration>
+ </plugin>
+ </plugins> -->
+ </reporting>
- <build>
- <!-- call result war : pollen-xxx.war -->
- <finalName>pollen-${project.version}</finalName>
+ <build>
+ <!-- call result war : pollen-xxx.war -->
+ <finalName>pollen-${project.version}</finalName>
- <!-- Add main class into war to make it executable -->
- <plugins>
+ <!-- Add main class into war to make it executable -->
+ <plugins>
- <plugin>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>tapestry-bundle</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.nuiton.util.war.WinstoneLauncher</mainClass>
- </manifest>
- </archive>
- <overlays>
- <overlay>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- <type>jar</type>
- <includes>
- <include>**/war/Winstone*</include>
- </includes>
- </overlay>
- <overlay>
- <groupId>org.jvnet.hudson.winstone</groupId>
- <artifactId>winstone</artifactId>
- <type>jar</type>
- </overlay>
- </overlays>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <configuration>
- <connectors>
- <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
- <port>8888</port>
- </connector>
- </connectors>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>tapestry-bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
- <!--<repositories>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.nuiton.util.war.WinstoneLauncher</mainClass>
+ </manifest>
+ </archive>
+ <overlays>
+ <overlay>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ <type>jar</type>
+ <includes>
+ <include>**/war/Winstone*</include>
+ </includes>
+ </overlay>
+ <overlay>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <type>jar</type>
+ </overlay>
+ </overlays>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <configuration>
+ <connectors>
+ <connector
+ implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
+ <port>8888</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
- chenillekit Repository
- <repository>
- <id>chenillekit</id>
- <url>http://www.chenillekit.org/mvnrepo/release</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
+ <!--<repositories>
- Maven Java.net Repository
- <repository>
- <id>maven2-repository.dev.java.net</id>
- <name>Java.net Repository for Maven</name>
- <url>http://download.java.net/maven/2/</url>
- <layout>default</layout>
- </repository>
- </repositories>-->
+ chenillekit Repository
+ <repository>
+ <id>chenillekit</id>
+ <url>http://www.chenillekit.org/mvnrepo/release</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ Maven Java.net Repository
+ <repository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Repository for Maven</name>
+ <url>http://download.java.net/maven/2/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>-->
</project>
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -3,6 +3,7 @@
import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.slf4j.Logger;
/**
* Created: 14 mai 2010
@@ -16,12 +17,18 @@
private boolean visible;
@Inject
+ private Logger logger;
+
+ @Inject
private Block formBlock;
@Inject
private Block noFormBlock;
public Block getActiveBlock() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("form already visible : " + visible);
+ }
if (visible) {
return noFormBlock;
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -0,0 +1,160 @@
+package org.chorem.pollen.ui.data;
+
+import org.apache.tapestry5.ValueEncoder;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.entity.Participant;
+import org.chorem.pollen.entity.ParticipantList;
+import org.chorem.pollen.service.ServicePoll;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Created: 18 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ParticipantListModel implements ValueEncoder<Participant> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ParticipantListModel.class);
+
+ protected ServicePoll service;
+
+ protected PollenManager manager;
+
+ protected ParticipantList list;
+
+ protected ParticipantMap participants;
+
+ public ParticipantListModel(ServicePoll service, PollenManager manager) {
+ this.service = service;
+ this.manager = manager;
+ participants = new ParticipantMap();
+ }
+
+ public Participant addNewParticipant() {
+ Participant newParticipant = service.getNewPollParticipant();
+ String id = manager.createPollenId();
+ participants.put(id, newParticipant);
+ return newParticipant;
+ }
+
+ public void removeParticipant(Participant participant) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Remove participant : " + participant);
+ }
+ participants.remove(participant);
+ }
+
+ public Collection<Participant> getParticipants() {
+ return participants.values();
+ }
+
+ public void setList(ParticipantList participantList) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Set current list : " + participantList.getName());
+ }
+ list = participantList;
+ participants.clear();
+ for (Participant participant : participantList.getParticipants()) {
+ String id = participant.getId() != null ? participant.getId() :
+ manager.createPollenId();
+ if (logger.isTraceEnabled()) {
+ logger.trace("Push participant : " +
+ participant.getName() +
+ " (" + participant.getEmail() + ")" +
+ " ID = " + id);
+ }
+ participants.put(id, participant);
+ }
+ }
+
+ public ParticipantList getList() {
+ return list;
+ }
+
+ public void reset() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Reset current list");
+ }
+ list = null;
+ participants.clear();
+ }
+
+ public void persistParticipants() throws PollenBusinessException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Save current list : " + list.getName());
+ }
+ list.setParticipants(getParticipants());
+ }
+
+ @Override
+ public String toClient(Participant value) {
+ String key = participants.getKey(value);
+ if (logger.isTraceEnabled()) {
+ logger.trace("toClient key = " + key);
+ }
+ return key;
+ }
+
+ @Override
+ public Participant toValue(String key) {
+ Participant value = participants.getValue(key);
+ if (logger.isTraceEnabled()) {
+ logger.trace("toValue from : " + key + " = " + value.getName() +
+ " (" + value.getEmail() + ")");
+ }
+ return value;
+ }
+
+ /**
+ * Participant map is a BidiMap ordered on values inserted using a {@link
+ * LinkedHashMap}.
+ */
+ protected class ParticipantMap {
+
+ protected Map<String, Participant> participants;
+
+ protected Map<Participant, String> keys;
+
+ public ParticipantMap() {
+ participants = new LinkedHashMap<String, Participant>();
+ keys = new HashMap<Participant, String>();
+ }
+
+ public void put(String id, Participant participant) {
+ participants.put(id, participant);
+ keys.put(participant, id);
+ }
+
+ public String getKey(Participant participant) {
+ return keys.get(participant);
+ }
+
+ public Participant getValue(String id) {
+ return participants.get(id);
+ }
+
+ public void clear() {
+ keys.clear();
+ participants.clear();
+ }
+
+ public void remove(Participant participant) {
+ String id = keys.remove(participant);
+ participants.remove(id);
+ }
+
+ public Collection<Participant> values() {
+ return participants.values();
+ }
+
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantsListener.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantsListener.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantsListener.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -0,0 +1,24 @@
+package org.chorem.pollen.ui.data;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ * Created: 18 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ParticipantsListener implements PropertyChangeListener {
+
+ protected boolean changed;
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ changed = true;
+ }
+
+ public boolean hasChanged() {
+ return changed;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ParticipantsListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -0,0 +1,241 @@
+package org.chorem.pollen.ui.data;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.ValueEncoder;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entity.ParticipantList;
+import org.chorem.pollen.entity.Poll;
+import org.chorem.pollen.service.ServicePoll;
+import org.chorem.pollen.ui.pages.poll.PollForm;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Model for PollForm page. Contains the current {@code poll} and its
+ * participant {@code lists}. Use {@link ParticipantListModel} to manage current
+ * edited list for restricted or group Poll. Implement a {@link ValueEncoder} to
+ * manage ParticipantList client conversion in PollForm page.
+ * <p/>
+ * Created: 18 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ * @see PollForm
+ * @see ValueEncoder
+ */
+public class PollFormModel implements ValueEncoder<ParticipantList> {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(PollFormModel.class);
+
+ /** Default listName for Restricted Poll */
+ private static final String DEFAULT_LIST_NAME = "LIST";
+
+ /** Service to manage poll */
+ protected ServicePoll service;
+
+ /** Current poll in edition */
+ protected Poll poll;
+
+ /** Current lists in edition */
+ protected Map<String, ParticipantList> lists;
+
+ /** Current listModel that contains current edited list and its participants */
+ protected ParticipantListModel listModel;
+
+ /**
+ * Constructor of PollFormModel. Initialize with edited {@code poll}. Need
+ * services {@code servicePoll} and {@code manager} to manage the {@code
+ * poll}.
+ *
+ * @param poll Current poll in edition
+ * @param servicePoll ServicePoll to manage poll
+ * @param manager PollenManager to manage ids
+ */
+ public PollFormModel(Poll poll,
+ ServicePoll servicePoll,
+ PollenManager manager) {
+ this.poll = poll;
+ this.service = servicePoll;
+ lists = new LinkedHashMap<String, ParticipantList>();
+ this.listModel = new ParticipantListModel(service, manager);
+ }
+
+ /**
+ * 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
+ * automatically added and set for current usage. For a {@link
+ * PollType#GROUP} poll, the listModel is simply reset.
+ *
+ * @param type PollType to change
+ */
+ public void setPollType(PollType type) {
+ lists.clear();
+ if (type.isRestricted()) {
+ addNewList(DEFAULT_LIST_NAME);
+ // Set automatically the current list to the unique one
+ listModel.setList(lists.get(DEFAULT_LIST_NAME));
+ } else if (type.isGroup()) {
+ listModel.reset();
+ }
+ poll.setPollType(type);
+ }
+
+ /**
+ * Retrieve a collection of {@link ParticipantList} of current lists.
+ *
+ * @return a Collection<ParticipantList>
+ */
+ public Collection<ParticipantList> getLists() {
+ return lists.values();
+ }
+
+ /**
+ * Add a new list to the poll using the {@code listName}. The list will not
+ * be added if the {@code listName} is empty or if a list with this {@code
+ * listName} already exists.
+ *
+ * @param listName for the new list to add
+ * @return true if the list has been added, false otherwise
+ * @see #addList(ParticipantList)
+ */
+ public boolean addNewList(String listName) {
+ boolean result = false;
+ if (StringUtils.isNotEmpty(listName)) {
+ ParticipantList newList = service.getNewPollList();
+ newList.setName(listName);
+ return addList(newList);
+ }
+ return result;
+ }
+
+ /**
+ * Add a {@code list} to the poll. The {@code list} will not be added if its
+ * name already reference an exising list.
+ *
+ * @param list ParticipantList to add
+ * @return true if the list has been added, false otherwise
+ */
+ public boolean addList(ParticipantList list) {
+ boolean result = false;
+ if (list != null) {
+ String listName = list.getName();
+ if (!lists.containsKey(listName)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Add list : " + listName);
+ }
+ lists.put(listName, list);
+ result = true;
+ } else if (logger.isDebugEnabled()) {
+ logger.debug("Refuse adding list : " + listName);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Give the current {@link ParticipantListModel} that references the list
+ * currently edited.
+ *
+ * @return the current listModel
+ */
+ public ParticipantListModel getListModel() {
+ return listModel;
+ }
+
+ /**
+ * Set the current list using its {@code listName}. The previous current
+ * list will be automatically saved. If error occurs during save, the
+ * previous list will be refresh (no list change will be done).
+ *
+ * @param listName name of the list to set (empty name will be ignored)
+ * @throws PollenBusinessException for saving error (doubloons)
+ * @see #saveCurrentList()
+ */
+ public void setCurrentList(String listName) throws PollenBusinessException {
+ if (StringUtils.isNotEmpty(listName)) {
+ ParticipantList list = getCurrentList();
+ try {
+ // Save previous list if not null
+ if (list != null) {
+ saveCurrentList();
+ }
+ // Change list
+ list = lists.get(listName);
+ } finally {
+ // Previous list will be keeped if error occurs during save.
+ // Apply change in listModel
+ listModel.setList(list);
+ }
+ }
+ }
+
+ /**
+ * Get the current list.
+ *
+ * @return the current list in edition.
+ */
+ public ParticipantList getCurrentList() {
+ return listModel.getList();
+ }
+
+ /** Remove the current list. */
+ public void removeCurrentList() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Remove list : " + listModel.getList().getName());
+ }
+
+ getLists().remove(listModel.getList());
+ listModel.reset();
+ }
+
+ /**
+ * Save the current participants from current list.
+ *
+ * @throws PollenBusinessException for saving errors (doubloons)
+ * @see ParticipantListModel#persistParticipants()
+ */
+ public void saveCurrentList() throws PollenBusinessException {
+ listModel.persistParticipants();
+ }
+
+ public void create() throws PollenBusinessException {
+ service.createPoll(poll, getLists());
+ }
+
+ /**
+ * ValueEncoder toClient is used to convert {@code value} to the list name.
+ *
+ * @param value ParticipantList to convert toClient
+ * @return the list name as a unique key for the list
+ * @see ValueEncoder#toClient(Object)
+ */
+ @Override
+ public String toClient(ParticipantList value) {
+ return value.getName();
+ }
+
+ /**
+ * ValueEncoder toClient is used to convert {@code clientValue} key to the
+ * list object.
+ *
+ * @param clientValue List name of the ParticipantList to retrieve.
+ * @return the ParticipantList corresponding to its name in argument
+ * @see ValueEncoder#toValue(String)
+ */
+ @Override
+ public ParticipantList toValue(String clientValue) {
+ for (ParticipantList curr : lists.values()) {
+ if (clientValue.equals(curr.getName())) {
+ return curr;
+ }
+ }
+ return null;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollFormModel.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-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,11 +1,8 @@
package org.chorem.pollen.ui.pages.poll;
import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Field;
import org.apache.tapestry5.RenderSupport;
-import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.IncludeStylesheet;
@@ -13,7 +10,6 @@
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.corelib.components.AjaxFormLoop;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
@@ -24,7 +20,6 @@
import org.chorem.pollen.entity.Participant;
import org.chorem.pollen.entity.ParticipantList;
import org.chorem.pollen.entity.Poll;
-import org.chorem.pollen.entity.PollAccountImpl;
import org.chorem.pollen.entity.PreventRule;
import org.chorem.pollen.entity.PreventRuleImpl;
import org.chorem.pollen.mail.PreventRuleManager;
@@ -32,23 +27,16 @@
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.GenericEncoder;
-import org.chorem.pollen.ui.data.ParticipantsListener;
+import org.chorem.pollen.ui.data.ParticipantListModel;
+import org.chorem.pollen.ui.data.PollFormModel;
import org.chorem.pollen.ui.services.PollenManager;
import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
/**
* PollForm : Creation and Modification.
@@ -70,11 +58,8 @@
* <p/>
* Created: 2 mars 2010
*
- * @author fdesbois
- * @version $Revision$
- * <p/>
- * Mise a jour: $Date$
- * par : $Author$
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
*/
@IncludeStylesheet("context:css/poll.css")
@IncludeJavaScriptLibrary({"context:js/pollForm.js", "context:js/jquery-1.4.2.min.js"})
@@ -123,6 +108,8 @@
poll = null;
initMainInfos();
initOptions();
+ model = null;
+ listsFeedback.clearErrors();
}
/**
@@ -225,7 +212,7 @@
}
}
- /** ************************* MAIN INFOS ********************************* */
+ /** *********************** MAIN INFOS ********************************* */
@InjectComponent
private Form mainForm;
@@ -410,22 +397,25 @@
return getPoll().getPollType().isFree();
}
- /** *********************** LISTS *****************************************/
+ /** ********************* LISTS **************************************** */
@Persist
- private Map<String, ParticipantList> lists;
+ private PollFormModel model;
+// @Persist
+// private Map<String, ParticipantList> lists;
+
@Property
private ParticipantList list;
// @Persist
// private String listSelectedName;
- @Persist
- private ParticipantList listSelected;
+// @Persist
+// private ParticipantList listSelected;
+//
+// private Map<String, Participant> selectedParticipants;
- private Map<String, Participant> selectedParticipants;
-
@Property
private Participant participant;
@@ -444,30 +434,47 @@
@InjectComponent
private FeedBack listsFeedback;
- private ParticipantsListener listSelectedListener;
+ private boolean editLists;
- public Map<String, ParticipantList> getLists() {
- if (lists == null) {
- lists = new LinkedHashMap<String, ParticipantList>();
- if (getPoll().getPollType().isRestricted()) {
- lists.put("LIST", servicePoll.getNewPollList());
+ /** DATA ** */
+
+ public PollFormModel getModel() {
+ if (model == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("-------- NEW MODEL --------");
}
+ model = new PollFormModel(getPoll(), servicePoll, manager);
}
- return lists;
+ return model;
}
+ public ParticipantListModel getListModel() {
+ return getModel().getListModel();
+ }
+
+ public Collection<ParticipantList> getLists() {
+ return getModel().getLists();
+ }
+
+ public ParticipantList getListSelected() {
+ ParticipantList result = getModel().getCurrentList();
+ if (log.isDebugEnabled() && result != null) {
+ log.debug("List selected : " + result.getName());
+ }
+ return result;
+ }
+
+ /** PollType change ** */
+
@Log
Object onChangeFromPollType(String value) {
PollType type = PollType.valueOf(value);
- getPoll().setPollType(type);
+ getModel().setPollType(type);
if (type.isRestrictedOrGroup()) {
listsFeedback.addInfo("Edition en cours d'une liste restreinte. " +
"Attention un changement de type de restriction provoquera" +
" une remise à zéro de la/les liste(s) en cours d'édition.");
}
- // Clean persist data for lists : careful, will reset unsaved data
- lists = null;
- listSelected = null;
return refreshListZone();
}
@@ -476,249 +483,81 @@
return getPoll().getPollType().isRestrictedOrGroup();
}
- public ParticipantList getListSelected() {
- if (listSelected == null && getPoll().getPollType().isRestricted()) {
- listSelected = getLists().get("LIST");
-// if (listSelected == null) {
-// listSelected = servicePoll.getNewPollList();
-// getLists().put("LIST", listSelected);
-// if (log.isDebugEnabled()) {
-// log.debug("Instantiate list for restricted poll");
-// }
-// }
- }
-// else if (StringUtils.isNotEmpty(listSelectedName)) {
-// listSelected = getLists().get(listSelectedName);
-// }
- if (log.isDebugEnabled() && listSelected != null) {
- log.debug("List selected : " + listSelected.getName());
- }
- return listSelected;
- }
+ /** GROUPS MANAGMENT ** */
public String getStyleSelected() {
return isCurrentListSelected() ? " selected" : "";
}
public boolean isCurrentListSelected() {
- return listSelected != null &&
- list.getName().equals(listSelected.getName());
+ return getListSelected() != null &&
+ list.getName().equals(getListSelected().getName());
}
@Log
void onSelectedFromAddList() {
- formActivate = true;
- if (StringUtils.isNotEmpty(listName) &&
- !getLists().containsKey(listName)) {
- if (log.isDebugEnabled()) {
- log.debug("Add list : " + listName);
- }
- ParticipantList list = servicePoll.getNewPollList();
- list.setName(listName);
- getLists().put(listName, list);
- listSelected = list;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Refuse adding list : " + listName);
- }
-// listSelected = null;
-// listsFeedback.addError("Impossible d'ajouter une liste avec un nom vide");
- }
+ // Set flag for editing lists
+ setEditListsFlag();
+ // Add new list in model
+ getModel().addNewList(listName);
+ // Set the new list as selected one
+ setSelectedList(listName);
// Reset form field before refresh form
listName = null;
- if (log.isDebugEnabled() && listSelected != null) {
- log.debug("Selected list : " + listSelected.getName());
- }
}
@Log
void onSelectedFromEditList(String listName) {
- formActivate = true;
- listSelected = getLists().get(listName);
- if (log.isDebugEnabled() && listSelected != null) {
- log.debug("List selected : " + listSelected.getName());
- }
+ // Set flag for editing lists
+ setEditListsFlag();
+ // Set the selected list
+ setSelectedList(listName);
}
- public Map<String, Participant> getSelectedParticipants() {
- if (selectedParticipants == null) {
- if (log.isDebugEnabled() && listSelected != null) {
- log.debug("Retrieve participants from list");
- }
- selectedParticipants = new LinkedHashMap<String, Participant>();
- for (Participant participant : listSelected.getParticipants()) {
- String id = manager.createPollenUrlId();
- selectedParticipants.put(id, participant);
- }
- }
- return selectedParticipants;
- }
-
- @Log
- Object onActionFromRemoveList() {
- if (log.isDebugEnabled()) {
- log.debug("Remove list : " + listSelected.getName());
- }
- getLists().remove(listSelected.getName());
- if (log.isDebugEnabled()) {
- for (ParticipantList list : getLists().values()) {
- log.debug("Existing lists : " + list.getName());
- }
- }
- listSelected = null;
- return refreshListZone();
- }
-
- @Log
- void onSelectedFromSaveList(String listName) {
+ protected void setSelectedList(String listName) {
+ // Change current list, will save the previous current one
+ // Errors can appear during saving previous participants.
try {
- listSelected.setParticipants(selectedParticipants.values());
+ getModel().setCurrentList(listName);
} catch (PollenBusinessException eee) {
String message = manager.getErrorMessage(eee, messages, logger);
listsFeedback.addError(message);
}
}
-
-// @Log
-// void onSelectedFromRemoveList(String listName) {
-// if (formActivate) {
-// if (log.isWarnEnabled()) {
-// log.warn("Strange submit behavior... Escape remove.");
-// }
-// return;
-// }
-// formActivate = true;
-// if (log.isDebugEnabled()) {
-// log.debug("Remove list : " + listName);
-// }
-// getLists().remove(listName);
-// if (log.isDebugEnabled()) {
-// for (ParticipantList list : getLists().values()) {
-// log.debug("Existing lists : " + list.getName());
-// }
-// }
-// if (listSelected != null && listSelected.getName().equals(listName)) {
-// listSelected = null;
-// }
-// }
- public ValueEncoder<ParticipantList> getListEncoder() {
- final Collection<ParticipantList> lists = getLists().values();
- ValueEncoder<ParticipantList> encoder =
- new ValueEncoder<ParticipantList>() {
-
- @Override
- public String toClient(ParticipantList participant) {
- return participant.getName();
- }
-
- @Override
- public ParticipantList toValue(String s) {
- for (ParticipantList curr : lists) {
- if (s.equals(curr.getName())) {
- return curr;
- }
- }
- return null;
- }
- };
- return encoder;
+ @Log
+ Object onActionFromRemoveList() {
+ getModel().removeCurrentList();
+ return refreshListZone();
}
+ /** PARTICIPANTS FOR LIST ** */
+
Object onAddRowFromParticipants() {
- Participant newParticipant = servicePoll.getNewPollParticipant();
- //selectedParticipants.add(newParticipant);
-// try {
-// listSelected.addParticipant(newParticipant);
-// } catch (PollenBusinessException eee) {
-// String message = manager.getErrorMessage(eee, messages, logger);
-// listsFeedback.addError(message);
-// }
- return newParticipant;
+ return getListModel().addNewParticipant();
}
void onRemoveRowFromParticipants(Participant participant) {
-// if (log.isDebugEnabled()) {
-// for (Participant p : listSelected.getParticipants()) {
-// log.debug("Before Existing participants : " +
-// p.getName() + "_" + p.getEmail());
-// }
-// }
-//// boolean isRemoved =
-//// listSelected.getParticipants().remove(participant);
-//// listSelected.removeParticipant(participant);
-// if (log.isDebugEnabled()) {
-// log.debug("Participant removed : " + participant.getName());
-// }
-// if (log.isDebugEnabled()) {
-// for (Participant p : listSelected.getParticipants()) {
-// log.debug("Existing participants : " +
-// p.getName() + "_" + p.getEmail());
-// }
-// }
+ getListModel().removeParticipant(participant);
}
- public ValueEncoder<Participant> getParticipantEncoder() {
- ValueEncoder<Participant> encoder = new ValueEncoder<Participant>() {
-
- @Override
- public String toClient(Participant participant) {
-// String key = getParticipantKey(participant);
- if (log.isDebugEnabled()) {
- log.debug("Participant to find : " + participant);
- }
- for (Map.Entry<String, Participant> entry :
- getSelectedParticipants().entrySet()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Selected participant entry : " +
- "key = " + entry.getKey() + " -> " +
- "value = " + entry.getValue());
- }
- if (entry.getValue() == participant) {
- if (logger.isDebugEnabled()) {
- logger.debug("toClient : key = " + entry.getKey());
- }
- return entry.getKey();
- }
- }
- return null;
- }
-
- @Override
- public Participant toValue(String s) {
-// for (Participant curr : getSelectedParticipants()) {
-// String key = getParticipantKey(curr);
-// if (s.equals(key)) {
-// if (logger.isDebugEnabled()) {
-// logger.debug("toValue from : " + s);
-// }
-// return curr;
-// }
-// }
- Participant participant = getSelectedParticipants().get(s);
- if (logger.isDebugEnabled()) {
- logger.debug("toValue : key = " + s + " -> " + participant);
- }
- return participant;
- }
- };
- return encoder;
- }
-
protected Object refreshListZone() {
formActivate = false;
return listsZone.getBody();
}
+ protected void setEditListsFlag() {
+ formActivate = true;
+ editLists = true;
+ }
+
@Log
Object onSuccess() {
+// if (!editLists) {
+// saveCurrentList();
+// }
return mainZone;
}
- // TODO-FD2010-05-18 : Put this in ParticipantHelper in business
- public String getParticipantKey(Participant participant) {
- return participant.getName() + "_" + participant.getEmail();
- }
-
}
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-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-05-19 12:59:57 UTC (rev 3001)
@@ -21,10 +21,6 @@
package org.chorem.pollen.ui.services;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Map;
-import java.util.Properties;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.apache.tapestry5.ioc.services.SymbolProvider;
@@ -36,26 +32,31 @@
import org.nuiton.util.ApplicationConfig;
import org.slf4j.Logger;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+
/**
* WaoManager
- *
+ * <p/>
* Created: 24 nov. 2009
*
* @author fdesbois
* @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
*/
public class PollenManager implements Runnable,
- RegistryShutdownListener,
- SymbolProvider {
+ RegistryShutdownListener,
+ SymbolProvider {
// private static final Logger logger =
// LoggerFactory.getLogger(PollenManager.class);
private final Map<String, String> propertiesMap =
- new CaseInsensitiveMap<String>();
+ new CaseInsensitiveMap<String>();
private PollenContext context;
@@ -74,16 +75,14 @@
this.serviceUser = serviceUser;
}
- /**
- * Called to start the application.
- */
+ /** Called to start the application. */
@Override
public void run() {
context.start(serviceUser);
// Copy properties to propertiesMap (insentitive) for SymbolProvider
Properties properties = getConfiguration().getOptions();
for (Object key : properties.keySet()) {
- propertiesMap.put((String)key,
+ propertiesMap.put((String) key,
properties.getProperty((String) key));
}
}
@@ -93,9 +92,7 @@
return propertiesMap.get(key);
}
- /**
- * Called to stop the application
- */
+ /** Called to stop the application */
@Override
public void registryDidShutdown() {
context.stop();
@@ -122,12 +119,12 @@
return context.getCurrentDate();
}
- public String createPollenUrlId() {
+ public String createPollenId() {
return context.createPollenUrlId();
}
public String getErrorMessage(PollenBusinessException eee,
- Messages messages, Logger logger) {
+ Messages messages, Logger logger) {
if (logger.isDebugEnabled()) {
logger.debug("ERROR from business : " + eee.getMessage() +
" _ args = " + Arrays.toString(eee.getArgs()));
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,6 +1,9 @@
-<!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:pageBodyId="p-pollForm" t:pageTitle="prop:pageTitle"
- xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+<!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:pageBodyId="p-pollForm" t:pageTitle="prop:pageTitle"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
+ xmlns:p="tapestry:parameter">
<h1 class="titlePoll">
<t:if t:test="createMode">
@@ -10,303 +13,417 @@
</h1>
<t:zone t:id="mainZone" t:update="show">
- <form t:type="form" t:id="mainForm" t:zone="mainZone" action="post">
- <t:errors/>
- <!-- MAIN INFOS -->
- <div id="p-pollForm-mainInfos">
- <fieldset>
- <legend>
- <img class="form-toggle" src="${asset:context:img/1uparrow.png}" /> ${message:legend-mainInfos}
- </legend>
- <div class="form-block">
- <p>
- <span><label t:type="label" t:for="title"/>:</span>
- <input type="text" t:type="textfield" class="title" t:id="title" value="poll.title" t:validate="required"/>
- </p>
- <p>
- <span><label t:type="label" t:for="creatorName"/>:</span>
- <input type="text" t:type="textfield" t:id="creatorName" value="poll.creator.name" t:validate="required,minlength=2"/>
- <label t:type="label" t:for="email"/>:
- <input type="text" t:type="textfield" class="email" t:id="email" value="poll.creator.email" t:validate="regexp"/>
- </p>
- <p>
- <span><label t:type="label" t:for="description"/>: </span>
- <textarea t:type="textarea" cols="80" rows="2" t:id="description" t:value="poll.description">${poll.description}</textarea>
- </p>
- <p>
- <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
- <span><label t:type="label" t:for="beginDate"/>: </span>
- <input t:type="ck/dateTimeField" t:id="beginDate" value="poll.beginDate" t:validate="regexp"
- t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/>
- <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
- <label t:type="label" t:for="endDate"/>:
- <input t:type="ck/dateTimeField" t:id="endDate" value="poll.endDate" t:validate="regexp"
- t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/>
- <label t:type="label" t:for="voteCountingType"/>:
- <select t:type="select" t:id="voteCountingType" t:value="poll.voteCountingType" t:validate="required">
- <option></option>
- </select>
- <span t:type="ck/Tooltip" title="${message:help}" t:value="${message:voteCounting-help}" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
+<form t:type="form" t:id="mainForm" t:zone="mainZone" action="post">
+<t:errors />
+<!-- MAIN INFOS -->
+<div id="p-pollForm-mainInfos">
+ <fieldset>
+ <legend>
+ <img class="form-toggle" src="${asset:context:img/1uparrow.png}" /> ${message:legend-mainInfos}
+ </legend>
+ <div class="form-block">
+ <p>
+ <span><label t:type="label" t:for="title" />:</span>
+ <input type="text" t:type="textfield" class="title" t:id="title"
+ value="poll.title" t:validate="required" />
+ </p>
+
+ <p>
+ <span><label t:type="label" t:for="creatorName" />:</span>
+ <input type="text" t:type="textfield" t:id="creatorName"
+ value="poll.creator.name"
+ t:validate="required,minlength=2" />
+ <label t:type="label" t:for="email" />:
+ <input type="text" t:type="textfield" class="email" t:id="email"
+ value="poll.creator.email" t:validate="regexp" />
+ </p>
+
+ <p>
+ <span><label t:type="label" t:for="description" />: </span>
+ <textarea t:type="textarea" cols="80" rows="2"
+ t:id="description" t:value="poll.description">${poll.description}</textarea>
+ </p>
+
+ <p>
+ <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
+ <span><label t:type="label" t:for="beginDate" />: </span>
+ <input t:type="ck/dateTimeField" t:id="beginDate"
+ value="poll.beginDate" t:validate="regexp"
+ t:datePattern="message:date-pattern" t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
+ <label t:type="label" t:for="endDate" />:
+ <input t:type="ck/dateTimeField" t:id="endDate"
+ value="poll.endDate" t:validate="regexp"
+ t:datePattern="message:date-pattern" t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ <label t:type="label" t:for="voteCountingType" />:
+ <select t:type="select" t:id="voteCountingType"
+ t:value="poll.voteCountingType" t:validate="required">
+ <option></option>
+ </select>
+ <span t:type="ck/Tooltip" title="${message:help}"
+ t:value="${message:voteCounting-help}"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="${message:help}" />
</span>
- </p>
- </div>
- </fieldset>
+ </p>
</div>
- <!-- OPTIONS -->
- <div id="p-pollForm-options">
- <fieldset>
- <legend>
- <!--<input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/>-->
- <!--<label t:type="label" t:for="advancedOptions"/>-->
- <img class="form-toggle" src="${asset:context:img/1downarrow.png}" /> ${message:legend-options}
- </legend>
- <div class="form-block clearfix" style="display:none;">
- <!--<t:formFragment t:id="optionsFragment" visible="advancedOptions">-->
- <!-- LEFT COLUMN -->
- <div class="left-column fleft">
- <p>
- <input t:type="checkbox" t:id="anonymous" value="poll.anonymous" />
- <label t:type="label" t:for="anonymous"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymous-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </fieldset>
+</div>
+<!-- OPTIONS -->
+<div id="p-pollForm-options">
+ <fieldset>
+ <legend>
+ <!--<input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment" t:fragment="optionsFragment"/>-->
+ <!--<label t:type="label" t:for="advancedOptions"/>-->
+ <img class="form-toggle"
+ src="${asset:context:img/1downarrow.png}" /> ${message:legend-options}
+ </legend>
+ <div class="form-block clearfix" style="display:none;">
+ <!--<t:formFragment t:id="optionsFragment" visible="advancedOptions">-->
+ <!-- LEFT COLUMN -->
+ <div class="left-column fleft">
+ <p>
+ <input t:type="checkbox" t:id="anonymous"
+ value="poll.anonymous" />
+ <label t:type="label" t:for="anonymous" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:anonymous-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <input t:type="checkbox" t:id="continuousResults" value="poll.continuousResults"/>
- <label t:type="label" t:for="continuousResults"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:continuousResults-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <input t:type="checkbox" t:id="continuousResults"
+ value="poll.continuousResults" />
+ <label t:type="label" t:for="continuousResults" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:continuousResults-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <input t:type="checkbox" t:id="choiceAddAllowed" value="poll.choiceAddAllowed"
- t:mixins="triggerfragment" t:fragment="choiceDateFragment"/>
- <label t:type="label" t:for="choiceAddAllowed"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceAddAllowed-help}" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <input t:type="checkbox" t:id="choiceAddAllowed"
+ value="poll.choiceAddAllowed"
+ t:mixins="triggerfragment"
+ t:fragment="choiceDateFragment" />
+ <label t:type="label" t:for="choiceAddAllowed" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:choiceAddAllowed-help}"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <t:formFragment t:id="choiceDateFragment" t:visible="poll.choiceAddAllowed">
- <label t:type="label" t:for="beginChoiceDate"/>
- <input t:type="ck/dateTimeField" t:id="beginChoiceDate" value="poll.beginChoiceDate" t:validate="regexp"
- t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/>
- <br/>
- <label t:type="label" t:for="endChoiceDate"/>
- <input t:type="ck/dateTimeField" t:id="endChoiceDate" value="poll.endChoiceDate" t:validate="regexp"
- t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"/>
- </t:formFragment>
- </p>
- <p>
- <input t:type="checkbox" t:id="sendNotification" value="hasNotification"
- disabled="notificationDisabled" t:mixins="triggerfragment" t:fragment="notificationFragment"/>
- <label t:type="label" t:for="sendNotification"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:sendNotification-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <t:formFragment t:id="choiceDateFragment"
+ t:visible="poll.choiceAddAllowed">
+ <label t:type="label" t:for="beginChoiceDate" />
+ <input t:type="ck/dateTimeField" t:id="beginChoiceDate"
+ value="poll.beginChoiceDate" t:validate="regexp"
+ t:datePattern="message:date-pattern"
+ t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ <br />
+ <label t:type="label" t:for="endChoiceDate" />
+ <input t:type="ck/dateTimeField" t:id="endChoiceDate"
+ value="poll.endChoiceDate" t:validate="regexp"
+ t:datePattern="message:date-pattern"
+ t:timePicker="true"
+ t:timePickerAdjacent="true" />
+ </t:formFragment>
+ </p>
+ <p>
+ <input t:type="checkbox" t:id="sendNotification"
+ value="hasNotification"
+ disabled="notificationDisabled"
+ t:mixins="triggerfragment"
+ t:fragment="notificationFragment" />
+ <label t:type="label" t:for="sendNotification" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:sendNotification-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <t:formFragment id="notificationHidden" t:id="notificationFragment" t:visible="hasNotification">
- <label t:type="label" t:for="notification"/>
- <input t:type="textfield" t:id="notification" value="notification.sensibility" t:size="3" t:validate="min=0"/>
- ${message:notification-label2}
- </t:formFragment>
- </p>
- </div>
- <!-- RIGHT COLUMN -->
- <div class="fleft">
- <p>
- <input t:type="checkbox" t:id="anonymousVoteAllowed" value="poll.anonymousVoteAllowed" disabled="anonymousVoteAllowedDisabled"/>
- <label t:type="label" t:for="anonymousVoteAllowed"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymousVoteAllowed-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <t:formFragment id="notificationHidden"
+ t:id="notificationFragment"
+ t:visible="hasNotification">
+ <label t:type="label" t:for="notification" />
+ <input t:type="textfield" t:id="notification"
+ value="notification.sensibility" t:size="3"
+ t:validate="min=0" />
+ ${message:notification-label2}
+ </t:formFragment>
+ </p>
+ </div>
+ <!-- RIGHT COLUMN -->
+ <div class="fleft">
+ <p>
+ <input t:type="checkbox" t:id="anonymousVoteAllowed"
+ value="poll.anonymousVoteAllowed"
+ disabled="anonymousVoteAllowedDisabled" />
+ <label t:type="label" t:for="anonymousVoteAllowed" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:anonymousVoteAllowed-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <input t:type="checkbox" t:id="publicResults" value="poll.publicResults" disabled="publicResultsDisabled"/>
- <label t:type="label" t:for="publicResults"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:publicResults-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <input t:type="checkbox" t:id="publicResults"
+ value="poll.publicResults"
+ disabled="publicResultsDisabled" />
+ <label t:type="label" t:for="publicResults" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:publicResults-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb" disabled="choiceNbDisabled"
- t:mixins="triggerFragment" t:fragment="choiceNbFragment"/>
- <label t:type="label" t:for="choiceNb"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceNb-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb"
+ disabled="choiceNbDisabled"
+ t:mixins="triggerFragment"
+ t:fragment="choiceNbFragment" />
+ <label t:type="label" t:for="choiceNb" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:choiceNb-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <t:formFragment id="choiceNbHidden" t:id="choiceNbFragment" t:visible="hasChoiceNb">
- <label t:type="label" t:for="maxChoiceNb"/>
- <input t:type="textfield" t:id="maxChoiceNb" t:value="poll.maxChoiceNb" t:size="1" t:validate="min=0"/>
- </t:formFragment>
- </p>
- <p>
- <input t:type="checkbox" t:id="sendReminder" t:value="hasReminder" disabled="reminderDisabled"
- t:mixins="triggerfragment" t:fragment="reminderFragment"/>
- <label t:type="label" t:for="sendReminder"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:sendReminder-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </p>
+
+ <p>
+ <t:formFragment id="choiceNbHidden" t:id="choiceNbFragment"
+ t:visible="hasChoiceNb">
+ <label t:type="label" t:for="maxChoiceNb" />
+ <input t:type="textfield" t:id="maxChoiceNb"
+ t:value="poll.maxChoiceNb" t:size="1"
+ t:validate="min=0" />
+ </t:formFragment>
+ </p>
+ <p>
+ <input t:type="checkbox" t:id="sendReminder"
+ t:value="hasReminder" disabled="reminderDisabled"
+ t:mixins="triggerfragment"
+ t:fragment="reminderFragment" />
+ <label t:type="label" t:for="sendReminder" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:sendReminder-help"
+ t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </p>
- <p>
- <t:formFragment id="reminderHidden" t:id="reminderFragment" t:visible="hasReminder">
- <input t:type="textfield" t:id="reminder" t:value="reminder.sensibility" t:size="1" t:validate="min=0"/>
- <label t:type="label" t:for="reminder"/>
- </t:formFragment>
- </p>
- </div>
- <!--</t:formFragment>-->
- </div>
- </fieldset>
+ </p>
+
+ <p>
+ <t:formFragment id="reminderHidden" t:id="reminderFragment"
+ t:visible="hasReminder">
+ <input t:type="textfield" t:id="reminder"
+ t:value="reminder.sensibility" t:size="1"
+ t:validate="min=0" />
+ <label t:type="label" t:for="reminder" />
+ </t:formFragment>
+ </p>
+ </div>
+ <!--</t:formFragment>-->
</div>
- <!-- 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">-->
- <!--<option></option>-->
- <!--</select> -->
- <!--<input type="image" t:type="submit" class="ico refresh" t:id="refreshChoices" value="Refresh choices" title="${message:refreshChoices-button}"/>-->
- <!--</legend>-->
- <!--<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>-->
- <!--</fieldset>-->
- <!--</div>-->
- <!-- LISTS -->
- <div id="p-pollForm-lists">
- <fieldset>
- <legend>
- <label t:type="label" t:for="pollType" />:
- <select t:type="select" class="list-select" t:id="pollType" t:value="poll.pollType" t:validate="required"
- t:mixins="nuiton/zoneUpdater" t:event="change" t:zone="p-pollForm-lists-zone"/>
- <span t:type="ck/Tooltip" title="message:help" t:value="message:pollType-help" t:effect="appear">
- <img src="${asset:context:img/help.png}" alt="message:help" />
+ </fieldset>
+</div>
+<!-- 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">-->
+<!--<option></option>-->
+<!--</select> -->
+<!--<input type="image" t:type="submit" class="ico refresh" t:id="refreshChoices" value="Refresh choices" title="${message:refreshChoices-button}"/>-->
+<!--</legend>-->
+<!--<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>-->
+<!--</fieldset>-->
+<!--</div>-->
+<!-- LISTS -->
+<div id="p-pollForm-lists">
+ <fieldset>
+ <legend>
+ <label t:type="label" t:for="pollType" />:
+ <select t:type="select" class="list-select" t:id="pollType"
+ t:value="poll.pollType" t:validate="required"
+ t:mixins="nuiton/zoneUpdater" t:event="change"
+ t:zone="p-pollForm-lists-zone" />
+ <span t:type="ck/Tooltip" title="message:help"
+ t:value="message:pollType-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}"
+ alt="message:help" />
</span>
- </legend>
- <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone" class="form-block" t:update="show">
- <t:if t:test="canDisplayLists()">
- <t:nuiton.feedback t:id="listsFeedback" /><br />
- <t:subForm t:visible="formActivate">
- <t:if t:test="poll.pollType.group">
- <p>
- <label t:type="label" t:for="listName" />:
- <input t:type="textfield" t:id="listName" value="listName" />
- <input t:type="submit" t:id="addList" value="ADD" />
- <!--<a t:type="actionlink" t:id="addList" t:zone="p-pollForm-lists-zone">-->
- <!--ADD-->
- <!--</a>-->
- </p>
- <p class="center">
- <t:loop t:source="lists.values()" t:value="list" t:encoder="listEncoder">
- <input class="list-edition${styleSelected}" t:type="nuiton/submitContext" t:context="list.name" t:id="editList" value="${list.name}" />
- <!--<span t:type="any" t:mixins="nuiton/confirm">-->
- <!--<input t:type="nuiton/submitContext" t:id="removeList" t:image="context:img/delete.png" t:context="list.name" value="${message:delete}" />-->
- <!--</span>-->
- <t:if t:test="currentListSelected">
- <input t:type="submit" t:id="saveList" t:image="context:img/save.png" t:zone="p-pollForm-lists-zone" />
- <a t:type="actionlink" t:id="removeList" t:zone="p-pollForm-lists-zone">
- <span t:type="any" t:mixins="nuiton/confirm">
- <img src="${asset:context:img/delete.png}" alt="${message:delete}" />
+ </legend>
+ <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone"
+ class="form-block" t:update="show">
+ <t:if t:test="canDisplayLists()">
+ <t:nuiton.feedback t:id="listsFeedback" />
+ <br />
+ <t:subForm t:visible="formActivate">
+ <t:if t:test="poll.pollType.group">
+ <p>
+ <label t:type="label" t:for="listName" />:
+ <input t:type="textfield" t:id="listName"
+ value="listName" />
+ <input t:type="submit" t:id="addList" value="ADD" />
+ <!--<a t:type="actionlink" t:id="addList" t:zone="p-pollForm-lists-zone">-->
+ <!--ADD-->
+ <!--</a>-->
+ </p>
+
+ <p class="center">
+ <t:loop t:source="lists" t:value="list"
+ t:encoder="model">
+ <input class="list-edition${styleSelected}"
+ t:type="nuiton/submitContext"
+ t:context="list.name" t:id="editList"
+ value="${list.name}" />
+ <!--<span t:type="any" t:mixins="nuiton/confirm">-->
+ <!--<input t:type="nuiton/submitContext" t:id="removeList" t:image="context:img/delete.png" t:context="list.name" value="${message:delete}" />-->
+ <!--</span>-->
+ <t:if t:test="currentListSelected">
+ <!--<input t:type="submit" t:id="saveList" t:image="context:img/save.png" />-->
+ <a t:type="actionlink" t:id="removeList"
+ t:zone="p-pollForm-lists-zone">
+ <span t:type="any"
+ t:mixins="nuiton/confirm">
+ <img src="${asset:context:img/delete.png}"
+ alt="${message:delete}" />
</span>
- </a>
- </t:if>
- </t:loop>
- </p>
- </t:if>
- <t:if t:test="listSelected">
- <div class="t-data-grid">
- <table class="t-data-grid">
- <thead>
- <tr>
- <th>${message:pollen.ui.participant.name-label}</th>
- <th>${message:pollen.ui.participant.email-label}</th>
- <th>${message:pollen.ui.participant.weight-label}</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <tr t:type="ajaxformloop" t:id="participants" source="selectedParticipants.values()" value="participant" t:encoder="participantEncoder">
- <td>
- <t:textfield t:id="participantName" value="participant.name" size="20" t:validate="required"/>
- </td>
- <td>
- <t:textfield t:id="participantEmail" value="participant.email" size="25" t:validate="email"/>
- </td>
- <td>
- <t:textfield t:id="participantWeight" value="participant.weight" size="1"/>
- </td>
- <td>
- <t:removerowlink>
- <img src="${asset:context:img/delete.png}" alt="${message:delete}"/>
- </t:removerowlink>
- </td>
- <p:addRow>
- <td colspan="4" class="center">
- <t:addrowlink>${message:pollen.ui.participant.add}</t:addrowlink>
- </td>
- </p:addRow>
- </tr>
- </tbody>
- </table>
- </div>
- </t:if>
- </t:subForm>
+ </a>
+ </t:if>
+ </t:loop>
+ </p>
</t:if>
- <!--<t:delegate t:to="listsBlock" />-->
- <!--<t:block t:id="listsForm">-->
- <!--<form t:type="form" action="tapestry">-->
- <!--<t:delegate t:to="listsFields" />-->
- <!--</form>-->
- <!--</t:block>-->
- <!--<t:block t:id="listsFields">-->
- <!--<t:if t:test="poll.pollType.group">-->
- <!--<p>-->
- <!--<label t:type="label" t:for="listName" />: -->
- <!--<input t:type="textfield" t:id="listName" value="listName"/> -->
- <!--<input t:type="submit" t:id="addList" value="ADD"/>-->
- <!--</p>-->
- <!--<p>-->
- <!--<t:loop t:source="lists.values()" t:value="list" t:volatile="true">-->
- <!--${list.name} -->
- <!--</t:loop>-->
- <!--</p>-->
- <!--<p:else>-->
- <!--COOL-->
- <!--</p:else>-->
- <!--</t:if>-->
- <!--</t:block> -->
- </div>
- </fieldset>
+ <t:if t:test="listSelected">
+ <div class="t-data-grid">
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <th>
+ ${message:pollen.ui.participant.name-label}
+ </th>
+ <th>
+ ${message:pollen.ui.participant.email-label}
+ </th>
+ <th>
+ ${message:pollen.ui.participant.weight-label}
+ </th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="ajaxformloop" t:id="participants"
+ source="listModel.participants"
+ value="participant" t:encoder="listModel">
+ <td>
+ <t:textfield t:id="participantName"
+ value="participant.name"
+ size="20"
+ t:validate="required" />
+ </td>
+ <td>
+ <t:textfield t:id="participantEmail"
+ value="participant.email"
+ size="25" />
+ </td>
+ <td>
+ <t:textfield t:id="participantWeight"
+ value="participant.weight"
+ size="1" />
+ </td>
+ <td>
+ <t:removerowlink>
+ <img src="${asset:context:img/delete.png}"
+ alt="${message:delete}" />
+ </t:removerowlink>
+ </td>
+ <p:addRow>
+ <td colspan="4" class="center">
+ <t:addrowlink>
+ ${message:pollen.ui.participant.add}
+ </t:addrowlink>
+ </td>
+ </p:addRow>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </t:if>
+ </t:subForm>
+ </t:if>
+ <!--<t:delegate t:to="listsBlock" />-->
+ <!--<t:block t:id="listsForm">-->
+ <!--<form t:type="form" action="tapestry">-->
+ <!--<t:delegate t:to="listsFields" />-->
+ <!--</form>-->
+ <!--</t:block>-->
+ <!--<t:block t:id="listsFields">-->
+ <!--<t:if t:test="poll.pollType.group">-->
+ <!--<p>-->
+ <!--<label t:type="label" t:for="listName" />: -->
+ <!--<input t:type="textfield" t:id="listName" value="listName"/> -->
+ <!--<input t:type="submit" t:id="addList" value="ADD"/>-->
+ <!--</p>-->
+ <!--<p>-->
+ <!--<t:loop t:source="lists.values()" t:value="list" t:volatile="true">-->
+ <!--${list.name} -->
+ <!--</t:loop>-->
+ <!--</p>-->
+ <!--<p:else>-->
+ <!--COOL-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:block> -->
</div>
- </form>
+ </fieldset>
+</div>
+</form>
</t:zone>
</html>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-18 17:09:12 UTC (rev 3000)
+++ trunk/pom.xml 2010-05-19 12:59:57 UTC (rev 3001)
@@ -1,483 +1,491 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>mavenpom4redmine</artifactId>
- <version>2.1.3</version>
- </parent>
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom4redmine</artifactId>
+ <version>2.1.3</version>
+ </parent>
- <groupId>org.chorem</groupId>
- <artifactId>pollen</artifactId>
- <version>2.0-SNAPSHOT</version>
+ <groupId>org.chorem</groupId>
+ <artifactId>pollen</artifactId>
+ <version>2.0-SNAPSHOT</version>
- <modules>
- <module>pollen-ui</module>
- <module>pollen-business</module>
- <module>pollen-votecounting</module>
- </modules>
+ <modules>
+ <module>pollen-ui</module>
+ <module>pollen-business</module>
+ <module>pollen-votecounting</module>
+ </modules>
- <dependencyManagement>
- <dependencies>
+ <dependencyManagement>
+ <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-email</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.4</version>
- </dependency>
-<!-- <dependency>
- <groupId>org.chorem</groupId>
- <artifactId>chorem-commons</artifactId>
- <version>${chorem-commons.version}</version>
- </dependency>-->
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- <version>${nuiton-utils.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>eugene</artifactId>
- <version>${eugene.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>${topia.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-service-migration</artifactId>
- <version>${topia.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-core</artifactId>
- <version>${tapestry.version}</version>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>javassist</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.nuiton.web</groupId>
- <artifactId>nuiton-tapestry-extra</artifactId>
- <version>${nuiton-web.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.5.10</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.10</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-upload</artifactId>
- <version>${tapestry.version}</version>
- </dependency>
- <dependency>
- <groupId>org.chenillekit</groupId>
- <artifactId>chenillekit-tapestry</artifactId>
- <version>1.0.0</version>
- <exclusions>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>javassist</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>jfree</groupId>
- <artifactId>jfreechart</artifactId>
- <version>1.0.12</version>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.8.0.GA</version>
- </dependency>
- <dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- <version>0.9</version>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.2.131</version>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.4-701.jdbc4</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jvnet.hudson.winstone</groupId>
- <artifactId>winstone</artifactId>
- <version>0.9.10-hudson-16</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <!-- <dependency>
+ <groupId>org.chorem</groupId>
+ <artifactId>chorem-commons</artifactId>
+ <version>${chorem-commons.version}</version>
+ </dependency>-->
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ <version>${nuiton-utils.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene</artifactId>
+ <version>${eugene.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topia.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-service-migration</artifactId>
+ <version>${topia.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-core</artifactId>
+ <version>${tapestry.version}</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-tapestry-extra</artifactId>
+ <version>${nuiton-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.10</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.10</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-upload</artifactId>
+ <version>${tapestry.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.chenillekit</groupId>
+ <artifactId>chenillekit-tapestry</artifactId>
+ <version>1.0.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>jfree</groupId>
+ <artifactId>jfreechart</artifactId>
+ <version>1.0.12</version>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.8.0.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.2.131</version>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.4-701.jdbc4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <version>0.9.10-hudson-16</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
- <name>Pollen</name>
- <description>Application de vote Pollen</description>
- <inceptionYear>2009</inceptionYear>
- <url>http://maven-site.chorem.org/pollen/</url>
+ <name>Pollen</name>
+ <description>Application de vote Pollen</description>
+ <inceptionYear>2009</inceptionYear>
+ <url>http://maven-site.chorem.org/pollen/</url>
- <licenses>
- <license>
- <name>General Public License (GPL)</name>
- <url>${maven.license.file}</url>
- <distribution>local</distribution>
- </license>
- </licenses>
+ <licenses>
+ <license>
+ <name>General Public License (GPL)</name>
+ <url>${maven.license.file}</url>
+ <distribution>local</distribution>
+ </license>
+ </licenses>
- <!-- Developpers, contributors... -->
- <developers>
- <developer>
- <id>fdesbois</id>
- <name>Florian DESBOIS</name>
- <email>florian.desbois(a)gmail.com</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Chef de Projet</role>
- <role>Analyste</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>enema</id>
- <name>Erwan NEMA</name>
- <email>nemawan(a)hotmail.com</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Chef de Projet</role>
- <role>Analyste</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>kmorin</id>
- <name>Kevin MORIN</name>
- <email>km(a)kevinmorin.net</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Architecte</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>tpoulit</id>
- <name>Thierry POULIT-POUBLAT</name>
- <email>tpoulit(a)gmail.com</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Analyste</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>aboukhary</id>
- <name>Abdelmajid BOUKHARY</name>
- <email>benouna66(a)gmail.com</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Analyste</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>tcicognagni</id>
- <name>Thomas CICOGNANI</name>
- <email>zhykos(a)gmail.com</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Architecte</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>aeddahbi</id>
- <name>Amine EDDAHBI</name>
- <email>eddahbi(a)gmail.com</email>
- <organization>ALMA - Code Lutin</organization>
- <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Architecte</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>nrannou</id>
- <name>Nolwenn RANNOU</name>
- <email>rannou(a)codelutin.com</email>
- <organization>Code Lutin</organization>
- <organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
- <roles>
- <role>Concepteur</role>
- <role>Développeur</role>
- </roles>
- </developer>
- <developer>
- <id>tchemit</id>
- <name>Tony Chemit</name>
- <email>chemit(a)codelutin.com</email>
- <organization>CodeLutin</organization>
- <timezone>+2</timezone>
- <roles>
- <role>Développeur</role>
- </roles>
- </developer>
- </developers>
+ <!-- Developpers, contributors... -->
+ <developers>
+ <developer>
+ <id>fdesbois</id>
+ <name>Florian DESBOIS</name>
+ <email>florian.desbois(a)gmail.com</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Chef de Projet</role>
+ <role>Analyste</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>enema</id>
+ <name>Erwan NEMA</name>
+ <email>nemawan(a)hotmail.com</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Chef de Projet</role>
+ <role>Analyste</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>kmorin</id>
+ <name>Kevin MORIN</name>
+ <email>km(a)kevinmorin.net</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Architecte</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>tpoulit</id>
+ <name>Thierry POULIT-POUBLAT</name>
+ <email>tpoulit(a)gmail.com</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Analyste</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>aboukhary</id>
+ <name>Abdelmajid BOUKHARY</name>
+ <email>benouna66(a)gmail.com</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Analyste</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>tcicognagni</id>
+ <name>Thomas CICOGNANI</name>
+ <email>zhykos(a)gmail.com</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Architecte</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>aeddahbi</id>
+ <name>Amine EDDAHBI</name>
+ <email>eddahbi(a)gmail.com</email>
+ <organization>ALMA - Code Lutin</organization>
+ <organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Architecte</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>nrannou</id>
+ <name>Nolwenn RANNOU</name>
+ <email>rannou(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <organizationUrl>http://www.codelutin.com/</organizationUrl>
+ <timezone>+1</timezone>
+ <roles>
+ <role>Concepteur</role>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>tchemit</id>
+ <name>Tony Chemit</name>
+ <email>chemit(a)codelutin.com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </developer>
+ </developers>
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
- <packaging>pom</packaging>
+ <packaging>pom</packaging>
- <properties>
+ <properties>
- <!-- redmine configuration -->
- <platform>chorem.org</platform>
- <projectId>pollen</projectId>
+ <!-- redmine configuration -->
+ <platform>chorem.org</platform>
+ <projectId>pollen</projectId>
- <!-- customized versions -->
- <!--javadoc.version>2.4</javadoc.version-->
- <topia.version>2.4-SNAPSHOT</topia.version>
- <eugene.version>2.0.2-SNAPSHOT</eugene.version>
- <i18n.version>1.2.2</i18n.version>
- <tapestry.version>5.1.0.5</tapestry.version>
- <nuiton-web.version>0.1-SNAPSHOT</nuiton-web.version>
- <nuiton-utils.version>1.3.1-SNAPSHOT</nuiton-utils.version>
- <processor.version>1.0.2</processor.version>
+ <!-- customized versions -->
+ <!--javadoc.version>2.4</javadoc.version-->
+ <topia.version>2.4-SNAPSHOT</topia.version>
+ <eugene.version>2.0.2-SNAPSHOT</eugene.version>
+ <i18n.version>1.2.2</i18n.version>
+ <tapestry.version>5.1.0.5</tapestry.version>
+ <nuiton-web.version>0.1-SNAPSHOT</nuiton-web.version>
+ <nuiton-utils.version>1.3.1-SNAPSHOT</nuiton-utils.version>
+ <processor.version>1.0.2</processor.version>
- <!--Multilanguage maven-site -->
- <siteLocales>en,fr</siteLocales>
+ <!--Multilanguage maven-site -->
+ <siteLocales>en,fr</siteLocales>
- <!-- license to use -->
- <license.licenseName>gpl_v3</license.licenseName>
+ <!-- license to use -->
+ <license.licenseName>gpl_v3</license.licenseName>
- </properties>
+ </properties>
- <build>
+ <build>
- <pluginManagement>
- <plugins>
+ <pluginManagement>
+ <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.nuiton.jrst</groupId>
- <artifactId>doxia-module-jrst</artifactId>
- <version>${jrst.version}</version>
- </dependency>
- </dependencies>
- </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>doxia-module-jrst</artifactId>
+ <version>${jrst.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>7.0.1.v20091125</version>
- </plugin>
- <!-- EUGene plugin for entities generation -->
- <plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <version>${eugene.version}</version>
- <configuration>
- <inputs>zargo</inputs>
- <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>${topia.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>${i18n.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>7.0.1.v20091125</version>
+ </plugin>
+ <!-- EUGene plugin for entities generation -->
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <version>${eugene.version}</version>
+ <configuration>
+ <inputs>zargo</inputs>
+ <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topia.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${i18n.version}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </build>
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
- <scm>
- <connection>scm:svn:http://svn.chorem.org/svn/pollen/trunk</connection>
- <developerConnection>scm:svn:http://svn.chorem.org/svn/pollen/trunk</developerConnection>
- <url>http://www.chorem.org/repositories/browse/pollen/trunk</url>
- </scm>
+ <scm>
+ <connection>scm:svn:http://svn.chorem.org/svn/pollen/trunk</connection>
+ <developerConnection>scm:svn:http://svn.chorem.org/svn/pollen/trunk
+ </developerConnection>
+ <url>http://www.chorem.org/repositories/browse/pollen/trunk</url>
+ </scm>
- <repositories>
+ <repositories>
- <!-- chenillekit Repository -->
- <!--repository>
- <id>chenillekit</id>
- <url>http://www.chenillekit.org/mvnrepo/release</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository-->
+ <!-- chenillekit Repository -->
+ <!--repository>
+ <id>chenillekit</id>
+ <url>http://www.chenillekit.org/mvnrepo/release</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository-->
- <!-- Maven Java.net Repository -->
- <!--repository>
- <id>maven2-repository.dev.java.net</id>
- <name>Java.net Repository for Maven</name>
- <url>http://download.java.net/maven/2/</url>
- <layout>default</layout>
- </repository-->
+ <!-- Maven Java.net Repository -->
+ <!--repository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Repository for Maven</name>
+ <url>http://download.java.net/maven/2/</url>
+ <layout>default</layout>
+ </repository-->
- <!-- depot des releases nuiton -->
+ <!-- depot des releases nuiton -->
- <repository>
- <id>nuiton.release</id>
- <name>NuitonReleaseRepository</name>
- <url>http://maven.nuiton.org/release</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </repository>
+ <repository>
+ <id>nuiton.release</id>
+ <name>NuitonReleaseRepository</name>
+ <url>http://maven.nuiton.org/release</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
- <!-- depot des snapshots nuiton -->
+ <!-- depot des snapshots nuiton -->
- <repository>
- <id>nuiton.snapshot</id>
- <name>NuitonSnapshotRepository</name>
- <url>http://maven.nuiton.org/snapshot</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
+ <repository>
+ <id>nuiton.snapshot</id>
+ <name>NuitonSnapshotRepository</name>
+ <url>http://maven.nuiton.org/snapshot</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
- </repositories>
+ </repositories>
- <pluginRepositories>
+ <pluginRepositories>
- <!-- depot des releases nuiton -->
+ <!-- depot des releases nuiton -->
- <pluginRepository>
+ <pluginRepository>
- <id>nuiton.release</id>
- <name>NuitonReleaseRepository</name>
- <url>http://maven.nuiton.org/release</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </pluginRepository>
+ <id>nuiton.release</id>
+ <name>NuitonReleaseRepository</name>
+ <url>http://maven.nuiton.org/release</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </pluginRepository>
- <!-- depot des snapshots nuiton -->
+ <!-- depot des snapshots nuiton -->
- <pluginRepository>
- <id>nuiton.snapshot</id>
- <name>NuitonSnapshotRepository</name>
- <url>http://maven.nuiton.org/snapshot</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </pluginRepository>
+ <pluginRepository>
+ <id>nuiton.snapshot</id>
+ <name>NuitonSnapshotRepository</name>
+ <url>http://maven.nuiton.org/snapshot</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
- </pluginRepositories>
+ </pluginRepositories>
</project>
1
0
18 May '10
Author: fdesbois
Date: 2010-05-18 19:09:12 +0200 (Tue, 18 May 2010)
New Revision: 3000
Url: http://chorem.org/repositories/revision/pollen/3000
Log:
continue form managment with list...
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericEncoder.java
Removed:
trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml.orig
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.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/services/PollenManager.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/webapp/css/poll.css
trunk/pollen-ui/src/main/webapp/js/pollForm.js
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -23,7 +23,16 @@
}
@Override
- public void addParticipant(Participant participant) throws PollenBusinessException {
+ public void setParticipants(Collection<Participant> participants)
+ throws PollenBusinessException {
+ setFavoriteParticipant(new ArrayList<FavoriteParticipant>());
+ for (Participant participant : participants) {
+ addParticipant(participant);
+ }
+ }
+
+ protected void addParticipant(Participant participant)
+ throws PollenBusinessException {
String name = participant.getName();
String email = participant.getEmail();
@@ -36,8 +45,4 @@
favorite.setFavoriteList(this);
addFavoriteParticipant(favorite);
}
-
- @Override
- public void removeParticipant(Participant participant) {
- }
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -14,7 +14,7 @@
/**
* Check the existence of participant from a {@code list}. The existence is
- * tested on {@code name} and {@code email}. The {@code email} an be null.
+ * tested on {@code name} and {@code email}. The {@code email} can be null.
*
* @param list ParticipantList which contains a list of Participant
* @param name Name of the participant to check
@@ -30,7 +30,7 @@
boolean emailCheck = emailNull ||
(email != null && email.equals(participant.getEmail()));
- if (name.equals(participant.getName()) && emailCheck) {
+ if (name != null && name.equals(participant.getName()) && emailCheck) {
if (emailNull) {
throw new PollenBusinessException(
PollenBusinessException.PollenExceptionType.PARTICIPANT_EXIST_WITHOUT_EMAIL,
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -30,11 +30,20 @@
}
@Override
- public void addParticipant(Participant participant) throws PollenBusinessException {
- if (!list) {
+ public void setParticipants(Collection<Participant> participants)
+ throws PollenBusinessException {
+ if (!list) {
throw new UnsupportedOperationException(
- "Unable to add a participant from a child account");
+ "Unable to set participants from a child account");
}
+ setChild(new ArrayList<PollAccount>());
+ for (Participant participant : participants) {
+ addParticipant(participant);
+ }
+ }
+
+ protected void addParticipant(Participant participant)
+ throws PollenBusinessException {
String name = participant.getName();
String email = participant.getEmail();
@@ -46,8 +55,4 @@
account.setWeight(participant.getWeight());
addChild(account);
}
-
- @Override
- public void removeParticipant(Participant participant) {
- }
}
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -69,14 +69,16 @@
list1.setName("List1");
list1.setList(true);
+ Collection<Participant> participants = new ArrayList<Participant>();
Participant participant1_1 = new PollAccountImpl();
participant1_1.setName("participant1_1");
participant1_1.setEmail("email1_1(a)domain.org");
- list1.addParticipant(participant1_1);
+ participants.add(participant1_1);
Participant participant1_2 = new PollAccountImpl();
participant1_2.setName("participant1_2");
- list1.addParticipant(participant1_2);
+ participants.add(participant1_2);
+ list1.setParticipants(participants);
// Second list : existing list from user favorites
list2 = createFavoriteList("list2", user);
@@ -283,17 +285,19 @@
ParticipantList list = servicePoll.getNewPollList();
lists.add(list);
+ Collection<Participant> participants = new ArrayList<Participant>();
Participant participant1 = servicePoll.getNewPollParticipant();
participant1.setName("participant1");
participant1.setEmail("email1");
participant1.setWeight(1.);
- list.addParticipant(participant1);
+ participants.add(participant1);
Participant participant2 = servicePoll.getNewPollParticipant();
participant2.setName("participant2");
participant2.setEmail(null);
participant2.setWeight(1.);
- list.addParticipant(participant2);
+ participants.add(participant2);
+ list.setParticipants(participants);
/** EXEC METHOD **/
servicePoll.createPoll(poll, lists);
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericEncoder.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericEncoder.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericEncoder.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -0,0 +1,37 @@
+package org.chorem.pollen.ui.data;
+
+import org.apache.tapestry5.ValueEncoder;
+import org.chorem.pollen.entity.Participant;
+
+import java.util.Collection;
+
+/**
+ * Created: 17 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class GenericEncoder<T> implements ValueEncoder<T> {
+
+ protected Iterable<T> dataSource;
+
+ public GenericEncoder(Iterable<T> dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ @Override
+ public String toClient(T object) {
+ return object == null ? null : object.toString();
+ }
+
+ @Override
+ public T toValue(String s) {
+ for (T curr : dataSource) {
+ if (curr.toString().equals(s)) {
+ return curr;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/GenericEncoder.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-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -3,7 +3,9 @@
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Field;
import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.IncludeStylesheet;
@@ -11,6 +13,7 @@
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.AjaxFormLoop;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
@@ -29,12 +32,22 @@
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.GenericEncoder;
+import org.chorem.pollen.ui.data.ParticipantsListener;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.nuiton.web.tapestry5.components.FeedBack;
import org.slf4j.Logger;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -73,6 +86,9 @@
@InjectComponent
private Zone mainZone;
+ @Inject
+ private Logger logger;
+
@Override
public Border getBorder() {
return border;
@@ -87,6 +103,9 @@
@Inject
private ServicePoll servicePoll;
+ @Inject
+ private PollenManager manager;
+
private String pollUID;
@Persist
@@ -113,7 +132,7 @@
* @return poll existing or a new one
* @throws PollenBusinessException
*/
- public Poll getPoll() throws PollenBusinessException {
+ public Poll getPoll() {
if (poll == null) {
if (StringUtils.isNotEmpty(pollUID)) {
if (log.isDebugEnabled()) {
@@ -137,8 +156,8 @@
* @return true if it's the create mode, false otherwise
* @throws PollenBusinessException
*/
- public boolean isCreateMode() throws PollenBusinessException {
- return StringUtils.isEmpty(getPoll().getTopiaId());
+ public boolean isCreateMode() {
+ return StringUtils.isEmpty(getPoll().getId());
}
/**
@@ -147,7 +166,7 @@
* @return the page title depends on create or update mode.
* @throws PollenBusinessException
*/
- public String getPageTitle() throws PollenBusinessException {
+ public String getPageTitle() {
String title = "";
if (isCreateMode()) {
title = messages.get("pageTitle-create");
@@ -163,7 +182,7 @@
* @return the address bar.
* @throws PollenBusinessException
*/
- public AddressBar getAddressBar() throws PollenBusinessException {
+ public AddressBar getAddressBar() {
return AddressBar.newBar().appendCurrent(getPageTitle());
}
@@ -325,7 +344,7 @@
hasReminder = false;
}
- public boolean isChoiceNbDisabled() throws PollenBusinessException {
+ public boolean isChoiceNbDisabled() {
// voteCounting not set to NORMAL
return !getPoll().getVoteCountingType().isNormal();
}
@@ -386,22 +405,30 @@
* @return true if the poll has a FREE pollType
* @throws PollenBusinessException
*/
- public boolean isReminderDisabled() throws PollenBusinessException {
+ public boolean isReminderDisabled() {
// pollType is FREE
return getPoll().getPollType().isFree();
}
- /** *********************** LISTS **************************************** */
+ /** *********************** LISTS *****************************************/
@Persist
- private Map<String, ParticipantList> lists; // for GROUP
+ private Map<String, ParticipantList> lists;
@Property
private ParticipantList list;
+// @Persist
+// private String listSelectedName;
+
@Persist
- private Map<String, Participant> participants; // for RESTRICTED
+ private ParticipantList listSelected;
+ private Map<String, Participant> selectedParticipants;
+
+ @Property
+ private Participant participant;
+
@InjectComponent
private Zone listsZone;
@@ -412,70 +439,286 @@
private ComponentResources resources;
@Property
- private boolean flag;
+ private boolean formActivate;
-// @Inject
-// private Block listsForm;
-//
-// @Inject
-// @Property
-// private Block listsFields;
+ @InjectComponent
+ private FeedBack listsFeedback;
+ private ParticipantsListener listSelectedListener;
+
public Map<String, ParticipantList> getLists() {
if (lists == null) {
- lists = new HashMap<String, ParticipantList>();
+ lists = new LinkedHashMap<String, ParticipantList>();
+ if (getPoll().getPollType().isRestricted()) {
+ lists.put("LIST", servicePoll.getNewPollList());
+ }
}
return lists;
}
- public Map<String, Participant> getParticipants() {
- if (participants == null) {
- participants = new HashMap<String, Participant>();
+ @Log
+ Object onChangeFromPollType(String value) {
+ PollType type = PollType.valueOf(value);
+ getPoll().setPollType(type);
+ if (type.isRestrictedOrGroup()) {
+ listsFeedback.addInfo("Edition en cours d'une liste restreinte. " +
+ "Attention un changement de type de restriction provoquera" +
+ " une remise à zéro de la/les liste(s) en cours d'édition.");
}
- return participants;
+ // Clean persist data for lists : careful, will reset unsaved data
+ lists = null;
+ listSelected = null;
+ return refreshListZone();
}
@Log
- public boolean canDisplayLists() throws PollenBusinessException {
+ public boolean canDisplayLists() {
return getPoll().getPollType().isRestrictedOrGroup();
}
+ public ParticipantList getListSelected() {
+ if (listSelected == null && getPoll().getPollType().isRestricted()) {
+ listSelected = getLists().get("LIST");
+// if (listSelected == null) {
+// listSelected = servicePoll.getNewPollList();
+// getLists().put("LIST", listSelected);
+// if (log.isDebugEnabled()) {
+// log.debug("Instantiate list for restricted poll");
+// }
+// }
+ }
+// else if (StringUtils.isNotEmpty(listSelectedName)) {
+// listSelected = getLists().get(listSelectedName);
+// }
+ if (log.isDebugEnabled() && listSelected != null) {
+ log.debug("List selected : " + listSelected.getName());
+ }
+ return listSelected;
+ }
+
+ public String getStyleSelected() {
+ return isCurrentListSelected() ? " selected" : "";
+ }
+
+ public boolean isCurrentListSelected() {
+ return listSelected != null &&
+ list.getName().equals(listSelected.getName());
+ }
+
@Log
- Object onChangeFromPollType(String value) throws PollenBusinessException {
- getPoll().setPollType(PollType.valueOf(value));
- flag = false;
- return listsZone.getBody();
+ void onSelectedFromAddList() {
+ formActivate = true;
+ if (StringUtils.isNotEmpty(listName) &&
+ !getLists().containsKey(listName)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Add list : " + listName);
+ }
+ ParticipantList list = servicePoll.getNewPollList();
+ list.setName(listName);
+ getLists().put(listName, list);
+ listSelected = list;
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Refuse adding list : " + listName);
+ }
+// listSelected = null;
+// listsFeedback.addError("Impossible d'ajouter une liste avec un nom vide");
+ }
+ // Reset form field before refresh form
+ listName = null;
+ if (log.isDebugEnabled() && listSelected != null) {
+ log.debug("Selected list : " + listSelected.getName());
+ }
}
+ @Log
+ void onSelectedFromEditList(String listName) {
+ formActivate = true;
+ listSelected = getLists().get(listName);
+ if (log.isDebugEnabled() && listSelected != null) {
+ log.debug("List selected : " + listSelected.getName());
+ }
+ }
+
+ public Map<String, Participant> getSelectedParticipants() {
+ if (selectedParticipants == null) {
+ if (log.isDebugEnabled() && listSelected != null) {
+ log.debug("Retrieve participants from list");
+ }
+ selectedParticipants = new LinkedHashMap<String, Participant>();
+ for (Participant participant : listSelected.getParticipants()) {
+ String id = manager.createPollenUrlId();
+ selectedParticipants.put(id, participant);
+ }
+ }
+ return selectedParticipants;
+ }
+
+ @Log
+ Object onActionFromRemoveList() {
+ if (log.isDebugEnabled()) {
+ log.debug("Remove list : " + listSelected.getName());
+ }
+ getLists().remove(listSelected.getName());
+ if (log.isDebugEnabled()) {
+ for (ParticipantList list : getLists().values()) {
+ log.debug("Existing lists : " + list.getName());
+ }
+ }
+ listSelected = null;
+ return refreshListZone();
+ }
+
+ @Log
+ void onSelectedFromSaveList(String listName) {
+ try {
+ listSelected.setParticipants(selectedParticipants.values());
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(eee, messages, logger);
+ listsFeedback.addError(message);
+ }
+ }
+
// @Log
-// public Block getListsBlock() throws PollenBusinessException {
-// if (canDisplayLists()) {
-// if (flag) {
-// return listsFields;
+// void onSelectedFromRemoveList(String listName) {
+// if (formActivate) {
+// if (log.isWarnEnabled()) {
+// log.warn("Strange submit behavior... Escape remove.");
// }
-// return listsForm;
+// return;
// }
-// return null;
+// formActivate = true;
+// if (log.isDebugEnabled()) {
+// log.debug("Remove list : " + listName);
+// }
+// getLists().remove(listName);
+// if (log.isDebugEnabled()) {
+// for (ParticipantList list : getLists().values()) {
+// log.debug("Existing lists : " + list.getName());
+// }
+// }
+// if (listSelected != null && listSelected.getName().equals(listName)) {
+// listSelected = null;
+// }
// }
- @Log
- void onSelectedFromAddList() {
- flag = true;
- addList(listName);
+ public ValueEncoder<ParticipantList> getListEncoder() {
+ final Collection<ParticipantList> lists = getLists().values();
+ ValueEncoder<ParticipantList> encoder =
+ new ValueEncoder<ParticipantList>() {
+
+ @Override
+ public String toClient(ParticipantList participant) {
+ return participant.getName();
+ }
+
+ @Override
+ public ParticipantList toValue(String s) {
+ for (ParticipantList curr : lists) {
+ if (s.equals(curr.getName())) {
+ return curr;
+ }
+ }
+ return null;
+ }
+ };
+ return encoder;
}
- protected void addList(String name) {
- if (!getLists().containsKey(name)) {
- ParticipantList list = new PollAccountImpl();
- list.setName(name);
- getLists().put(name, list);
- }
+ Object onAddRowFromParticipants() {
+ Participant newParticipant = servicePoll.getNewPollParticipant();
+ //selectedParticipants.add(newParticipant);
+// try {
+// listSelected.addParticipant(newParticipant);
+// } catch (PollenBusinessException eee) {
+// String message = manager.getErrorMessage(eee, messages, logger);
+// listsFeedback.addError(message);
+// }
+ return newParticipant;
}
+ void onRemoveRowFromParticipants(Participant participant) {
+// if (log.isDebugEnabled()) {
+// for (Participant p : listSelected.getParticipants()) {
+// log.debug("Before Existing participants : " +
+// p.getName() + "_" + p.getEmail());
+// }
+// }
+//// boolean isRemoved =
+//// listSelected.getParticipants().remove(participant);
+//// listSelected.removeParticipant(participant);
+// if (log.isDebugEnabled()) {
+// log.debug("Participant removed : " + participant.getName());
+// }
+// if (log.isDebugEnabled()) {
+// for (Participant p : listSelected.getParticipants()) {
+// log.debug("Existing participants : " +
+// p.getName() + "_" + p.getEmail());
+// }
+// }
+ }
+
+ public ValueEncoder<Participant> getParticipantEncoder() {
+ ValueEncoder<Participant> encoder = new ValueEncoder<Participant>() {
+
+ @Override
+ public String toClient(Participant participant) {
+// String key = getParticipantKey(participant);
+ if (log.isDebugEnabled()) {
+ log.debug("Participant to find : " + participant);
+ }
+ for (Map.Entry<String, Participant> entry :
+ getSelectedParticipants().entrySet()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Selected participant entry : " +
+ "key = " + entry.getKey() + " -> " +
+ "value = " + entry.getValue());
+ }
+ if (entry.getValue() == participant) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("toClient : key = " + entry.getKey());
+ }
+ return entry.getKey();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Participant toValue(String s) {
+// for (Participant curr : getSelectedParticipants()) {
+// String key = getParticipantKey(curr);
+// if (s.equals(key)) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("toValue from : " + s);
+// }
+// return curr;
+// }
+// }
+ Participant participant = getSelectedParticipants().get(s);
+ if (logger.isDebugEnabled()) {
+ logger.debug("toValue : key = " + s + " -> " + participant);
+ }
+ return participant;
+ }
+ };
+ return encoder;
+ }
+
+ protected Object refreshListZone() {
+ formActivate = false;
+ return listsZone.getBody();
+ }
+
@Log
- Object onSuccess() throws PollenBusinessException {
+ Object onSuccess() {
return mainZone;
}
+ // TODO-FD2010-05-18 : Put this in ParticipantHelper in business
+ public String getParticipantKey(Participant participant) {
+ return participant.getName() + "_" + participant.getEmail();
+ }
+
}
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-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-05-18 17:09:12 UTC (rev 3000)
@@ -122,6 +122,10 @@
return context.getCurrentDate();
}
+ public String createPollenUrlId() {
+ return context.createPollenUrlId();
+ }
+
public String getErrorMessage(PollenBusinessException eee,
Messages messages, Logger logger) {
if (logger.isDebugEnabled()) {
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-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-18 17:09:12 UTC (rev 3000)
@@ -3,53 +3,58 @@
pollen.page.UserLists.title=Vos listes de votants
############################ 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.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
############################ GLOBAL ############################################
pollen.ui.tooltip.help=Aide
pollen.ui.button.add=Ajouter
-pollen.ui.button.create=Cr\u00E9er
+pollen.ui.button.create=Cr\u00e9er
pollen.ui.button.ok=Ok
############################ USER ##############################################
-pollen.ui.user.register.autoConnection=Vous \u00EAtes maintenant connect\u00E9 avec l'identifiant %1$s.
-pollen.ui.user.register.sendEmail=Un email vous a \u00E9t\u00E9 envoy\u00E9 \u00E0 l'adresse %1$s.
+pollen.ui.user.register.autoConnection=Vous \u00eates maintenant connect\u00e9 avec l'identifiant %1$s.
+pollen.ui.user.register.sendEmail=Un email vous a \u00e9t\u00e9 envoy\u00e9 \u00e0 l'adresse %1$s.
pollen.ui.user.validate.passwords=Les deux mots de passe ne correspondent pas.
-pollen.ui.user.update.success=Modification enregistr\u00E9e avec succ\u00E8s.
-pollen.ui.user.display.notConnected=Vous devez vous connecter pour acc\u00E9der \u00E0 la page %1$s.
-pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00E9cessaires pour acc\u00E9der \u00E0 la page %1$s.
-pollen.ui.user.create.title=Cr\u00E9er un nouvel utilisateur
-pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9.
-pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le m\u00EAme que son identifiant.
-pollen.ui.user.create.passwordHelp=Si vous pr\u00E9cisez un email, un mot de passe sera g\u00E9n\u00E9r\u00E9 et envoy\u00E9 \u00E0 l'utilisateur. Sinon le mot de passe sera identique au login.
-pollen.ui.user.create.sendEmail=Un email a \u00E9t\u00E9 envoy\u00E9 au nouvel utilisateur %1$s \u00E0 l'adresse %2$s.
-pollen.ui.user.create.emailFailedShowPassword=Le mot de passe g\u00E9n\u00E9r\u00E9 est le suivant : %1$s
-pollen.ui.user.create.success=L'utilisateur %1$s a \u00E9t\u00E9 cr\u00E9\u00E9 avec succ\u00E8s.
+pollen.ui.user.update.success=Modification enregistr\u00e9e avec succ\u00e8s.
+pollen.ui.user.display.notConnected=Vous devez vous connecter pour acc\u00e9der \u00e0 la page %1$s.
+pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00e9cessaires pour acc\u00e9der \u00e0 la page %1$s.
+pollen.ui.user.create.title=Cr\u00e9er un nouvel utilisateur
+pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9.
+pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le m\u00eame que son identifiant.
+pollen.ui.user.create.passwordHelp=Si vous pr\u00e9cisez un email, un mot de passe sera g\u00e9n\u00e9r\u00e9 et envoy\u00e9 \u00e0 l'utilisateur. Sinon le mot de passe sera identique au login.
+pollen.ui.user.create.sendEmail=Un email a \u00e9t\u00e9 envoy\u00e9 au nouvel utilisateur %1$s \u00e0 l'adresse %2$s.
+pollen.ui.user.create.emailFailedShowPassword=Le mot de passe g\u00e9n\u00e9r\u00e9 est le suivant : %1$s
+pollen.ui.user.create.success=L'utilisateur %1$s a \u00e9t\u00e9 cr\u00e9\u00e9 avec succ\u00e8s.
pollen.ui.user.nbUsers=%1$d utilisateurs existants
pollen.ui.user.update.edit=Modifier cet utilisateur
pollen.ui.user.update.save=Enregistrer les modifications
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 ?
-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.
+pollen.ui.user.delete.confirmMessage=Etes-vous s\u00fbr de vouloir d\u00e9finitivement supprimer cet utilisateur ?
+############################ USER ##############################################
+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.
pollen.ui.list.delete=Supprimer la liste %1$s
-pollen.ui.list.delete.confirmMessage=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer cette liste et l'int\u00E9gralit\u00E9 de ses votants ?
-pollen.ui.list.delete.success=La liste et son contenu ont \u00E9t\u00E9 supprim\u00E9 avec succ\u00E8s.
-pollen.ui.list.notSelected=Aucune liste s\u00E9lectionn\u00E9e
+pollen.ui.list.delete.confirmMessage=Etes-vous s\u00fbr de vouloir d\u00e9finitivement supprimer cette liste et l'int\u00e9gralit\u00e9 de ses votants ?
+pollen.ui.list.delete.success=La liste et son contenu ont \u00e9t\u00e9 supprim\u00e9 avec succ\u00e8s.
+pollen.ui.list.notSelected=Aucune liste s\u00e9lectionn\u00e9e
pollen.ui.list.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
pollen.ui.list.nbParticipants=%1$d votants contenus dans cette liste
-pollen.ui.list.update.addParticipant=Ajouter un nouveau votant \u00E0 la liste
-pollen.ui.list.update.addParticipant.success=Le votant %1$s a \u00E9t\u00E9 ajout\u00E9 \u00E0 la liste.
+pollen.ui.list.update.addParticipant=Ajouter un nouveau votant \u00e0 la liste
+pollen.ui.list.update.addParticipant.success=Le votant %1$s a \u00e9t\u00e9 ajout\u00e9 \u00e0 la liste.
pollen.ui.list.update.cancelEdition=Annuler les changements
pollen.ui.list.update.saveParticipant=Enregistrer les modifications
-pollen.ui.list.update.saveParticipant.success=Modification enregistr\u00E9e avec succ\u00E8s.
+pollen.ui.list.update.saveParticipant.success=Modification enregistr\u00e9e avec succ\u00e8s.
pollen.ui.list.update.updateParticipant=Modifier ce votant
pollen.ui.list.update.removeParticipant=Supprimer ce votant
-pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous s\u00FBr de vouloir supprimer %1$s de la liste ?
-pollen.ui.list.update.removeParticipant.success=Le votant a \u00E9t\u00E9 supprim\u00E9 avec succ\u00E8s.
+pollen.ui.list.update.removeParticipant.confirmMessage=Etes-vous s\u00fbr de vouloir supprimer %1$s de la liste ?
+pollen.ui.list.update.removeParticipant.success=Le votant a \u00e9t\u00e9 supprim\u00e9 avec succ\u00e8s.
+pollen.ui.participant.name-label=Nom
+pollen.ui.participant.email-label=Email
+pollen.ui.participant.weight-label=Poids
+pollen.ui.participant.add=Nouveau participant
# OLD LOGIN_COMPONENT
connectionLegend=Connexion
@@ -61,7 +66,7 @@
loginFailed=Mauvais identifiant ou mot de passe.
# FORM:: user
-firstName-label=Pr\u00E9nom
+firstName-label=Pr\u00e9nom
lastName-label=Nom
login-label=Identifiant
email-label=Email
@@ -77,14 +82,14 @@
editEmail-regexp-message=Adresse email invalide.
############################ CHOICE ############################################
-pollen.ui.choice.delete.confirm=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer ce choix ?
+pollen.ui.choice.delete.confirm=Etes-vous s\u00fbr de vouloir d\u00e9finitivement supprimer ce choix ?
pollen.ui.choice.delete.title=Supprimer ce choix
-pollen.ui.vote.noVote=Aucune personne n'a encore particip\u00E9 au sondage
+pollen.ui.vote.noVote=Aucune personne n'a encore particip\u00e9 au sondage
pollen.ui.vote.noPager=%1$d votes existants
pollen.ui.choice.datePattern=dd/MM/yyyy HH:mm
pollen.ui.choice.add.title=Ajout d'un choix
pollen.ui.choice.add.submit=Ajouter
-pollen.ui.error.upload=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autoris\u00E9e est de %1$s par fichier et %2$s au total.
+pollen.ui.error.upload=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autoris\u00e9e est de %1$s par fichier et %2$s au total.
# Tapestry messages for VoteForPoll.tml
# FORM:: addChoice
@@ -93,42 +98,42 @@
addChoice-choiceText-required-message=Vous devez saisir un choix.
choiceDate-label=Date et heure
addChoice-choiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
-addChoice-choiceDate-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59.
+addChoice-choiceDate-regexp-message=La date de d\u00e9but doit-\u00eatre au format 31/12/2000 23:59.
addChoice-choiceDate-required-message=Vous devez saisir un choix.
choiceImage-label=Image
addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
-addChoice-choiceImage-regexp-message=L'image doit-\u00EAtre au format JPG, GIF ou PNG.
+addChoice-choiceImage-regexp-message=L'image doit-\u00eatre au format JPG, GIF ou PNG.
addChoice-choiceImage-required-message=Vous devez saisir un choix.
# Poll creation emails
-#creatorEmail_subject=[Pollen] Cr\u00E9ation d'un sondage (%s)
-#creatorEmail_msg=Vous venez de cr\u00E9er le sondage "%s".\nVous pouvez y acc\u00E9der en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
+#creatorEmail_subject=[Pollen] Cr\u00e9ation d'un sondage (%s)
+#creatorEmail_msg=Vous venez de cr\u00e9er le sondage "%s".\nVous pouvez y acc\u00e9der en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
#votingEmail_subject=[Pollen] Invitation au vote (%s)
-#votingEmail_msg=Un nouveau sondage a \u00E9t\u00E9 cr\u00E9\u00E9 : "%s".\nVous pouvez y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s
+#votingEmail_msg=Un nouveau sondage a \u00e9t\u00e9 cr\u00e9\u00e9 : "%s".\nVous pouvez y participer avec l'identifiant %s \u00e0 l'adresse suivante : \n%s
# Notification emails
#voteEmail_subject=[Pollen] Notification de vote (%s)
-#voteEmail_msg=Un vote vient d'\u00EAtre enregistr\u00E9 pour le sondage "%s". Ce sondage compte d\u00E9sormais %d votes.\nVous pouvez acc\u00E9der \u00E0 ce sondage en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
+#voteEmail_msg=Un vote vient d'\u00eatre enregistr\u00e9 pour le sondage "%s". Ce sondage compte d\u00e9sormais %d votes.\nVous pouvez acc\u00e9der \u00e0 ce sondage en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
# Reminder emails
#reminderEmail_subject=[Pollen] Rappel (%s)
-#reminderEmail_msg=Vous n'avez pas encore vot\u00E9 pour le sondage "%s".\nVous pouvez encore y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s
+#reminderEmail_msg=Vous n'avez pas encore vot\u00e9 pour le sondage "%s".\nVous pouvez encore y participer avec l'identifiant %s \u00e0 l'adresse suivante : \n%s
# Poll feed
#pollFeed_title=Pollen : %s
#pollFeed_desc=%s
-#pollFeed_createTitle=Sondage cr\u00E9\u00E9 par %s
+#pollFeed_createTitle=Sondage cr\u00e9\u00e9 par %s
#pollFeed_createContent=
#pollFeed_voteTitle=Nouveau vote de %s
-#pollFeed_voteContent=\u00C9tat du sondage : %s
+#pollFeed_voteContent=\u00c9tat du sondage : %s
#pollFeed_choiceTitle=Nouveau choix : %s
#pollFeed_choiceContent=%s
#pollFeed_commentTitle=Nouveau commentaire de %s
#pollFeed_commentContent=%s
# Actions
-#create=Cr\u00E9er
+#create=Cr\u00e9er
#edit=Modifier
#delete=Supprimer
#add=Ajouter
Modified: trunk/pollen-ui/src/main/webapp/css/poll.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/poll.css 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/webapp/css/poll.css 2010-05-18 17:09:12 UTC (rev 3000)
@@ -70,3 +70,108 @@
float: left;
}
+/* FOR LISTS */
+TABLE.t-data-grid {
+ width: 500px;
+ margin: auto;
+}
+
+TABLE.t-data-grid THEAD TR {
+ background-color: #98dae4;
+ color: #727A7E;
+}
+
+INPUT.list-edition {
+ border: 0;
+ background-color: transparent;
+ cursor: pointer;
+}
+
+INPUT.selected {
+ color: #32B5C9;
+ font-weight: bold;
+ font-size: 1.2em;
+}
+
+/*DIV.t-data-grid {
+ font-family: Arial, Helvetica, sans-serif;
+ margin-top:20px;
+ margin-bottom:20px;
+}
+
+DIV.t-data-grid-pager {
+ margin: 8px 0px;
+}
+
+DIV.t-data-grid-pager A, DIV.t-data-grid-pager SPAN.current {
+ text-decoration: none;
+ padding: 2px 5px;
+ font-size: 14px;
+ margin-right: 5px;
+}
+
+DIV.t-data-grid-pager A {
+ background-color: #fc0;
+ border: 1px solid #aab;
+ color: #fff;
+}
+
+DIV.t-data-grid-pager A:hover {
+ border: 1px solid #000;
+ color: #000;
+}
+
+DIV.t-data-grid-pager SPAN.current {
+ color: #fff;
+ border: 1px solid #fc0;
+ background-color: #000;
+}
+
+TABLE.t-data-grid {
+ border-collapse: collapse;
+ border-left: 1px solid #aab;
+ border-top: 1px solid #aab;
+ background-color: #fff;
+ font-size: 14px;
+ margin: auto;
+ text-align: center;
+}
+
+TABLE.t-data-grid THEAD {
+ border-top: 1px solid #aab; / For Firefox /
+}
+
+TABLE.t-data-grid THEAD TR {
+ color: #fff;
+ background-color: #fc0;
+}
+
+TABLE.t-data-grid THEAD TR a {
+ color: #fff;
+ background-color: #fc0;
+}
+
+TABLE.t-data-grid THEAD TR TH {
+ text-align: left;
+ padding: 2px 3px;
+ white-space: nowrap;
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ background-color:#fc0;
+}
+
+TABLE.t-data-grid TBODY TR {
+ background-color: #fff;
+}
+
+TABLE.t-data-grid TBODY TR.odd {
+ background-color: #ffb;
+}
+
+TABLE.t-data-grid TBODY TR TD {
+ border-right: 1px solid #aab;
+ border-bottom: 1px solid #aab;
+ padding: 2px 5px;
+}
+*/
+
Modified: trunk/pollen-ui/src/main/webapp/js/pollForm.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-05-18 17:09:12 UTC (rev 3000)
@@ -37,6 +37,8 @@
this.contextPath = contextPath;
+// this.form.observe('submit', this.disableEnterSubmit.bindAsEventListener(this));
+
// this.contextBlockVisible = ['true', 'false'];
// this.contextBlockId = ['mainInfos', 'options'];
//
@@ -99,6 +101,13 @@
// }
// },
+// disableEnterSubmit: function(event) {
+// if (event.keyCode != Event.KEY_RETURN) {
+// Tapestry.debug('disable enter');
+// event.stop();
+// }
+// },
+
/*
* Action when voteCounting select change. This change affects choiceNb
* checkbox : choiceNb is only available if voteCounting is 'NORMAL'.
Deleted: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml.orig
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml.orig 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml.orig 2010-05-18 17:09:12 UTC (rev 3000)
@@ -1,301 +0,0 @@
-
-<t:border t:address="address" t:pageLogo="literal:Creation"
- xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-
- <t:feedback t:id="feedback"/>
- <h1 class="titleCreation">${message:title-new}</h1>
- <t:zone t:id="pollCreationZone" show="show" update="show">
- <t:form t:id="pollCreationForm" t:zone="pollCreationZone">
-
- <!-- Étape POLL -->
- <t:formfragment visible="inPoll">
- <div id="pollCreationFormDiv">
- <t:errors/>
- <fieldset>
- <legend>${stepLegend}</legend>
- <div>
- <t:label for="votingId" />
- <t:textfield t:id="votingId" t:value="poll.creatorName" t:validate="required,minlength=2"/>
- </div>
- <div>
- <t:label for="email" />
- <t:textfield t:id="email" t:value="poll.creatorEmail" t:validate="regexp" />
- </div>
- <br />
- <div>
- <t:label for="title" />
- <t:textfield t:id="title" t:value="poll.title" t:validate="required" />
- </div>
- <div>
- <t:label for="description" />
- <t:textarea cols="23" t:id="description" t:value="poll.description"/>
- </div>
- <div>
- <t:label for="beginDate" />
- <input t:type="ck/dateTimeField" t:id="beginDate" value="poll.beginDate" t:validate="regexp"
- t:datePattern="${message:DTF-pattern}" t:timePicker="true" t:timePickerAdjacent="true"/>
- </div>
- <div>
- <t:label for="endDate" />
- <input t:type="ck/dateTimeField" t:id="endDate" value="poll.endDate" t:validate="regexp"
- t:datePattern="${message:DTF-pattern}" t:timePicker="true" t:timePickerAdjacent="true"/>
- </div>
- <div>
- <t:label for="pollType" />
- <t:select t:id="pollType" t:value="poll.pollType" t:validate="required"></t:select>
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:pollType-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:label for="voteCounting" />
- <t:select t:id="voteCounting" t:value="poll.voteCounting" t:validate="required"></t:select>
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:voteCounting-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- </fieldset>
- <div class="buttons">
- <t:submit t:value="${message:next-button}" t:zone="pollCreationZone" />
- </div>
- </div>
- </t:formfragment>
-
- <!-- Étape OPTIONS -->
- <t:formfragment visible="inOptions">
- <div id="optionsCreationFormDiv">
- <t:errors/>
- <FieldSet>
- <legend>${stepLegend}</legend>
- <div>
- <t:checkbox t:id="anonymous" t:value="poll.anonymous" onChange="cbDisable(this, this.form.anonymousVoteAllowed)" />
- <t:label for="anonymous" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:anonymous-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:checkbox t:id="anonymousVoteAllowed" t:value="poll.anonymousVoteAllowed" />
- <t:label for="anonymousVoteAllowed" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:anonymousVoteAllowed-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:checkbox t:id="continuousResults" t:value="poll.continuousResults" onChange="cbDisable(this, this.form.publicResults)" />
- <t:label for="continuousResults" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:continuousResults-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:checkbox t:id="publicResults" t:value="poll.publicResults" />
- <t:label for="publicResults" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:publicResults-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:checkbox t:id="addChoiceAllowed" t:value="poll.choiceAddAllowed" onChange="$('choiceDateDiv').toggle()" />
- <t:label for="addChoiceAllowed" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:addChoiceAllowed-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- <br/>
- <span id="choiceDateDiv" style="${choiceDateDisplay}">
- <t:label for="beginChoiceDate" />
- <input t:type="ck/dateTimeField" t:id="beginChoiceDate" value="poll.beginChoiceDate" t:validate="regexp"
- t:datePattern="${message:DTF-pattern}" t:timePicker="true" t:timePickerAdjacent="true"/>
- <br />
- <t:label for="endChoiceDate" />
- <input t:type="ck/dateTimeField" t:id="endChoiceDate" value="poll.endChoiceDate" t:validate="regexp"
- t:datePattern="${message:DTF-pattern}" t:timePicker="true" t:timePickerAdjacent="true"/>
- </span>
- </div>
- <t:if test="normalVoteCounting">
- <div>
- <t:checkbox t:id="choiceNb" value="choiceNbCheckBox" onChange="$('choiceNbDiv').toggle()"/>
- <t:label for="choiceNb" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:choiceNb-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- <br/>
- <span id="choiceNbDiv" style="${choiceNbDisplay}">
- <t:label for="maxChoiceNb" />
- <t:TextField t:id="maxChoiceNb" t:value="poll.maxChoiceNb" t:size="1" t:validate="min=0"/>
- </span>
- </div>
- </t:if>
- <t:if test="poll.creatorEmail">
- <div>
- <t:checkbox t:id="sendNotification" t:value="notificationCheckBox" onChange="$('notificationDiv').toggle()"/>
- <t:label for="sendNotification" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:sendNotification-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- <br/>
- <span id="notificationDiv" style="${notificationDisplay}">
- <t:label for="notification" />
- <t:TextField t:id="notification" t:value="notificationPreventRule.sensibility" t:size="3" t:validate="min=0"/>
- ${message:notification-label2}
- </span>
- </div>
- </t:if>
- <t:unless test="freePoll">
- <div>
- <t:checkbox t:id="sendReminder" t:value="reminderCheckBox" onChange="$('reminderDiv').toggle()"/>
- <t:label for="sendReminder" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:sendReminder-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- <br/>
- <span id="reminderDiv" style="${reminderDisplay}">
- <t:TextField t:id="reminder" t:value="reminderPreventRule.sensibility" t:size="1" t:validate="min=0"/>
- <t:label for="reminder" />
- </span>
- </div>
- </t:unless>
- </FieldSet>
- <div class="buttons">
- <t:eventLink t:event="previous" t:zone="pollCreationZone" style="text-decoration: none;">
- <input type="button" value="${message:prev-button}" />
- </t:eventLink>
- <t:submit t:value="${message:next-button}" t:zone="pollCreationZone" />
- </div>
- </div>
- </t:formfragment>
-
- <!-- Étape LISTS -->
- <t:formfragment visible="inLists">
- <div id="listsCreationFormDiv">
- <t:if test="personListsExists">
- <div>
- <t:label for="listSelect" />:
- <t:select t:id="listSelect" t:model="personLists" t:encoder="personLists" t:value="personList"
- t:mixins="ck/onEvent" t:event="change" t:onCompleteCallback="literal:onCompleteZoneUpdate"></t:select>
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:listSelect-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- </t:if>
- <t:errors/>
- <fieldset>
- <legend>${stepLegend}</legend>
- <div t:type="loop" t:source="votingLists" t:value="votingList" t:volatile="true" class="${currentListClass}">
- <div t:type="if" test="groupPoll" class="groupTitleDiv">
- <t:if test="severalGroups">
- <span class="cmd">
- <t:submit t:id="editGroup" t:value="${message:edit}" t:context="${votingListIndex}" t:defer="false" t:class="editGroupSubmit"/>
- <t:submit t:id="deleteGroup" t:value="${message:delete}" t:context="${votingListIndex}" t:defer="false" t:class="deleteGroupSubmit"/>
- </span>
- </t:if>
- ${message:group-label} ${votingListNumber} >>
- <t:label for="groupName" />
- <t:textfield t:id="groupName" t:value="votingList.name" validate="required" />
- -
- <t:label for="groupWeight" />
- <t:textfield t:id="groupWeight" t:value="votingList.weight" t:size="1" validate="required,min=1" />
- </div>
- <div t:type="loop" t:source="votingList.pollAccountDTOs" t:value="votingListPerson" t:volatile="true">
- <t:label for="personName" />
- <t:textfield t:id="personName" t:value="votingListPerson.votingId" />
- -
- <t:label for="personEmail" />
- <t:textfield t:id="personEmail" t:value="votingListPerson.email" validate="regexp" />
- -
- <t:label for="personWeight" />
- <t:textfield t:id="personWeight" t:value="votingListPerson.weight" t:size="1" validate="required,min=1" />
- </div>
- <t:submit t:id="addPerson" t:value="${message:addPerson}" t:context="${votingListIndex}" t:defer="false"/>
- </div>
- </fieldset>
- <div class="buttons">
- <t:eventLink t:event="previous" t:zone="pollCreationZone" style="text-decoration: none;">
- <input type="button" value="${message:prev-button}" />
- </t:eventLink>
- <t:if test="groupPoll">
- <t:submit t:id="addGroup" t:value="${message:addGroup}" />
- </t:if>
- <t:submit t:value="${message:next-button}" t:zone="pollCreationZone" />
- </div>
- </div>
- </t:formfragment>
-
- </t:form>
-
-
- <!-- Étape CHOICES - Formulaire différent car t:upload ne fonctionne pas en ajax -->
- <t:if test="inChoices">
- <t:FeedContextLink t:id="feedContext" />
- <t:form t:id="choicesCreationForm">
- <div id="choicesCreationFormDiv">
- <t:unless test="numberVoteCounting">
- <div>
- <t:label for="choiceType" />:
- <t:select t:id="choiceType" t:value="poll.choiceType" t:validate="required"
- t:mixins="ck/OnEvent" event="change" onCompleteCallback="onCompleteZoneUpdate">
- </t:select>
- </div>
- </t:unless>
- <t:errors/>
- <fieldset>
- <legend>${stepLegend}</legend>
- <t:formfragment t:id="textChoiceFragment" visible="isTextChoices()">
- <div t:type="loop" t:source="choices" t:value="choice" t:volatile="true">
- <div class="fleft choiceName">
- <t:label for="textName" />
- <t:textfield class="nameField" t:id="textName" t:value="choice.name" />
- -
- <t:label for="textDesc" />
- </div>
- <div class="fleft">
- <t:textarea cols="30" t:id="textDesc" t:value="choice.description" />
- </div>
- <div class="clr" />
- </div>
- </t:formfragment>
- <t:formfragment t:id="dateChoiceFragment" visible="isDateChoices()">
- <div t:type="loop" t:source="dateTypeChoices" t:value="dateTypeChoice" t:volatile="true">
- <div class="fleft choiceName">
- <t:label for="dateDTF" />
- <input t:type="ck/dateTimeField" t:id="dateDTF" value="dateTypeChoice.date" t:validate="regexp"
- t:datePattern="${message:DTF-pattern}" t:timePicker="true" t:timePickerAdjacent="true"/>
- -
- <t:label for="dateDesc" />
- </div>
- <div class="fleft">
- <t:textarea cols="35" t:id="dateDesc" t:value="dateTypeChoice.description" />
- </div>
- <div class="clr" />
- </div>
- </t:formfragment>
- <t:formfragment t:id="imgChoiceFragment" visible="isImgChoices()">
- <t:ImageContextLink t:id="imgContext" t:dir="poll.pollId" />
- <div t:type="loop" t:source="imgTypeChoices" t:value="imgTypeChoice" t:volatile="true">
- <div class="fleft choiceName">
- <t:label for="imgFile" />
- <input class="nameField" t:type="upload" t:id="imgFile" t:value="imgTypeChoice.img" t:validate="regexp" />
- -
- <t:label for="imgDesc" />
- </div>
- <div class="fleft">
- <t:textarea cols="30" t:id="imgDesc" t:value="imgTypeChoice.description" />
- </div>
- <div class="clr" />
- </div>
- </t:formfragment>
- </fieldset>
- <div class="buttons">
- <t:eventLink t:event="previous" t:zone="pollCreationZone" style="text-decoration: none;">
- <input type="button" value="${message:prev-button}" />
- </t:eventLink>
- <t:submit t:id="addChoice" t:value="${message:addChoice}" />
- <t:submit t:value="${message:submit}" />
- </div>
- </div>
- </t:form>
- </t:if>
-
-
- </t:zone>
-</t:border>
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-14 15:12:25 UTC (rev 2999)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-18 17:09:12 UTC (rev 3000)
@@ -212,23 +212,72 @@
<img src="${asset:context:img/help.png}" alt="message:help" />
</span>
</legend>
- <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone" class="form-block">
+ <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone" class="form-block" t:update="show">
<t:if t:test="canDisplayLists()">
- <t:subForm t:visible="flag">
+ <t:nuiton.feedback t:id="listsFeedback" /><br />
+ <t:subForm t:visible="formActivate">
<t:if t:test="poll.pollType.group">
<p>
<label t:type="label" t:for="listName" />:
- <input t:type="textfield" t:id="listName" value="listName"/>
- <input t:type="submit" t:id="addList" value="ADD"/>
+ <input t:type="textfield" t:id="listName" value="listName" />
+ <input t:type="submit" t:id="addList" value="ADD" />
+ <!--<a t:type="actionlink" t:id="addList" t:zone="p-pollForm-lists-zone">-->
+ <!--ADD-->
+ <!--</a>-->
</p>
- <p>
- <t:loop t:source="lists.values()" t:value="list" t:volatile="true">
- ${list.name}
+ <p class="center">
+ <t:loop t:source="lists.values()" t:value="list" t:encoder="listEncoder">
+ <input class="list-edition${styleSelected}" t:type="nuiton/submitContext" t:context="list.name" t:id="editList" value="${list.name}" />
+ <!--<span t:type="any" t:mixins="nuiton/confirm">-->
+ <!--<input t:type="nuiton/submitContext" t:id="removeList" t:image="context:img/delete.png" t:context="list.name" value="${message:delete}" />-->
+ <!--</span>-->
+ <t:if t:test="currentListSelected">
+ <input t:type="submit" t:id="saveList" t:image="context:img/save.png" t:zone="p-pollForm-lists-zone" />
+ <a t:type="actionlink" t:id="removeList" t:zone="p-pollForm-lists-zone">
+ <span t:type="any" t:mixins="nuiton/confirm">
+ <img src="${asset:context:img/delete.png}" alt="${message:delete}" />
+ </span>
+ </a>
+ </t:if>
</t:loop>
</p>
- <p:else>
- COOL
- </p:else>
+ </t:if>
+ <t:if t:test="listSelected">
+ <div class="t-data-grid">
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <th>${message:pollen.ui.participant.name-label}</th>
+ <th>${message:pollen.ui.participant.email-label}</th>
+ <th>${message:pollen.ui.participant.weight-label}</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="ajaxformloop" t:id="participants" source="selectedParticipants.values()" value="participant" t:encoder="participantEncoder">
+ <td>
+ <t:textfield t:id="participantName" value="participant.name" size="20" t:validate="required"/>
+ </td>
+ <td>
+ <t:textfield t:id="participantEmail" value="participant.email" size="25" t:validate="email"/>
+ </td>
+ <td>
+ <t:textfield t:id="participantWeight" value="participant.weight" size="1"/>
+ </td>
+ <td>
+ <t:removerowlink>
+ <img src="${asset:context:img/delete.png}" alt="${message:delete}"/>
+ </t:removerowlink>
+ </td>
+ <p:addRow>
+ <td colspan="4" class="center">
+ <t:addrowlink>${message:pollen.ui.participant.add}</t:addrowlink>
+ </td>
+ </p:addRow>
+ </tr>
+ </tbody>
+ </table>
+ </div>
</t:if>
</t:subForm>
</t:if>
1
0
r2999 - in trunk/pollen-ui/src/main: java/org/chorem/pollen/ui/components java/org/chorem/pollen/ui/pages/poll resources/org/chorem/pollen/ui/components webapp/poll
by fdesbois@users.chorem.org 14 May '10
by fdesbois@users.chorem.org 14 May '10
14 May '10
Author: fdesbois
Date: 2010-05-14 17:12:25 +0200 (Fri, 14 May 2010)
New Revision: 2999
Url: http://chorem.org/repositories/revision/pollen/2999
Log:
Create component subForm to refresh zone inside a form.
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java 2010-05-14 15:12:25 UTC (rev 2999)
@@ -0,0 +1,30 @@
+package org.chorem.pollen.ui.components;
+
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * Created: 14 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class SubForm {
+
+ @Parameter
+ private boolean visible;
+
+ @Inject
+ private Block formBlock;
+
+ @Inject
+ private Block noFormBlock;
+
+ public Block getActiveBlock() {
+ if (visible) {
+ return noFormBlock;
+ }
+ return formBlock;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.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-14 14:23:00 UTC (rev 2998)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-14 15:12:25 UTC (rev 2999)
@@ -411,15 +411,16 @@
@Inject
private ComponentResources resources;
+ @Property
private boolean flag;
- @Inject
- private Block listsForm;
+// @Inject
+// private Block listsForm;
+//
+// @Inject
+// @Property
+// private Block listsFields;
- @Inject
- @Property
- private Block listsFields;
-
public Map<String, ParticipantList> getLists() {
if (lists == null) {
lists = new HashMap<String, ParticipantList>();
@@ -446,16 +447,16 @@
return listsZone.getBody();
}
- @Log
- public Block getListsBlock() throws PollenBusinessException {
- if (canDisplayLists()) {
- if (flag) {
- return listsFields;
- }
- return listsForm;
- }
- return null;
- }
+// @Log
+// public Block getListsBlock() throws PollenBusinessException {
+// if (canDisplayLists()) {
+// if (flag) {
+// return listsFields;
+// }
+// return listsForm;
+// }
+// return null;
+// }
@Log
void onSelectedFromAddList() {
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml 2010-05-14 15:12:25 UTC (rev 2999)
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <t:delegate t:to="activeBlock" />
+ <t:block t:id="formBlock">
+ <form t:type="form" action="tapestry">
+ <t:body />
+ </form>
+ </t:block>
+ <t:block t:id="noFormBlock">
+ <t:body />
+ </t:block>
+
+</html>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.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-14 14:23:00 UTC (rev 2998)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-14 15:12:25 UTC (rev 2999)
@@ -213,29 +213,48 @@
</span>
</legend>
<div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone" class="form-block">
- <t:delegate t:to="listsBlock" />
- <t:block t:id="listsForm">
- <form t:type="form" action="tapestry">
- <t:delegate t:to="listsFields" />
- </form>
- </t:block>
- <t:block t:id="listsFields">
- <t:if t:test="poll.pollType.group">
- <p>
- <label t:type="label" t:for="listName" />:
- <input t:type="textfield" t:id="listName" value="listName"/>
- <input t:type="submit" t:id="addList" value="ADD"/>
- </p>
- <p>
- <t:loop t:source="lists.values()" t:value="list" t:volatile="true">
- ${list.name}
- </t:loop>
- </p>
- <p:else>
- COOL
- </p:else>
- </t:if>
- </t:block>
+ <t:if t:test="canDisplayLists()">
+ <t:subForm t:visible="flag">
+ <t:if t:test="poll.pollType.group">
+ <p>
+ <label t:type="label" t:for="listName" />:
+ <input t:type="textfield" t:id="listName" value="listName"/>
+ <input t:type="submit" t:id="addList" value="ADD"/>
+ </p>
+ <p>
+ <t:loop t:source="lists.values()" t:value="list" t:volatile="true">
+ ${list.name}
+ </t:loop>
+ </p>
+ <p:else>
+ COOL
+ </p:else>
+ </t:if>
+ </t:subForm>
+ </t:if>
+ <!--<t:delegate t:to="listsBlock" />-->
+ <!--<t:block t:id="listsForm">-->
+ <!--<form t:type="form" action="tapestry">-->
+ <!--<t:delegate t:to="listsFields" />-->
+ <!--</form>-->
+ <!--</t:block>-->
+ <!--<t:block t:id="listsFields">-->
+ <!--<t:if t:test="poll.pollType.group">-->
+ <!--<p>-->
+ <!--<label t:type="label" t:for="listName" />: -->
+ <!--<input t:type="textfield" t:id="listName" value="listName"/> -->
+ <!--<input t:type="submit" t:id="addList" value="ADD"/>-->
+ <!--</p>-->
+ <!--<p>-->
+ <!--<t:loop t:source="lists.values()" t:value="list" t:volatile="true">-->
+ <!--${list.name} -->
+ <!--</t:loop>-->
+ <!--</p>-->
+ <!--<p:else>-->
+ <!--COOL-->
+ <!--</p:else>-->
+ <!--</t:if>-->
+ <!--</t:block> -->
</div>
</fieldset>
</div>
1
0
Author: fdesbois
Date: 2010-05-14 16:23:00 +0200 (Fri, 14 May 2010)
New Revision: 2998
Url: http://chorem.org/repositories/revision/pollen/2998
Log:
Use last nuiton-utils snapshot, not 1.3 but 1.3.1 !! Evol on binder is not on good version on redmine.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-14 14:10:54 UTC (rev 2997)
+++ trunk/pom.xml 2010-05-14 14:23:00 UTC (rev 2998)
@@ -319,7 +319,7 @@
<i18n.version>1.2.2</i18n.version>
<tapestry.version>5.1.0.5</tapestry.version>
<nuiton-web.version>0.1-SNAPSHOT</nuiton-web.version>
- <nuiton-utils.version>1.3</nuiton-utils.version>
+ <nuiton-utils.version>1.3.1-SNAPSHOT</nuiton-utils.version>
<processor.version>1.0.2</processor.version>
<!--Multilanguage maven-site -->
1
0
Author: fdesbois
Date: 2010-05-14 16:10:54 +0200 (Fri, 14 May 2010)
New Revision: 2997
Url: http://chorem.org/repositories/revision/pollen/2997
Log:
Use last nuiton-utils release
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-14 12:06:15 UTC (rev 2996)
+++ trunk/pom.xml 2010-05-14 14:10:54 UTC (rev 2997)
@@ -319,7 +319,7 @@
<i18n.version>1.2.2</i18n.version>
<tapestry.version>5.1.0.5</tapestry.version>
<nuiton-web.version>0.1-SNAPSHOT</nuiton-web.version>
- <nuiton-utils.version>1.3-SNAPSHOT</nuiton-utils.version>
+ <nuiton-utils.version>1.3</nuiton-utils.version>
<processor.version>1.0.2</processor.version>
<!--Multilanguage maven-site -->
1
0
r2996 - in trunk/pollen-business/src: main/java/org/chorem/pollen main/java/org/chorem/pollen/entity main/java/org/chorem/pollen/service main/resources/i18n main/xmi test/java/org/chorem/pollen test/java/org/chorem/pollen/service test/java/org/chorem/pollen/test
by fdesbois@users.chorem.org 14 May '10
by fdesbois@users.chorem.org 14 May '10
14 May '10
Author: fdesbois
Date: 2010-05-14 14:06:15 +0200 (Fri, 14 May 2010)
New Revision: 2996
Url: http://chorem.org/repositories/revision/pollen/2996
Log:
- Use rule in tests to execute start with methodName
- Add tests for createPoll : unit and integration tests
- Add some methods for instantiation
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/test/
trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/test/TestData.java
Removed:
trunk/pollen-business/src/test/java/org/chorem/pollen/business/
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.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/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.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-05-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -51,17 +51,19 @@
FAVORITE_LIST_NAME_EXIST(
n_("pollen.exception.favorite_list_name_exist")),
/**
- * Exception when favorite participant name ($2) and email ($3) are
+ * Exception when participant name ($2) and email ($3) are
* already defined for the current list ($1).
**/
- FAVORITE_PARTICIPANT_EXIST(
- n_("pollen.exception.favorite_participant_exist")),
+ PARTICIPANT_EXIST(n_("pollen.exception.participant_exist")),
+
/**
* Exception when favorite participant name ($2) with no email is
* already defined for the current list ($1).
**/
- FAVORITE_PARTICIPANT_EXIST_WITHOUT_EMAIL(
- n_("pollen.exception.favorite_participant_exist_without_email"));
+ PARTICIPANT_EXIST_WITHOUT_EMAIL(
+ n_("pollen.exception.participant_exist_without_email")),
+ /** Exception when poll already exist at creation **/
+ POLL_EXIST(n_("pollen.exception.poll_exist"));
private String message;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListImpl.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -1,5 +1,7 @@
package org.chorem.pollen.entity;
+import org.chorem.pollen.PollenBusinessException;
+
import java.util.ArrayList;
import java.util.Collection;
@@ -21,7 +23,18 @@
}
@Override
- public void addParticipant(Participant participant) {
+ public void addParticipant(Participant participant) throws PollenBusinessException {
+ String name = participant.getName();
+ String email = participant.getEmail();
+
+ ParticipantHelper.checkParticipantExist(this, name, email);
+
+ FavoriteParticipant favorite = new FavoriteParticipantImpl();
+ favorite.setName(participant.getName());
+ favorite.setEmail(participant.getEmail());
+ favorite.setWeight(participant.getWeight());
+ favorite.setFavoriteList(this);
+ addFavoriteParticipant(favorite);
}
@Override
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -0,0 +1,47 @@
+package org.chorem.pollen.entity;
+
+import org.chorem.pollen.PollenBusinessException;
+
+/**
+ * Helper classes for common Participant manipulations.
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ * @see Participant
+ * @see ParticipantList
+ */
+public class ParticipantHelper {
+
+ /**
+ * Check the existence of participant from a {@code list}. The existence is
+ * tested on {@code name} and {@code email}. The {@code email} an be null.
+ *
+ * @param list ParticipantList which contains a list of Participant
+ * @param name Name of the participant to check
+ * @param email Email of the participant to check
+ * @throws PollenBusinessException if name and email correspond to an
+ * existing participant in the list.
+ */
+ public static void checkParticipantExist(
+ ParticipantList list, String name, String email)
+ throws PollenBusinessException {
+ for (Participant participant : list.getParticipants()) {
+ boolean emailNull = (email == null && participant.getEmail() == null);
+ boolean emailCheck = emailNull ||
+ (email != null && email.equals(participant.getEmail()));
+
+ if (name.equals(participant.getName()) && emailCheck) {
+ if (emailNull) {
+ throw new PollenBusinessException(
+ PollenBusinessException.PollenExceptionType.PARTICIPANT_EXIST_WITHOUT_EMAIL,
+ list.getName(), name);
+ } else {
+ throw new PollenBusinessException(
+ PollenBusinessException.PollenExceptionType.PARTICIPANT_EXIST,
+ list.getName(), name, email);
+ }
+ }
+ }
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -1,5 +1,8 @@
package org.chorem.pollen.entity;
+import org.chorem.pollen.PollenBinderHelper;
+import org.chorem.pollen.PollenBusinessException;
+
import java.util.ArrayList;
import java.util.Collection;
@@ -18,14 +21,30 @@
return null;
}
Collection<Participant> results = new ArrayList<Participant>();
- for (PollAccount account : getChild()) {
- results.add(account);
- }
+ if (getChild() != null) {
+ for (PollAccount account : getChild()) {
+ results.add(account);
+ }
+ }
return results;
}
@Override
- public void addParticipant(Participant participant) {
+ public void addParticipant(Participant participant) throws PollenBusinessException {
+ if (!list) {
+ throw new UnsupportedOperationException(
+ "Unable to add a participant from a child account");
+ }
+ String name = participant.getName();
+ String email = participant.getEmail();
+
+ ParticipantHelper.checkParticipantExist(this, name, email);
+
+ PollAccount account = new PollAccountImpl();
+ account.setName(name);
+ account.setEmail(email);
+ account.setWeight(participant.getWeight());
+ addChild(account);
}
@Override
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-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -70,4 +70,14 @@
setVoteCounting(voteCountingType.ordinal());
}
+ @Override
+ public Choice addNewChoice(String name, String description) {
+ // check exist
+ Choice choice = new ChoiceImpl();
+ choice.setName(name);
+ choice.setDescription(description);
+ choice.setChoiceType(getChoiceType());
+ addChoice(choice);
+ return choice;
+ }
}
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-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceFavoriteImpl.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -142,12 +142,12 @@
// The error type (message) depends on email nullity
if (participant.getEmail() == null) {
throw new PollenBusinessException(
- PollenExceptionType.FAVORITE_PARTICIPANT_EXIST_WITHOUT_EMAIL,
+ PollenExceptionType.PARTICIPANT_EXIST_WITHOUT_EMAIL,
list.getName(),
participant.getName());
} else {
throw new PollenBusinessException(
- PollenExceptionType.FAVORITE_PARTICIPANT_EXIST,
+ PollenExceptionType.PARTICIPANT_EXIST,
list.getName(),
participant.getName(),
participant.getEmail());
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-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -76,6 +76,9 @@
creator.setUserAccount(user);
}
poll.setCreator(creator);
+ // Generate Uid to have a unique poll. Will avoid multi-submit, existing
+ // poll will be check by its uid.
+ poll.setUid(context.createPollenUrlId());
return poll;
}
@@ -87,23 +90,37 @@
@Override
protected void executeCreatePoll(TopiaContext transaction,
List<Object> errorArgs, Poll poll, Collection<ParticipantList> lists)
- throws TopiaException, IllegalArgumentException {
+ throws TopiaException,
+ IllegalArgumentException,
+ PollenBusinessException {
errorArgs.add(poll.getTitle());
errorArgs.add(poll.getUid());
PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
+ if (dao.existByNaturalId(poll.getUid())) {
+ throw new PollenBusinessException(
+ PollenBusinessException.PollenExceptionType.POLL_EXIST);
+ }
+
// Create newPoll and copy simple properties from poll source
Poll newPoll = createBasicPoll(transaction, poll);
- // Create accounts depends on pollType and lists argument
- List<PollAccount> accounts = createPollAccounts(transaction,
- newPoll.getPollType(), lists);
+ // Create accounts only for non free poll
+ if (!newPoll.getPollType().isFree()) {
+ // Create accounts depends on pollType and lists argument
+ List<PollAccount> accounts = createPollAccounts(transaction,
+ newPoll.getPollType(), lists);
+ newPoll.setPollAccount(accounts);
+ }
+
// Create newPoll choices
List<Choice> choices = createPollChoices(transaction, poll.getChoice());
+ newPoll.setChoice(choices);
+
dao.update(newPoll);
transaction.commitTransaction();
@@ -117,8 +134,10 @@
PollenDAOHelper.getPollAccountDAO(transaction);
// Create newPoll and copy simple properties from poll source
- Poll newPoll = dao.create(context.createPollenUrlId());
+ Poll newPoll = dao.create(source.getUid());
+ // Copy all properties instead of Uid (already set at creation),
+ // Closed (not used in this case) and Creator (managed separately)
PollenBinderHelper.getSimpleTopiaBinder(Poll.class).
copyExcluding(source, newPoll,
Poll.UID,
@@ -132,8 +151,9 @@
copy(source.getCreator(), creator,
PollAccount.NAME,
PollAccount.EMAIL,
- PollAccount.WEIGHT,
- PollAccount.ADMIN);
+// PollAccount.WEIGHT,
+ PollAccount.ADMIN,
+ PollAccount.USER_ACCOUNT);
accountDAO.update(creator);
newPoll.setCreator(creator);
@@ -178,7 +198,7 @@
createPersonAccounts(accountDAO, list);
accountList.setChild(accounts);
- // Add the accountList to the newPoll
+ // Add the accountList to the results
results.add(accountList);
}
}
@@ -306,4 +326,18 @@
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
+ protected ParticipantList executeGetNewPollList() {
+ PollAccount list = new PollAccountImpl();
+ list.setList(true);
+ list.setChild(new ArrayList<PollAccount>());
+ return list;
+ }
+
+ @Override
+ protected Participant executeGetNewPollParticipant() {
+ PollAccount participant = new PollAccountImpl();
+ return participant;
+ }
+
}
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-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-14 12:06:15 UTC (rev 2996)
@@ -33,6 +33,8 @@
pollen.error.servicePoll.getAllPolls=
pollen.error.servicePoll.getComments=
pollen.error.servicePoll.getNewPoll=
+pollen.error.servicePoll.getNewPollList=
+pollen.error.servicePoll.getNewPollParticipant=
pollen.error.servicePoll.getPoll=
pollen.error.servicePoll.getPollForResults=
pollen.error.servicePoll.getPollForUpdate=
@@ -79,6 +81,9 @@
pollen.exception.favorite_participant_exist=
pollen.exception.favorite_participant_exist_without_email=
pollen.exception.load_configuration=
+pollen.exception.participant_exist=
+pollen.exception.participant_exist_without_email=
+pollen.exception.poll_exist=
pollen.exception.poll_not_exist=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
pollen.exception.smtp_not_available=
pollen.exception.user_email_exist=
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-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-14 12:06:15 UTC (rev 2996)
@@ -32,6 +32,8 @@
pollen.error.servicePoll.getAllPolls=
pollen.error.servicePoll.getComments=
pollen.error.servicePoll.getNewPoll=
+pollen.error.servicePoll.getNewPollList=
+pollen.error.servicePoll.getNewPollParticipant=
pollen.error.servicePoll.getPoll=
pollen.error.servicePoll.getPollForResults=
pollen.error.servicePoll.getPollForUpdate=
@@ -75,9 +77,10 @@
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
-pollen.exception.favorite_participant_exist=La liste %1$s contient d\u00E9j\u00E0 un utilisateur nomm\u00E9 %2$s avec un email %3$s
-pollen.exception.favorite_participant_exist_without_email=La liste %1$s contient d\u00E9j\u00E0 un utilisateur nomm\u00E9 %2$s avec aucun email
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_exist=La liste %1$s contient d\u00E9j\u00E0 un votant nomm\u00E9 %2$s avec un email %3$s
+pollen.exception.participant_exist_without_email=La liste %1$s contient d\u00E9j\u00E0 un votant nomm\u00E9 %2$s avec aucun email
+pollen.exception.poll_exist=
pollen.exception.poll_not_exist=Il n'y a pas de sondage \u00E0 cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le compl\u00E8tement dans le champ d'adresse de votre navigateur.
pollen.exception.smtp_not_available=Impossible d'envoyer un email \u00E0 %1$s. Serveur smtp indisponible pour l'envoi d'email, veuillez contacter un administrateur.
pollen.exception.user_email_exist=Un utilisateur est d\u00E9j\u00E0 enregistr\u00E9 avec cet email.
Modified: trunk/pollen-business/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/xmi/pollen.properties 2010-05-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-05-14 12:06:15 UTC (rev 2996)
@@ -1,4 +1,4 @@
-# Pr\u00E9cise l'ent\u00EAte de l'ensemble des fichiers g\u00E9n\u00E9r\u00E9s
+# Pr\u00e9cise l'ent\u00eate de l'ensemble des fichiers g\u00e9n\u00e9r\u00e9s
model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 Pollen\n *##%*/
#model.tagvalue.dbSchema=Pollen
model.tagvalue.java.lang.String=text
@@ -17,3 +17,6 @@
org.chorem.pollen.entity.FavoriteParticipant.attribute.name.tagvalue.naturalId=true
org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.naturalId=true
org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.notNull=false
+
+org.chorem.pollen.entity.Poll.attribute.uid.tagvalue.naturalId=true
+org.chorem.pollen.entity.Poll.attribute.creator.tagvalue.lazy=false
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java 2010-05-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceFavoriteImplTest.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -6,7 +6,7 @@
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.PollenDAOHelper;
-import org.chorem.pollen.business.AbstractServiceTest;
+import org.chorem.pollen.test.AbstractServiceTest;
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.FavoriteParticipantDAO;
@@ -27,9 +27,13 @@
private static final Log log = LogFactory.getLog(ServiceUserImplTest.class);
+ @Override
+ protected void init() throws Exception {
+ }
+
@Test
public void testCreateFavoriteParticipant() throws Exception {
- start("testCreateFavoriteParticipant");
+ //start("testCreateFavoriteParticipant");
UserAccount user = createUser(false);
@@ -56,7 +60,7 @@
try {
getServiceFavorite().createFavoriteParticipant(participant);
} catch (PollenBusinessException eee) {
- Assert.assertEquals(PollenExceptionType.FAVORITE_PARTICIPANT_EXIST,
+ Assert.assertEquals(PollenExceptionType.PARTICIPANT_EXIST,
eee.getType());
}
@@ -89,7 +93,7 @@
@Test
public void testUpdateFavoriteParticipant() throws Exception {
- start("testUpdateFavoriteParticipant");
+ //start("testUpdateFavoriteParticipant");
/** PREPARE DATA **/
UserAccount user = createUser(false);
@@ -105,5 +109,4 @@
getServiceFavorite().updateFavoriteParticipant(participant);
}
-
}
Added: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -0,0 +1,324 @@
+package org.chorem.pollen.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenDAOHelper;
+import org.chorem.pollen.test.AbstractServiceTest;
+import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entity.FavoriteList;
+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.PollAccountImpl;
+import org.chorem.pollen.entity.PollDAO;
+import org.chorem.pollen.entity.PollImpl;
+import org.chorem.pollen.entity.UserAccount;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Created: 14 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ServicePollImplTest extends AbstractServiceTest {
+
+ private static final Log log = LogFactory.getLog(ServicePollImplTest.class);
+
+ private UserAccount user;
+
+ private PollAccount creator;
+
+ private PollAccount list1;
+
+ private FavoriteList list2;
+
+ private Poll poll;
+
+ //@Before
+ public void init() throws Exception {
+ // Initialize service and default user
+ getServicePoll();
+ user = createUser(false);
+
+ // Poll creator
+ creator = new PollAccountImpl();
+ creator.setName(user.getDisplayName());
+ creator.setEmail(user.getEmail());
+ creator.setUserAccount(user);
+ creator.setAdmin(true);
+
+ // Poll
+ poll = new PollImpl();
+ poll.setCreator(creator);
+ poll.setTitle("Poll");
+ poll.setUid(context.createPollenUrlId());
+
+ // Participant Lists
+ // First list : new list specific for poll restriction
+ list1 = new PollAccountImpl();
+ list1.setName("List1");
+ list1.setList(true);
+
+ Participant participant1_1 = new PollAccountImpl();
+ participant1_1.setName("participant1_1");
+ participant1_1.setEmail("email1_1(a)domain.org");
+ list1.addParticipant(participant1_1);
+
+ Participant participant1_2 = new PollAccountImpl();
+ participant1_2.setName("participant1_2");
+ list1.addParticipant(participant1_2);
+
+ // Second list : existing list from user favorites
+ list2 = createFavoriteList("list2", user);
+ Participant participant2_1 = createFavoriteParticipant(
+ "participant2_1", "email2_1(a)domain.org", list2);
+ Participant participant2_2 = createFavoriteParticipant(
+ "participant2_2", "email2_2(a)domain.org", list2);
+ Participant participant2_3 = createFavoriteParticipant(
+ "participant2_3", null, list2);
+
+ list2 = findFavoriteList(list2.getId(), FavoriteList.FAVORITE_PARTICIPANT);
+ }
+
+ @Test
+ public void testInternalCreateBasicPoll() throws Exception {
+ //start("testInternalCreateBasicPoll");
+
+ /** PREPARE DATA **/
+ // done in init() method
+
+ /** EXEC METHOD **/
+
+ log.info("test 1 : create poll with creator from existing user");
+
+ TopiaContext transaction = beginTransaction();
+ Poll newPoll = null;
+ try {
+ newPoll = servicePoll.createBasicPoll(transaction, poll);
+ Assert.assertNotNull(newPoll);
+ Assert.assertNotNull(newPoll.getId());
+ Assert.assertNotNull(newPoll.getUid());
+ Assert.assertEquals("Poll", newPoll.getTitle());
+
+ PollAccount newCreatorAccount = newPoll.getCreator();
+ Assert.assertNotNull(newCreatorAccount);
+ Assert.assertNotNull(newCreatorAccount.getUid());
+ Assert.assertEquals(user, newCreatorAccount.getUserAccount());
+ Assert.assertTrue(newCreatorAccount.getAdmin());
+
+ // Will save the poll and its creator
+ transaction.commitTransaction();
+
+ } finally {
+ transaction.closeContext();
+ }
+
+ // Verification
+ transaction = beginTransaction();
+ try {
+ PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
+
+ Poll pollFound = dao.findById(newPoll.getId());
+ Assert.assertNotNull(pollFound);
+ Assert.assertNotNull(pollFound.getCreator());
+ Assert.assertEquals(user, pollFound.getCreator().getUserAccount());
+
+ } finally {
+ transaction.closeContext();
+ }
+
+ log.info("test 2 : create poll with new creator");
+ poll.getCreator().setUserAccount(null);
+
+ transaction = beginTransaction();
+ newPoll = null;
+ try {
+ newPoll = servicePoll.createBasicPoll(transaction, poll);
+ PollAccount newCreatorAccount = newPoll.getCreator();
+ Assert.assertNull(newCreatorAccount.getUserAccount());
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ @Test
+ public void testInternalCreatePollAccounts() throws Exception {
+ //start("testInternalCreatePollAccounts");
+
+ /** PREPARE DATA **/
+ // list initializations in init() method
+
+ Collection<ParticipantList> lists = new ArrayList<ParticipantList>();
+ // First list : new list specific for poll restriction
+ lists.add(list1);
+ // Second list : existing list from user favorites
+ lists.add(list2);
+
+ /** EXEC METHOD **/
+
+ log.info("test 1 : createPollAccounts from one new list : RESTRICTED");
+
+
+ TopiaContext transaction = beginTransaction();
+ try {
+ // Only the first list of the collection will be considered : list1
+ // Create only person accounts
+ List<PollAccount> accounts = servicePoll.createPollAccounts(
+ transaction, PollType.RESTRICTED, lists);
+
+ Assert.assertEquals(2, accounts.size());
+ for (PollAccount account : accounts) {
+ Assert.assertFalse(account.getList());
+ Assert.assertNotNull(account.getId());
+ Assert.assertNotNull(account.getUid());
+ // No link with user
+ Assert.assertNull(account.getUserAccount());
+ }
+
+ } finally {
+ transaction.closeContext();
+ }
+
+ log.info("test 2 : createPollAccounts from two lists : GROUP." +
+ " One of the list is an existing favorite one");
+
+ transaction = beginTransaction();
+ try {
+ // Create only list accounts
+ List<PollAccount> accounts = servicePoll.createPollAccounts(
+ transaction, PollType.GROUP, lists);
+
+ Assert.assertEquals(2, accounts.size());
+ for (PollAccount account : accounts) {
+ Assert.assertTrue(account.getList());
+ Assert.assertNotNull(account.getId());
+ Assert.assertNotNull(account.getUid());
+ Assert.assertNotNull(account.getName());
+ // No link with user
+ Assert.assertNull(account.getUserAccount());
+ // Check on list1
+ if (account.getName().equals(list1.getName())) {
+ Assert.assertEquals(2, account.getChild().size());
+ // Check on list2
+ } else if (account.getName().equals(list2.getName())) {
+ Assert.assertEquals(3, account.getChild().size());
+ // Child are person accounts
+ for (PollAccount person : account.getChild()) {
+ Assert.assertFalse(person.getList());
+ Assert.assertNotNull(person.getId());
+ Assert.assertNotNull(person.getUid());
+ // No link with user
+ Assert.assertNull(person.getUserAccount());
+ }
+ }
+ }
+
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ @Test
+ public void integrationCreatePollFree() throws Exception {
+ /** PREPARE DATA **/
+ user = null;
+ poll = servicePoll.getNewPoll(user);
+ poll.getCreator().setName("homer");
+ poll.setPollType(PollType.FREE);
+ poll.setChoiceType(ChoiceType.TEXT);
+ poll.addNewChoice("choice1", null);
+ poll.addNewChoice("choice2", "desc2");
+ poll.addNewChoice("choice3", "desc3");
+
+ /** EXEC METHOD **/
+ servicePoll.createPoll(poll, null);
+
+ /** VERIFICATION RESULT **/
+ TopiaContext transaction = beginTransaction();
+ try {
+ // No accounts + type = FREE + 3 TEXT choices
+ PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
+ Assert.assertTrue(dao.existByNaturalId(poll.getUid()));
+ Poll pollFound = dao.findByNaturalId(poll.getUid());
+
+ // Check pollType and accounts
+ Assert.assertEquals(PollType.FREE, pollFound.getPollType());
+ Assert.assertEquals(0, pollFound.getPollAccount().size());
+
+ // Check choices
+ Assert.assertEquals(ChoiceType.TEXT, pollFound.getChoiceType());
+ Assert.assertEquals(3, pollFound.getChoice().size());
+
+ // Check creator
+ Assert.assertNotNull(pollFound.getCreator());
+ Assert.assertNull(pollFound.getCreator().getUserAccount());
+ Assert.assertNotNull(pollFound.getCreator().getName());
+
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ @Test
+ public void integrationCreatePollRestrictedFromNewList() throws Exception {
+ /** PREPARE DATA **/
+ poll = servicePoll.getNewPoll(user);
+ poll.setPollType(PollType.RESTRICTED);
+ poll.setChoiceType(ChoiceType.DATE);
+ poll.addNewChoice("date1", null);
+ poll.addNewChoice("date2", "desc2");
+ poll.addNewChoice("date3", "desc3");
+
+ Collection<ParticipantList> lists = new ArrayList<ParticipantList>();
+ ParticipantList list = servicePoll.getNewPollList();
+ lists.add(list);
+
+ Participant participant1 = servicePoll.getNewPollParticipant();
+ participant1.setName("participant1");
+ participant1.setEmail("email1");
+ participant1.setWeight(1.);
+ list.addParticipant(participant1);
+
+ Participant participant2 = servicePoll.getNewPollParticipant();
+ participant2.setName("participant2");
+ participant2.setEmail(null);
+ participant2.setWeight(1.);
+ list.addParticipant(participant2);
+
+ /** EXEC METHOD **/
+ servicePoll.createPoll(poll, lists);
+
+ /** VERIFICATION RESULT **/
+ TopiaContext transaction = beginTransaction();
+ try {
+ // Two person accounts + type = RESTRICTED + 3 DATE choices
+ PollDAO dao = PollenDAOHelper.getPollDAO(transaction);
+ Assert.assertTrue(dao.existByNaturalId(poll.getUid()));
+ Poll pollFound = dao.findByNaturalId(poll.getUid());
+
+ // Check pollType and accounts
+ Assert.assertEquals(PollType.RESTRICTED, pollFound.getPollType());
+ Assert.assertEquals(2, pollFound.getPollAccount().size());
+
+ // Check choices
+ Assert.assertEquals(ChoiceType.DATE, pollFound.getChoiceType());
+ Assert.assertEquals(3, pollFound.getChoice().size());
+
+ // Check creator
+ Assert.assertEquals(user, pollFound.getCreator().getUserAccount());
+
+ } finally {
+ transaction.closeContext();
+ }
+ }
+}
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServicePollImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-05-12 21:11:26 UTC (rev 2995)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -7,18 +7,13 @@
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
-import org.chorem.pollen.business.AbstractServiceTest;
-import org.chorem.pollen.business.TestData;
-import org.chorem.pollen.entity.FavoriteList;
-import org.chorem.pollen.entity.FavoriteParticipant;
-import org.chorem.pollen.entity.FavoriteParticipantDAO;
+import org.chorem.pollen.test.AbstractServiceTest;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
import org.junit.Assert;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaQuery;
/**
*
@@ -27,10 +22,14 @@
public class ServiceUserImplTest extends AbstractServiceTest {
private static final Log log = LogFactory.getLog(ServiceUserImplTest.class);
+
+ @Override
+ protected void init() throws Exception {
+ }
@Test
public void testCopyUserAccount() throws Exception {
- start("testManageNewPassword");
+ //start("testManageNewPassword");
UserAccount user = getServiceUser().getNewUser();
user.setLogin("homer");
@@ -53,7 +52,7 @@
@Test
public void testCheckPassword() throws Exception {
- start("testCheckPassword");
+ //start("testCheckPassword");
UserAccount user = getServiceUser().getNewUser();
user.setLogin("homer");
@@ -87,7 +86,7 @@
*/
@Test
public void testExecuteConnect() throws Exception {
- start("testExecuteConnect");
+ //start("testExecuteConnect");
// The password is wouhou and login is homer
UserAccount user = createUser(false);
@@ -121,7 +120,7 @@
*/
@Test
public void testExecuteGetNewUser() throws Exception {
- start("testGetNewUser");
+ //start("testGetNewUser");
UserAccount user = getServiceUser().getNewUser();
Assert.assertNotNull(user);
@@ -133,7 +132,7 @@
*/
@Test
public void testExecuteCreateUser() throws Exception {
- start("testCreateUser");
+ //start("testCreateUser");
UserAccount user = getServiceUser().getNewUser();
user.setLogin("hsimpson");
@@ -190,7 +189,7 @@
*/
@Test
public void testExecuteUpdateUser() throws Exception {
- start("testUpdateUser");
+ //start("testUpdateUser");
UserAccount user1 = getServiceUser().getNewUser();
user1.setLogin("hsimpson");
@@ -242,7 +241,7 @@
*/
@Test
public void testExecuteDeleteUser() throws Exception {
- start("testUpdateUser");
+ //start("testUpdateUser");
try {
getServiceUser().deleteUser("test");
Copied: trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java (from rev 2992, trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java)
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -0,0 +1,246 @@
+package org.chorem.pollen.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenContext;
+import org.chorem.pollen.PollenContextImpl;
+import org.chorem.pollen.PollenDAOHelper;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteListDAO;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.FavoriteParticipantDAO;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.UserAccountDAO;
+import org.chorem.pollen.service.ServiceFavoriteImpl;
+import org.chorem.pollen.service.ServicePollImpl;
+import org.chorem.pollen.service.ServiceUserImpl;
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.junit.runners.model.FrameworkMethod;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * TestManager
+ *
+ * Created: 24 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+@Ignore
+public abstract class AbstractServiceTest {
+
+ private static final Log log = LogFactory.getLog(AbstractServiceTest.class);
+
+ protected PollenContext context;
+
+ protected ServiceUserImpl serviceUser;
+
+ protected ServiceFavoriteImpl serviceFavorite;
+
+ protected ServicePollImpl servicePoll;
+
+ @Rule
+ public TestName rule = new TestName() {
+
+ @Override
+ public void starting(FrameworkMethod method) {
+ super.starting(method);
+ try {
+ getTest().start(getMethodName());
+ getTest().init();
+ } catch (Exception eee) {
+ log.error(eee.getClass().getSimpleName(), eee);
+ }
+ }
+
+ public AbstractServiceTest getTest() {
+ return AbstractServiceTest.this;
+ }
+ };
+
+ protected abstract void init() throws Exception;
+
+ public void start(String dbname) throws IOException {
+ log.info("## START ## : " + dbname);
+
+ InputStream input = AbstractServiceTest.class.
+ getResourceAsStream("/PollenTest.properties");
+
+ Properties options = new Properties();
+ options.load(input);
+
+ ApplicationConfig config = new ApplicationConfig();
+ config.setOptions(options);
+ config.setOption(
+ "hibernate.connection.url",
+ "jdbc:h2:file:target/surefire-data/" + dbname
+ );
+
+ getContext().loadConfiguration(config);
+ getContext().start(getServiceUser());
+
+ // Set currentDate to 23/02/2010 for tests
+ Calendar calendar = new GregorianCalendar(2010, 1, 23, 0, 0, 0);
+ ((PollenContextImpl)getContext()).setCurrentDate(calendar.getTime());
+ }
+
+ @After
+ public void stop() throws IOException {
+ getContext().stop();
+ context = null;
+ serviceUser = null;
+ servicePoll = null;
+ serviceFavorite = null;
+ }
+
+ public PollenContext getContext() {
+ if (context == null) {
+ context = new PollenContextImpl();
+ }
+ return context;
+ }
+
+ public ServiceUserImpl getServiceUser() {
+ if (serviceUser == null) {
+ serviceUser = new ServiceUserImpl();
+ serviceUser.setContext(getContext());
+ }
+ return serviceUser;
+ }
+
+ public ServiceFavoriteImpl getServiceFavorite() {
+ if (serviceFavorite == null) {
+ serviceFavorite = new ServiceFavoriteImpl();
+ serviceFavorite.setContext(getContext());
+ }
+ return serviceFavorite;
+ }
+
+ public ServicePollImpl getServicePoll() {
+ if (servicePoll == null) {
+ servicePoll = new ServicePollImpl();
+ servicePoll.setContext(getContext());
+ }
+ return servicePoll;
+ }
+
+ public TopiaContext beginTransaction() throws TopiaException {
+ return getContext().beginTransaction();
+ }
+
+// public ServiceEmailImpl getServiceEmail() {
+// ServiceEmailImpl instance = new ServiceEmailImpl();
+// instance.setContext(getContext());
+// return instance;
+// }
+//
+// public ServicePollImpl getServicePoll() {
+// ServicePollImpl instance = new ServicePollImpl();
+// instance.setContext(getContext());
+// return instance;
+// }
+
+ /**
+ * Create a user :<br />
+ * <ul>
+ * <li>login : homer</li>
+ * <li>email : homer(a)simpson.us</li>
+ * <li>password : wouhou</li>
+ * </ul>
+ * You can decide if this user is an admin using {@code admin} argument.
+ *
+ * @param admin flag to create the user as an admin
+ * @return the new UserAccount created
+ * @throws TopiaException
+ * @throws PollenBusinessException
+ */
+ public UserAccount createUser(boolean admin)
+ throws TopiaException, PollenBusinessException {
+
+ UserAccount user = getServiceUser().getNewUser();
+ user.setLogin("homer");
+ user.setEmail("homer(a)simpson.us");
+ user.setNewPassword("wouhou");
+ user.setAdmin(admin);
+
+ getServiceUser().createUser(user);
+
+ TopiaContext transaction = getContext().beginTransaction();
+ try {
+ UserAccountDAO dao =
+ PollenDAOHelper.getUserAccountDAO(transaction);
+
+ UserAccount findUser = dao.findByLogin(user.getLogin());
+ return findUser;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ public FavoriteList createFavoriteList(String name, UserAccount user)
+ throws TopiaException {
+
+ TopiaContext transaction = beginTransaction();
+ try {
+ FavoriteListDAO dao =
+ PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ FavoriteList list = dao.create(name, user);
+ transaction.commitTransaction();
+ return list;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ public FavoriteParticipant createFavoriteParticipant(String name,
+ String email, FavoriteList list) throws TopiaException {
+ TopiaContext transaction = beginTransaction();
+ try {
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ FavoriteParticipant participant = dao.create(name, email, list);
+ transaction.commitTransaction();
+ return participant;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+ public FavoriteList findFavoriteList(String id, String... propertiesLoad)
+ throws TopiaException {
+ TopiaContext transaction = beginTransaction();
+ try {
+ FavoriteListDAO dao =
+ PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ TopiaQuery query = dao.createQuery().
+ add(TopiaEntity.ID, id).
+ addLoad(propertiesLoad);
+
+ FavoriteList result = dao.findByQuery(query);
+
+ return result;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+}
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/test/AbstractServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Copied: trunk/pollen-business/src/test/java/org/chorem/pollen/test/TestData.java (from rev 2992, trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java)
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/test/TestData.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/test/TestData.java 2010-05-14 12:06:15 UTC (rev 2996)
@@ -0,0 +1,40 @@
+package org.chorem.pollen.test;
+
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * TestData
+ *
+ * Created: 24 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public abstract class TestData {
+
+ protected TopiaContext transaction;
+
+ public void execute() throws Exception {
+ transaction = null;
+ try {
+ //transaction = beginTransaction();
+
+ test();
+
+ } catch (Exception eee) {
+ if (transaction != null) {
+ transaction.rollbackTransaction();
+ }
+ throw eee;
+ } finally {
+ if (transaction != null) {
+ transaction.closeContext();
+ }
+ }
+ }
+
+ protected abstract void test() throws Exception;
+}
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/test/TestData.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
1
0