r2977 - in trunk: . pollen-business pollen-business/src/main/java/org/chorem/pollen pollen-business/src/main/java/org/chorem/pollen/bean pollen-business/src/main/java/org/chorem/pollen/entity pollen-business/src/main/java/org/chorem/pollen/service pollen-business/src/main/resources/i18n pollen-business/src/main/xmi pollen-ui 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/pages/poll pollen
Author: fdesbois Date: 2010-04-28 10:47:44 +0200 (Wed, 28 Apr 2010) New Revision: 2977 Log: - Change in model : Add two entities FavoriteList and FavoriteParticipant + add contracts to identify them as ParticipantList and Participant like PollAccount. - Some trials on PropertyNameProvider to find the best way to use it - Use transformers JavaInterfaceTransformer from EUGene and BinderHelperTransformer from ToPIA Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java Removed: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java Modified: trunk/pollen-business/pom.xml trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties trunk/pollen-business/src/main/xmi/pollen.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/UserListsCreate.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml trunk/pom.xml Modified: trunk/pollen-business/pom.xml =================================================================== --- trunk/pollen-business/pom.xml 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/pom.xml 2010-04-28 08:47:44 UTC (rev 2977) @@ -114,7 +114,9 @@ <templates> org.nuiton.topia.generator.TopiaMetaTransformer, org.nuiton.topia.generator.ServiceTransformer, - org.nuiton.topia.generator.BeanTransformer + org.nuiton.eugene.java.JavaInterfaceTransformer, + org.nuiton.eugene.java.JavaBeanTransformer, + org.nuiton.topia.generator.BinderHelperTransformer </templates> </configuration> <goals> Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -3,7 +3,6 @@ import java.security.NoSuchAlgorithmException; import java.util.Date; -import java.util.Locale; import java.util.Properties; import java.util.UUID; import org.apache.commons.logging.Log; @@ -20,7 +19,10 @@ import static org.nuiton.i18n.I18n.n_; import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; import org.nuiton.util.StringUtil; +import org.nuiton.util.beans.BinderBuilder; /** * PollenContext 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-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -4,8 +4,8 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import org.apache.commons.lang.StringUtils; -import org.chorem.pollen.entity.EntityProperty; -import org.chorem.pollen.entity.PropertyUid; +import org.chorem.pollen.entity.PropertyNameProviderImpl; +import org.chorem.pollen.entity.PropertyNameProvider; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.persistence.TopiaEntity; @@ -25,7 +25,7 @@ protected String orderBy; - protected String uid; + protected String referenceId; private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); @@ -36,7 +36,7 @@ public static final String PROPERTY_ORDER_BY = "orderBy"; - public static final String PROP_UID = "uid"; + public static final String PROP_REFERENCE_ID = "referenceId"; /** * Get the value of startIndex @@ -55,7 +55,8 @@ public void setStartIndex(Integer startIndex) { Integer oldStartIndex = this.startIndex; this.startIndex = startIndex; - propertyChangeSupport.firePropertyChange(PROPERTY_START_INDEX, oldStartIndex, startIndex); + propertyChangeSupport.firePropertyChange(PROPERTY_START_INDEX, + oldStartIndex, startIndex); } /** @@ -75,7 +76,8 @@ public void setOrderBy(String orderBy) { String oldOrderBy = this.orderBy; this.orderBy = orderBy; - propertyChangeSupport.firePropertyChange(PROPERTY_ORDER_BY, oldOrderBy, orderBy); + propertyChangeSupport.firePropertyChange(PROPERTY_ORDER_BY, + oldOrderBy, orderBy); } /** @@ -95,27 +97,29 @@ public void setEndIndex(Integer endIndex) { Integer oldEndIndex = this.endIndex; this.endIndex = endIndex; - propertyChangeSupport.firePropertyChange(PROPERTY_END_INDEX, oldEndIndex, endIndex); + propertyChangeSupport.firePropertyChange(PROPERTY_END_INDEX, + oldEndIndex, endIndex); } /** - * Get the value of uid + * Get the value of referenceId * - * @return the value of uid + * @return the value of referenceId */ - public String getUid() { - return uid; + public String getReferenceId() { + return referenceId; } /** - * Set the value of uid + * Set the value of referenceId * - * @param uid new value of uid + * @param entity */ - public void setUid(String uid) { - String oldUid = this.uid; - this.uid = uid; - propertyChangeSupport.firePropertyChange(PROP_UID, oldUid, uid); + public void setReference(TopiaEntity entity) { + String oldReferenceId = this.referenceId; + this.referenceId = entity.getTopiaId(); + propertyChangeSupport.firePropertyChange(PROP_REFERENCE_ID, + oldReferenceId, referenceId); } /** @@ -152,10 +156,9 @@ * to retrieve the name of UID property in case of filter using uid. * * @param query to prepare - * @param ordered if order is needed (using orderBy filter) * @param property to provide UID property name (using uid filter) */ - public void prepareQuery(TopiaQuery query, PropertyUid property) { + public void prepareQuery(TopiaQuery query, PropertyNameProvider property) { // Add limits. Only startIndex do nothing. // startIndex + endIndex provides the limit if (startIndex != null && endIndex != null) { @@ -166,8 +169,8 @@ query.setMaxResults(endIndex); } - if (StringUtils.isNotEmpty(uid) && property != null) { - query.add(property.namePropertyUid(), uid); + if (StringUtils.isNotEmpty(referenceId) && property != null) { + query.add(property.namePropertyId(), referenceId); } // Add order to the query, splitted by comma and trimmed using Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -1,80 +0,0 @@ - -package org.chorem.pollen.entity; - -import org.nuiton.topia.framework.*; - -/** - * EntityProperty is used to simplify property concatenation in TopiaQuery. - * The usage is simple, the EntityProperty 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); - * - * // Property used in the query - * EntityProperty boatProperty = new EntityProperty("B"); - * - * // It's better to create the query with the property name - * TopiaQuery query = dao.createQuery(boatProperty.name()); - * - * // The property NAME of the boat need to be find equals to "ULUBERLU" - * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU"); - * - * // 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 : - * <pre> - * public class BoatProperty extends EntityProperty { - * - * public BoatProperty(String mainAlias) { - * super(mainAlias); - * } - * - * public String namePropertyName() { - * return nameProperty(Boat.NAME); - * } - * } - * </pre> - * - * Created: 14 avr. 2010 - * - * @author fdesbois <fdesbois@codelutin.com> - */ -public class EntityProperty { - - /** alias of the entity **/ - protected String mainAlias; - - public EntityProperty(String mainAlias) { - this.mainAlias = mainAlias; - } - - /** - * Name the entity as a property for a TopiaQuery. - * - * @return the entity name used as a TopiaQuery property - */ - public String name() { - return mainAlias; - } - - /** - * Name a property from the Entity for a TopiaQuery. - * - * @param propertyName to named in the TopiaQuery - * @return the property name used as a TopiaQuery property - */ - public String nameProperty(String propertyName) { - return TopiaQuery.getProperty(mainAlias, propertyName); - } - - @Override - public String toString() { - return name(); - } -} Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,23 @@ + +package org.chorem.pollen.entity; + +/** + * FavoriteListProperty + * + * Created: 28 avr. 2010 + * + * @author fdesbois + */ +public class FavoriteListProperty extends PropertyNameProviderImpl + implements ParticipantListProperty { + + public FavoriteListProperty(String mainAlias) { + super(FavoriteList.class, mainAlias); + } + + @Override + public String namePropertyParticipant() { + return nameProperty(FavoriteList.FAVORITE_PARTICIPANT); + } + +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,19 @@ + +package org.chorem.pollen.entity; + +import org.nuiton.topia.persistence.TopiaEntity; + +/** + * FavoriteParticipant + * + * Created: 28 avr. 2010 + * + * @author fdesbois + */ +public class FavoriteParticipantProperty extends PropertyNameProviderImpl + implements ParticipantProperty { + + public FavoriteParticipantProperty(String mainAlias) { + super(FavoriteParticipant.class, mainAlias); + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,14 @@ + +package org.chorem.pollen.entity; + +/** + * ParticipantListProperty + * + * Created: 28 avr. 2010 + * + * @author fdesbois + */ +public interface ParticipantListProperty extends PropertyNameProvider { + + String namePropertyParticipant(); +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,13 @@ + +package org.chorem.pollen.entity; + +/** + * ParticipantProperty + * + * Created: 28 avr. 2010 + * + * @author fdesbois + */ +public interface ParticipantProperty extends PropertyNameProvider { + +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Deleted: 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-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -1,27 +0,0 @@ - -package org.chorem.pollen.entity; - -/** - * PollAccountImpl - * - * Created: 26 avr. 2010 - * - * @author fdesbois - */ -public class PollAccountImpl extends PollAccountAbstract { - - private static final long serialVersionUID = 1L; - - @Override - public PollAccount getChildByUId(String UId) { - if (child != null) { - for (PollAccount account : child) { - if (account.getUid().equals(UId)) { - return account; - } - } - } - return null; - } - -} Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -9,19 +9,13 @@ * @author fdesbois * @since 2.0 */ -public class PollAccountProperty extends EntityProperty implements PropertyUid { +public class PollAccountProperty extends PropertyNameProviderImpl { public PollAccountProperty(String mainAlias) { - super(mainAlias); + super(PollAccount.class, mainAlias); } - @Override - public String namePropertyUid() { - return nameProperty(PollAccount.UID); - } - public String namePropertyChild() { return nameProperty(PollAccount.CHILD); } - } Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java (from rev 2976, trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java) =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,26 @@ + +package org.chorem.pollen.entity; + +import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.persistence.TopiaEntity; + +/** + * PropertyUid + * + * Created: 27 avr. 2010 + * + * @author fdesbois + * @since 2.0 + */ +public interface PropertyNameProvider { + + String name(); + + String namePropertyId(); + + String nameProperty(String propertyName); + + Class<? extends TopiaEntity> getEntityClass(); + + TopiaQuery newQuery(); +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: svn:mergeinfo + Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java (from rev 2976, trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java) =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,110 @@ + +package org.chorem.pollen.entity; + +import org.nuiton.topia.framework.*; +import org.nuiton.topia.persistence.TopiaEntity; + +/** + * EntityProperty is used to simplify property concatenation in TopiaQuery. + * The usage is simple, the EntityProperty 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); + * + * // Property used in the query + * EntityProperty boatProperty = new EntityProperty("B"); + * + * // It's better to create the query with the property name + * TopiaQuery query = dao.createQuery(boatProperty.name()); + * + * // The property NAME of the boat need to be find equals to "ULUBERLU" + * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU"); + * + * // 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 : + * <pre> + * public class BoatProperty extends EntityProperty { + * + * public BoatProperty(String mainAlias) { + * super(mainAlias); + * } + * + * public String namePropertyName() { + * return nameProperty(Boat.NAME); + * } + * } + * </pre> + * + * Created: 14 avr. 2010 + * + * @author fdesbois <fdesbois@codelutin.com> + */ +public class PropertyNameProviderImpl implements PropertyNameProvider { + + /** alias of the entity **/ + protected String mainAlias; + + protected Class<? extends TopiaEntity> entityClass; + + public PropertyNameProviderImpl(Class<? extends TopiaEntity> entityClass, + String mainAlias) { + this.mainAlias = mainAlias; + this.entityClass = entityClass; + } + + public void setMainAlias(String mainAlias) { + this.mainAlias = mainAlias; + } + + public void setEntityClass(Class<? extends TopiaEntity> entityClass) { + this.entityClass = entityClass; + } + + /** + * Name the entity as a property for a TopiaQuery. + * + * @return the entity name used as a TopiaQuery property + */ + @Override + public String name() { + return mainAlias; + } + + /** + * Name a property from the Entity for a TopiaQuery. + * + * @param propertyName to named in the TopiaQuery + * @return the property name used as a TopiaQuery property + */ + @Override + public String nameProperty(String propertyName) { + return TopiaQuery.getProperty(mainAlias, propertyName); + } + + @Override + public String namePropertyId() { + return nameProperty(TopiaEntity.TOPIA_ID); + } + + @Override + public Class<? extends TopiaEntity> getEntityClass() { + return entityClass; + } + + @Override + public TopiaQuery newQuery() { + return new TopiaQuery(getEntityClass(), name()); + } + + @Override + public String toString() { + return name(); + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: svn:mergeinfo + Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -1,15 +0,0 @@ - -package org.chorem.pollen.entity; - -/** - * PropertyUid - * - * Created: 27 avr. 2010 - * - * @author fdesbois - * @since 2.0 - */ -public interface PropertyUid { - - String namePropertyUid(); -} Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -40,13 +40,7 @@ this.newPassword = newPassword; } - @Override - public void addFavoriteList(PollAccount list) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override public String getDisplayName() { String name = ""; String separator = ""; Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -6,16 +6,24 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.PollenBinderHelper; import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.PollenBusinessException.PollenExceptionType; import org.chorem.pollen.PollenContext; import org.chorem.pollen.PollenDAOHelper; import org.chorem.pollen.PollenException; import org.chorem.pollen.bean.Filter; +import org.chorem.pollen.entity.FavoriteList; +import org.chorem.pollen.entity.FavoriteListDAO; +import org.chorem.pollen.entity.FavoriteListImpl; +import org.chorem.pollen.entity.FavoriteListProperty; +import org.chorem.pollen.entity.FavoriteParticipant; +import org.chorem.pollen.entity.FavoriteParticipantDAO; +import org.chorem.pollen.entity.FavoriteParticipantImpl; +import org.chorem.pollen.entity.FavoriteParticipantProperty; +import org.chorem.pollen.entity.ParticipantListProperty; +import org.chorem.pollen.entity.ParticipantProperty; import org.chorem.pollen.entity.PollAccount; -import org.chorem.pollen.entity.PollAccountDAO; -import org.chorem.pollen.entity.PollAccountImpl; -import org.chorem.pollen.entity.PollAccountProperty; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; import org.chorem.pollen.entity.UserAccountImpl; @@ -23,6 +31,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderBuilder; import org.nuiton.util.beans.BinderProvider; @@ -48,7 +57,6 @@ public void setContext(PollenContext context) { this.context = context; - prepareUserAccountBinder(); prepareFavoriteListBinder(); } @@ -68,14 +76,6 @@ context.closeTransaction(transaction); } - protected void prepareUserAccountBinder() { - BinderBuilder builder = new BinderBuilder(UserAccount.class, - UserAccount.ADMIN, - UserAccount.FIRST_NAME, - UserAccount.LAST_NAME); - BinderProvider.registerBinder(builder); - } - protected void prepareFavoriteListBinder() { BinderBuilder builder = new BinderBuilder(PollAccount.class, PollAccount.LIST, @@ -93,7 +93,13 @@ * @see org.nuiton.util.beans.Binder#copy(Object, Object, String...) */ protected void copyUserAccount(UserAccount source, UserAccount destination) { - BinderProvider.getBinder(UserAccount.class).copy(source, destination); + TopiaEntityBinder<UserAccount> binder = + PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class); + + binder.copy(source, destination, UserAccount.ADMIN, + UserAccount.FIRST_NAME, + UserAccount.LAST_NAME); + // Don't keep case for email destination.setEmail(StringUtils.lowerCase(source.getEmail())); // Manage new password if needed String password = source.getNewPassword(); @@ -296,134 +302,153 @@ return result; } + /** + * Create a TopiaQuery to find all participants of a list with + * {@code filter} constraints (order, limit indexes, listId). + * + * @param filter used to add constraint in the query + * @param participantPropertyProvider + * @param listPropertyProvider + * @return the TopiaQuery created + * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid) + */ + protected TopiaQuery createQueryFindParticipantsByList( + Filter filter, + ParticipantProperty participantPropertyProvider, + ParticipantListProperty listPropertyProvider) { + + // Instanciate a new query based on participant + TopiaQuery query = participantPropertyProvider.newQuery(); + + // Add the list in the From of the query + query.addFrom(listPropertyProvider.getEntityClass(), listPropertyProvider.name()); + + // Add the link between the list and the participant + query.addInElements(participantPropertyProvider.name(), + listPropertyProvider.namePropertyParticipant()); + + // Add constraints from filter, the listProperty is given to provide + // the name of its ID property. + filter.prepareQuery(query, listPropertyProvider); + + return query; + } + @Override - protected PollAccount executeGetNewList(UserAccount user) { - PollAccount result = new PollAccountImpl(); - result.setList(true); + protected FavoriteList executeGetNewFavoriteList(UserAccount user) { + FavoriteList result = new FavoriteListImpl(); result.setUserAccount(user); return result; } @Override protected void executeCreateFavoriteList(TopiaContext transaction, - PollAccount list) throws TopiaException, PollenBusinessException { + FavoriteList list) throws TopiaException, PollenBusinessException { - PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction); - - // check favoriteList name exist for user - UserAccount user = list.getUserAccount(); - int count = dao.createQuery(). - add(PollAccount.LIST, true). - add(PollAccount.USER_ACCOUNT, user). - add(PollAccount.NAME, list.getName()). - executeCount(); - // existing list found - if (count > 0) { - throw new PollenBusinessException( - PollenExceptionType.FAVORITE_LIST_NAME_EXIST, - list.getName(), user.getDisplayName()); - } - - // Create unique Id for the new List - String UId = context.createPollenUrlId(); - PollAccount newList = dao.create(UId); - BinderProvider.getBinder(PollAccount.class, - BINDER_CONTEXT_FAVORITE_LIST). - copy(list, newList); - dao.update(newList); - - transaction.commitTransaction(); +// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction); +// +// // check favoriteList name exist for user +// UserAccount user = list.getUserAccount(); +// int count = dao.createQuery(). +// add(PollAccount.LIST, true). +// add(PollAccount.USER_ACCOUNT, user). +// add(PollAccount.NAME, list.getName()). +// executeCount(); +// // existing list found +// if (count > 0) { +// throw new PollenBusinessException( +// PollenExceptionType.FAVORITE_LIST_NAME_EXIST, +// list.getName(), user.getDisplayName()); +// } +// +// // Create unique Id for the new List +// String UId = context.createPollenUrlId(); +// PollAccount newList = dao.create(UId); +// BinderProvider.getBinder(PollAccount.class, +// BINDER_CONTEXT_FAVORITE_LIST). +// copy(list, newList); +// dao.update(newList); +// +// transaction.commitTransaction(); } @Override - protected void executeDeleteList(TopiaContext transaction, - PollAccount list) throws TopiaException { + protected void executeDeleteFavoriteList(TopiaContext transaction, + FavoriteList list) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected List<PollAccount> executeGetFavoriteLists( + protected List<FavoriteList> executeGetFavoriteLists( TopiaContext transaction, UserAccount user) throws TopiaException { - PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction); + FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction); - TopiaQuery query = dao.createQuery(). - add(PollAccount.LIST, true). - add(PollAccount.USER_ACCOUNT, user); + List<FavoriteList> results = dao.findAllByUserAccount(user); - List<PollAccount> results = dao.findAllByQuery(query); - return results; } @Override - protected PollAccount executeGetNewAccount(TopiaContext transaction) + protected FavoriteParticipant executeGetNewFavoriteParticipant( + TopiaContext transaction, FavoriteList list) throws TopiaException { - PollAccount result = new PollAccountImpl(); + FavoriteParticipant result = new FavoriteParticipantImpl(); + result.setFavoriteList(list); return result; } @Override - protected PollAccount executeGetPerson(TopiaContext transaction, - String accountUId) + protected void executeCreateFavoriteParticipant(TopiaContext transaction, + FavoriteParticipant participant) throws PollenBusinessException, TopiaException { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected Map<String, PollAccount> executeGetAccounts( + protected void executeDeleteFavoriteParticipant(TopiaContext transaction, + FavoriteParticipant participant) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + protected void executeUpdateFavoriteParticipant(TopiaContext transaction, + FavoriteParticipant participant) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants( TopiaContext transaction, Filter filter) throws TopiaException { + + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(transaction); - PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction); + ParticipantProperty participantProperty = + new FavoriteParticipantProperty("P"); - TopiaQuery query = createQueryFindAccountsByList(dao, filter); + ParticipantListProperty listProperty = new FavoriteListProperty("L"); - Map<String, PollAccount> results = dao.findAllMappedByQuery(query, - PollAccount.UID, String.class); + TopiaQuery query = createQueryFindParticipantsByList(filter, + participantProperty, listProperty); + Map<String, FavoriteParticipant> results = dao.findAllMappedByQuery( + query, FavoriteParticipant.EMAIL, String.class); + return results; } @Override - protected int executeGetNbAccounts(TopiaContext transaction, + protected int executeGetNbFavoriteParticipants(TopiaContext transaction, Filter filter) throws TopiaException { + throw new UnsupportedOperationException("Not supported yet."); - PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction); - - TopiaQuery query = createQueryFindAccountsByList(dao, filter); - - int result = query.executeCount(); - return result; +// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction); +// +// TopiaQuery query = createQueryFindAccountsByList(dao, filter); +// +// int result = query.executeCount(); +// return result; } - /** - * Create a TopiaQuery to find all the accounts of a list with - * {@code filter} constraints (order, limit indexes, uid). - * - * @param dao used to create the query - * @param filter used to add constraint in the query - * @return the TopiaQuery created - * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid) - */ - protected TopiaQuery createQueryFindAccountsByList(PollAccountDAO dao, - Filter filter) { - - // Property for account to find - PollAccountProperty accountProperty = new PollAccountProperty("A"); - // Property for list reference that contains the accounts - PollAccountProperty listProperty = new PollAccountProperty("L"); - - TopiaQuery query = dao.createQuery(accountProperty.name()); - query.addFrom(PollAccount.class, listProperty.name()); - query.addInElements(accountProperty.name(), - listProperty.namePropertyChild()); - // query.add("A IN elements(L." + PollAccount.CHILD + ")"); - - // Add constraints from filter, the listProperty is given to provide - // the name of its UID property. - filter.prepareQuery(query, listProperty); - - return query; - } - } 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-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-28 08:47:44 UTC (rev 2977) @@ -36,22 +36,30 @@ pollen.error.serviceUser.connect= pollen.error.serviceUser.createDefaultAdmin= pollen.error.serviceUser.createFavoriteList= +pollen.error.serviceUser.createFavoriteParticipant= pollen.error.serviceUser.createList= pollen.error.serviceUser.createUpdateList= pollen.error.serviceUser.createUpdateUser= pollen.error.serviceUser.createUser= +pollen.error.serviceUser.deleteFavoriteList= +pollen.error.serviceUser.deleteFavoriteParticipant= pollen.error.serviceUser.deleteList= pollen.error.serviceUser.deleteUser= pollen.error.serviceUser.getAccounts= pollen.error.serviceUser.getFavoriteLists= +pollen.error.serviceUser.getFavoriteParticipants= pollen.error.serviceUser.getNbAccounts= +pollen.error.serviceUser.getNbFavoriteParticipants= pollen.error.serviceUser.getNbUsers= pollen.error.serviceUser.getNewAccount= +pollen.error.serviceUser.getNewFavoriteList= +pollen.error.serviceUser.getNewFavoriteParticipant= pollen.error.serviceUser.getNewList= pollen.error.serviceUser.getNewPerson= pollen.error.serviceUser.getNewUser= pollen.error.serviceUser.getPerson= pollen.error.serviceUser.getUsers= +pollen.error.serviceUser.updateFavoriteParticipant= pollen.error.serviceUser.updateUser= pollen.error.serviceVote.getVote= pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s 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-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-28 08:47:44 UTC (rev 2977) @@ -35,22 +35,30 @@ pollen.error.serviceUser.connect=Impossible d'\u00E9tablir la connexion pour l'identifiant %1$s et le mot de passe encod\u00E9 %2$s pollen.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut \: %1$s (%2$s) pollen.error.serviceUser.createFavoriteList= +pollen.error.serviceUser.createFavoriteParticipant= pollen.error.serviceUser.createList= pollen.error.serviceUser.createUpdateList= pollen.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er l'utilisateur '%1$s' <%2$s> (admin \= %$3b) pollen.error.serviceUser.createUser= +pollen.error.serviceUser.deleteFavoriteList= +pollen.error.serviceUser.deleteFavoriteParticipant= pollen.error.serviceUser.deleteList= pollen.error.serviceUser.deleteUser= pollen.error.serviceUser.getAccounts= pollen.error.serviceUser.getFavoriteLists= +pollen.error.serviceUser.getFavoriteParticipants= pollen.error.serviceUser.getNbAccounts= +pollen.error.serviceUser.getNbFavoriteParticipants= pollen.error.serviceUser.getNbUsers= pollen.error.serviceUser.getNewAccount= +pollen.error.serviceUser.getNewFavoriteList= +pollen.error.serviceUser.getNewFavoriteParticipant= pollen.error.serviceUser.getNewList= pollen.error.serviceUser.getNewPerson= pollen.error.serviceUser.getNewUser=Impossible d'instancier un nouvel utilisateur. pollen.error.serviceUser.getPerson= pollen.error.serviceUser.getUsers= +pollen.error.serviceUser.updateFavoriteParticipant= pollen.error.serviceUser.updateUser= pollen.error.serviceVote.getVote= pollen.error.serviceVote.getVotesByPoll= Modified: trunk/pollen-business/src/main/xmi/pollen.properties =================================================================== --- trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-28 08:47:44 UTC (rev 2977) @@ -7,4 +7,10 @@ org.chorem.pollen.entity.UserAccount.attribute.login.tagvalue.naturalId=true org.chorem.pollen.entity.UserAccount.attribute.email.tagvalue.unique=true -org.chorem.pollen.entity.PollAccount.attribute.uid.tagvalue.naturalId=true \ No newline at end of file +org.chorem.pollen.entity.PollAccount.attribute.uid.tagvalue.naturalId=true + +org.chorem.pollen.entity.FavoriteList.attribute.userAccount.tagvalue.naturalId=true +org.chorem.pollen.entity.FavoriteList.attribute.name.tagvalue.naturalId=true + +org.chorem.pollen.entity.FavoriteParticipant.attribute.favoriteList.tagvalue.naturalId=true +org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.naturalId=true \ No newline at end of file Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Modified: trunk/pollen-ui/pom.xml =================================================================== --- trunk/pollen-ui/pom.xml 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/pom.xml 2010-04-28 08:47:44 UTC (rev 2977) @@ -174,9 +174,9 @@ </plugins> </build> - <repositories> + <!--<repositories> - <!-- chenillekit Repository --> + chenillekit Repository <repository> <id>chenillekit</id> <url>http://www.chenillekit.org/mvnrepo/release</url> @@ -185,13 +185,13 @@ </snapshots> </repository> - <!-- Maven Java.net 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> + </repositories>--> </project> Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -10,7 +10,7 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.PollenBusinessException.PollenExceptionType; -import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.FavoriteList; import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.base.PollenPage; import org.chorem.pollen.ui.services.PollenManager; @@ -44,7 +44,7 @@ /** Properties **/ @Property - private PollAccount newFavoriteList; + private FavoriteList newFavoriteList; /** Components injected **/ @InjectComponent @@ -62,7 +62,8 @@ if (logger.isDebugEnabled()) { logger.debug("User connected : " + page.getUserConnected()); } - newFavoriteList = serviceUser.getNewList(page.getUserConnected()); + newFavoriteList = + serviceUser.getNewFavoriteList(page.getUserConnected()); } } 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-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -2,19 +2,20 @@ package org.chorem.pollen.ui.components; import java.util.List; -import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.ComponentResources; -import org.apache.tapestry5.ValidationException; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.annotations.Inject; +import org.chorem.pollen.bean.Filter; +import org.chorem.pollen.entity.FavoriteList; +import org.chorem.pollen.entity.FavoriteParticipant; import org.chorem.pollen.entity.PollAccount; -import org.chorem.pollen.entity.PollAccountImpl; import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.data.EvenOdd; +import org.chorem.pollen.ui.data.FavoriteParticipantDataSource; import org.slf4j.Logger; /** @@ -43,17 +44,19 @@ @Inject private ServiceUser serviceUser; - @Persist @Property - private PollAccount favoriteListSelected; + private FavoriteList favoriteListSelected; private EvenOdd evenOdd; + @Persist + private FavoriteParticipantDataSource accounts; + @Property - private PollAccount account; + private FavoriteParticipant account; @Property - private PollAccount newAccount; + private FavoriteParticipant newAccount; @InjectComponent private Zone updateZone; @@ -73,32 +76,28 @@ return favoriteListSelected != null; } + public FavoriteParticipantDataSource getAccounts() { + if (accounts == null) { + Filter filter = new Filter(); + filter.setReference(favoriteListSelected); + accounts = new FavoriteParticipantDataSource(serviceUser, filter); + } + return accounts; + } + void onActionFromRemoveAccount(String UId) { - PollAccount child = favoriteListSelected.getChildByUId(UId); - favoriteListSelected.removeChild(child); + // NEED DELETE ACCOUNT FOR LIST } void onPrepareFromAddAccount() { if (newAccount == null) { - // TEMP - newAccount = new PollAccountImpl(); + newAccount = + serviceUser.getNewFavoriteParticipant(favoriteListSelected); } } -// void onValidateFromEmail(String input) throws ValidationException { -// String test = StringUtils.lowerCase(input); -// for (PollAccount curr : favoriteListSelected.getChild()) { -// if (test.equals(curr.getEmail())) { -// throw new ValidationException("NOT ALLOWED"); -// } -// } -// } - Object onSuccessFromAddAccount() { - favoriteListSelected.addChild(newAccount); - if (logger.isDebugEnabled()) { - logger.debug("Add account : " + newAccount); - } + // NEED CREATE ACCOUNT FOR LIST return updateZone.getBody(); } } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -26,6 +26,7 @@ package org.chorem.pollen.ui.data; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import org.apache.commons.collections.CollectionUtils; @@ -55,8 +56,6 @@ private Map<K, E> mapResults; - private List<E> listResults; - private int nbRows = -1; private int nbRowsPerPage; @@ -84,10 +83,7 @@ nbRowsPerPage = endIndex - startIndex + 1; try { mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints)); - listResults = new ArrayList<E>(mapResults.values()); - // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats - //sortResults(sortConstraints); } catch (PollenException eee) { throw new TapestryException("", eee); } @@ -127,70 +123,17 @@ } return filterOrder; } - -// protected void sortResults(List<SortConstraint> sortConstraints) { -// -// for (SortConstraint constraint : sortConstraints) -// { -// final ColumnSort sort = constraint.getColumnSort(); -// -// if (sort == ColumnSort.UNSORTED) continue; -// -// final PropertyConduit conduit = constraint.getPropertyModel().getConduit(); -// -// final Comparator valueComparator = new Comparator<Comparable>() -// { -// public int compare(Comparable o1, Comparable o2) -// { -// // Simplify comparison, and handle case where both are nulls. -// -// if (o1 == o2) return 0; -// -// if (o2 == null) return 1; -// -// if (o1 == null) return -1; -// -// return o1.compareTo(o2); -// } -// }; -// -// final Comparator rowComparator = new Comparator() -// { -// public int compare(Object row1, Object row2) -// { -// Comparable value1 = (Comparable) conduit.get(row1); -// Comparable value2 = (Comparable) conduit.get(row2); -// -// return valueComparator.compare(value1, value2); -// } -// }; -// -// final Comparator reverseComparator = new Comparator() -// { -// public int compare(Object o1, Object o2) -// { -// int modifier = sort == ColumnSort.ASCENDING ? 1 : -1; -// -// return modifier * rowComparator.compare(o1, o2); -// } -// }; -// -// // We can freely sort this list because its just a copy. -// -// Collections.sort(listResults, reverseComparator); -// } -// } - + @Override public Object getRowValue(int index) { index = index % nbRowsPerPage; - if (index >= listResults.size()) { + if (index >= mapResults.size()) { if (log.isErrorEnabled()) { - log.error("Size error : " + index + " / " + listResults.size()); + log.error("Size error : " + index + " / " + mapResults.size()); } return null; } - return CollectionUtils.get(listResults, index); + return CollectionUtils.get(mapResults, index); } @Override @@ -200,8 +143,8 @@ return mapResults.get(key); } - public List<E> values() { - return listResults; + public Collection<E> values() { + return mapResults.values(); } public boolean contains(K key) { Added: 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 (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -0,0 +1,55 @@ + +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.entity.PollAccount; +import org.chorem.pollen.service.ServiceUser; + +/** + * UserAccountDataSource + * + * Created: 23 avr. 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class FavoriteParticipantDataSource extends + AbstractMappedGridDataSource<String, FavoriteParticipant> { + + private ServiceUser service; + + private Filter filter; + + public FavoriteParticipantDataSource(ServiceUser 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)); + return service.getFavoriteParticipants(filter); + } + + @Override + protected int count() throws PollenException { + return service.getNbFavoriteParticipants(filter); + } + + @Override + public Class<?> getRowType() { + return PollAccount.class; + } + +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -1092,12 +1092,16 @@ if (pollAccount == null) { // Identification du votant if (uri.getAccountUId() != null) { - pollAccount = serviceUser.getPerson(uri.getAccountUId()); + // pollAccount = serviceUser.getPerson(uri.getAccountUId()); + + // pollAccountId = pollAccount.getId(); } if (pollAccount == null) { // pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO(); + + // if (userExists) { // if (user.getFirstName() != null && user.getLastName() != null) { // pollAccount.setVotingId( 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-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-04-28 08:47:44 UTC (rev 2977) @@ -22,18 +22,13 @@ import org.apache.tapestry5.annotations.IncludeStylesheet; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; -import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.FavoriteList; import org.chorem.pollen.service.ServiceUser; 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.EvenOdd; -import org.chorem.pollen.ui.services.PollenManager; -import org.slf4j.Logger; /** * Classe de la page d'affichage des listes de votants favorites de @@ -59,7 +54,7 @@ @Inject private ServiceUser serviceUser; - private List<PollAccount> favoriteLists; + private List<FavoriteList> favoriteLists; @Override public Border getBorder() { @@ -80,7 +75,7 @@ return AddressBar.newBar().appendCurrent(title); } - public List<PollAccount> getFavoriteLists() { + public List<FavoriteList> getFavoriteLists() { if (favoriteLists == null) { favoriteLists = serviceUser.getFavoriteLists(getUserConnected()); } Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-28 08:47:44 UTC (rev 2977) @@ -1,19 +1,19 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> - <t:zone t:id="updateZone" show="show" update="show"> - <form t:type="form" t:id="selectListForm" action="tapestry"> - <div> - ${message:listSelect-label}: - <select t:id="listSelect" t:type="ck/beanSelect" t:list="source" t:value="favoriteListSelected" - t:labelField="literal:name" t:valueField="literal:name" /> - <input t:type="submit" value="${message:pollen.ui.button.ok}"/> - </div> - </form> + <form t:type="form" t:id="selectListForm" action="tapestry"> + <div> + ${message:listSelect-label}: + <select t:id="listSelect" t:type="ck/beanSelect" t:list="source" t:value="favoriteListSelected" + t:labelField="literal:name" t:valueField="literal:name" /> + <input t:type="submit" value="${message:pollen.ui.button.ok}"/> + </div> + </form> - <t:if test="canDisplayAccounts()"> + <t:if test="canDisplayAccounts()"> + <t:zone t:id="updateZone" show="show" update="show"> <!-- Display all Accounts child of favoriteListSelected --> - <div t:type="grid" t:source="favoriteListSelected.child" t:row="account" + <div t:type="grid" t:source="accounts.values()" t:row="account" t:include="name, email, weight" t:add="actions" t:rowsPerPage="20" t:rowClass="prop:evenodd.next" t:inPlace="true"> <p:actionsCell> @@ -40,6 +40,7 @@ <input t:type="textfield" t:id="weight" t:value="newAccount.weight" size="5"/> </td> <td class="functions"> + <input t:type="hidden" value="newAccount.list" /> <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addAccount}"/> </td> </tr> @@ -48,16 +49,16 @@ </form> <!-- Delete the favoriteListSelected --> -<!-- <p> - <a t:type="actionlink" t:id="deleteList"> - <img src="${asset:context:img/delete.png}" alt="Delete"/>${message:deleteList} - </a> - </p>--> + <!-- <p> + <a t:type="actionlink" t:id="deleteList"> + <img src="${asset:context:img/delete.png}" alt="Delete"/>${message:deleteList} + </a> + </p>--> - <p:else> - ${message:pollen.ui.list.update.notSelected} - </p:else> - </t:if> + </t:zone> - </t:zone> + <p:else> + ${message:pollen.ui.list.update.notSelected} + </p:else> + </t:if> </body> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-27 16:29:41 UTC (rev 2976) +++ trunk/pom.xml 2010-04-28 08:47:44 UTC (rev 2977) @@ -134,7 +134,7 @@ <dependency> <groupId>rome</groupId> <artifactId>rome</artifactId> - <version>1.0</version> + <version>0.9</version> </dependency> <dependency> <groupId>com.h2database</groupId>
participants (1)
-
fdesbois@users.chorem.org