r2981 - in trunk: pollen-business/src/main/java/org/chorem/pollen pollen-business/src/main/java/org/chorem/pollen/entity pollen-business/src/main/java/org/chorem/pollen/service pollen-business/src/main/xmi pollen-business/src/test/java/org/chorem/pollen pollen-business/src/test/java/org/chorem/pollen/business pollen-business/src/test/java/org/chorem/pollen/service pollen-ui/src/main/java/org/chorem/pollen/ui/components pollen-ui/src/main/java/org/chorem/pollen/ui/data pollen-ui/src/main/res
Author: fdesbois Date: 2010-04-30 10:47:02 +0200 (Fri, 30 Apr 2010) New Revision: 2981 Url: http://chorem.org/repositories/revision/pollen/2981 Log: Continue UserLists managment... Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java Removed: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 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/TopiaQueryBuilderTest.java trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.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/data/FavoriteParticipantDataSource.java trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java ___________________________________________________________________ Modified: svn:keywords - "Author Date Id Revision HeadURL" + Id Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java ___________________________________________________________________ Modified: svn:keywords - "Author Date Id Revision HeadURL" + Author Date Id Revision HeadURL Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java ___________________________________________________________________ Modified: svn:keywords - "Author Date Id Revision HeadURL" + Author Date Id Revision HeadURL 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-04-30 08:47:02 UTC (rev 2981) @@ -0,0 +1,24 @@ + +package org.chorem.pollen.entity; + +/** + * FavoriteParticipantImpl + * + * Created: 28 avr. 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class FavoriteParticipantImpl extends FavoriteParticipantAbstract { + + private static final long serialVersionUID = 1L; + + @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/service/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -57,7 +57,6 @@ public void setContext(PollenContext context) { this.context = context; - prepareFavoriteListBinder(); } @Override @@ -76,14 +75,6 @@ context.closeTransaction(transaction); } - protected void prepareFavoriteListBinder() { - BinderBuilder builder = new BinderBuilder(PollAccount.class, - PollAccount.LIST, - PollAccount.NAME, - PollAccount.USER_ACCOUNT); - BinderProvider.registerBinder(builder, BINDER_CONTEXT_FAVORITE_LIST); - } - /** * Copy {@code source} user account to {@code destination} one. * The email is lower cased in the {@code destination} user account. @@ -227,7 +218,7 @@ // Execute create UserAccount newUser = dao.create(user.getLogin()); copyUserAccount(user, newUser); - user.setTopiaId(newUser.getTopiaId()); +// user.setTopiaId(newUser.getTopiaId()); transaction.commitTransaction(); } @@ -318,9 +309,8 @@ // 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()). + add(FavoriteList.USER_ACCOUNT, user). + add(FavoriteList.NAME, list.getName()). executeCount(); // existing list found if (count > 0) { @@ -329,13 +319,10 @@ list.getName(), user.getDisplayName()); } - // Create unique Id for the new List - String UId = context.createPollenUrlId(); - FavoriteList newList = dao.create(UId); - BinderProvider.getBinder(FavoriteList.class, - BINDER_CONTEXT_FAVORITE_LIST). - copy(list, newList); - dao.update(newList); + FavoriteList newList = dao.create( + FavoriteList.USER_ACCOUNT, list.getUserAccount(), + FavoriteList.NAME, list.getName()); +// list.setTopiaId(newList.getTopiaId()); transaction.commitTransaction(); } @@ -363,6 +350,7 @@ throws TopiaException { FavoriteParticipant result = new FavoriteParticipantImpl(); result.setFavoriteList(list); + result.setWeight(1.); return result; } @@ -370,7 +358,36 @@ protected void executeCreateFavoriteParticipant(TopiaContext transaction, FavoriteParticipant participant) throws PollenBusinessException, TopiaException { - throw new UnsupportedOperationException("Not supported yet."); + + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(transaction); + + FavoriteList list = participant.getFavoriteList(); +// int count = dao.createQuery(). +// add(FavoriteParticipant.FAVORITE_LIST, list). +// add(FavoriteParticipant.NAME, participant.getName()). +// add(FavoriteParticipant.EMAIL, participant.getEmail()). +// executeCount(); +// // existing participant found +// if (count > 0) { +// throw new PollenBusinessException( +// PollenExceptionType.FAVORITE_PARTICIPANT_EXIST, +// list.getName(), list.getName()); +// } + + // Create newParticipant with naturalId + FavoriteParticipant newParticipant = + dao.create(FavoriteParticipant.FAVORITE_LIST, list, + FavoriteParticipant.NAME, participant.getName(), + FavoriteParticipant.EMAIL, participant.getEmail()); + + // Set other field + newParticipant.setWeight(participant.getWeight()); + + // Update input participant with new topiaId +// participant.setTopiaId(newParticipant.getTopiaId()); + + transaction.commitTransaction(); } @Override @@ -397,9 +414,17 @@ FavoriteParticipantDAO dao = PollenDAOHelper.getFavoriteParticipantDAO(transaction); - Map<String, FavoriteParticipant> results = dao.findAllMappedByQuery( - query, FavoriteParticipant.EMAIL, String.class); + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } + Map<String, FavoriteParticipant> results = + dao.findAllMappedByQuery(query); + + if (log.isDebugEnabled()) { + log.debug("Results : " + results); + } + return results; } Modified: trunk/pollen-business/src/main/xmi/pollen.properties =================================================================== --- trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-30 08:47:02 UTC (rev 2981) @@ -13,4 +13,6 @@ 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 +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 \ No newline at end of file Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java ___________________________________________________________________ Modified: svn:keywords - "Author Date Id Revision HeadURL" + Author Date Id Revision HeadURL Copied: trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java (from rev 2973, trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java) =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java (rev 0) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -0,0 +1,143 @@ + +package org.chorem.pollen.business; + +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.UserAccount; +import org.chorem.pollen.entity.UserAccountDAO; +import org.chorem.pollen.service.ServiceUserImpl; +import org.junit.After; +import org.junit.Ignore; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; +import org.nuiton.util.ApplicationConfig; + +/** + * TestManager + * + * Created: 24 févr. 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +@Ignore +public class AbstractServiceTest { + + private static final Log log = LogFactory.getLog(AbstractServiceTest.class); + + protected PollenContext context; + + protected ServiceUserImpl serviceUser; + + 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; + } + + 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 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@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@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(); + } + } + +} Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: svn:mergeinfo + Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java 2010-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -20,7 +20,7 @@ public void execute() throws Exception { transaction = null; try { - transaction = TestManager.beginTransaction(); + //transaction = beginTransaction(); test(); Deleted: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -1,99 +0,0 @@ - -package org.chorem.pollen.business; - -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.PollenContext; -import org.chorem.pollen.PollenContextImpl; -import org.chorem.pollen.service.ServiceEmail; -import org.chorem.pollen.service.ServiceEmailImpl; -import org.chorem.pollen.service.ServicePoll; -import org.chorem.pollen.service.ServicePollImpl; -import org.chorem.pollen.service.ServiceUser; -import org.chorem.pollen.service.ServiceUserImpl; -import org.junit.Ignore; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaException; -import org.nuiton.util.ApplicationConfig; - -/** - * TestManager - * - * Created: 24 févr. 2010 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -@Ignore -public class TestManager { - - private static final Log log = LogFactory.getLog(TestManager.class); - - private static PollenContext context; - - public static void start(String dbname) throws IOException { - log.info("## START ## : " + dbname); - - InputStream input = TestManager.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()); - } - - public static void stop() throws IOException { - getContext().stop(); - } - - public static PollenContext getContext() { - if (context == null) { - context = new PollenContextImpl(); - } - return context; - } - - public static TopiaContext beginTransaction() throws TopiaException { - return getContext().beginTransaction(); - } - - public static ServiceUserImpl getServiceUser() { - ServiceUserImpl instance = new ServiceUserImpl(); - instance.setContext(getContext()); - return instance; - } - - public static ServiceEmailImpl getServiceEmail() { - ServiceEmailImpl instance = new ServiceEmailImpl(); - instance.setContext(getContext()); - return instance; - } - - public static ServicePollImpl getServicePoll() { - ServicePollImpl instance = new ServicePollImpl(); - instance.setContext(getContext()); - return instance; - } - -} 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-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -1,22 +1,17 @@ package org.chorem.pollen.service; -import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.PollenBusinessException.PollenExceptionType; import org.chorem.pollen.PollenDAOHelper; import org.chorem.pollen.PollenException; -import org.chorem.pollen.business.TestManager; +import org.chorem.pollen.business.AbstractServiceTest; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; import org.chorem.pollen.entity.UserAccountImpl; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.nuiton.topia.TopiaContext; @@ -24,46 +19,24 @@ * * @author fdesbois */ -public class ServiceUserImplTest { +public class ServiceUserImplTest extends AbstractServiceTest { private static final Log log = LogFactory.getLog(ServiceUserImplTest.class); - - public ServiceUserImplTest() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() throws IOException { - TestManager.stop(); - } - + @Test public void testCopyUserAccount() throws Exception { - TestManager.start("testManageNewPassword"); - - ServiceUserImpl serviceUser = TestManager.getServiceUser(); + start("testManageNewPassword"); - UserAccount user = serviceUser.getNewUser(); + UserAccount user = getServiceUser().getNewUser(); user.setLogin("homer"); user.setNewPassword("wouhou"); log.info("test 1 : Encode new password"); UserAccount destination = new UserAccountImpl(); - serviceUser.copyUserAccount(user, destination); + getServiceUser().copyUserAccount(user, destination); Assert.assertNotNull(destination.getPassword()); - String expected = TestManager.getContext().encodePassword("wouhou"); + String expected = getContext().encodePassword("wouhou"); Assert.assertEquals(expected, destination.getPassword()); log.info("test 2 : Do not encode new password -> newPassword empty"); @@ -75,19 +48,16 @@ @Test public void testCheckPassword() throws Exception { - TestManager.start("testCheckPassword"); + start("testCheckPassword"); - ServiceUserImpl serviceUser = TestManager.getServiceUser(); - - UserAccount user = serviceUser.getNewUser(); + UserAccount user = getServiceUser().getNewUser(); user.setLogin("homer"); user.setNewPassword("wouhou"); - serviceUser.createUser(user); + getServiceUser().createUser(user); - String encodedPassword = - TestManager.getContext().encodePassword("wouhou"); + String encodedPassword = getContext().encodePassword("wouhou"); - TopiaContext transaction = TestManager.beginTransaction(); + TopiaContext transaction = beginTransaction(); try { UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); @@ -112,32 +82,28 @@ */ @Test public void testExecuteConnect() throws Exception { - TestManager.start("testExecuteConnect"); + start("testExecuteConnect"); - ServiceUser serviceUser = TestManager.getServiceUser(); + // The password is wouhou and login is homer + UserAccount user = createUser(false); - UserAccount user = serviceUser.getNewUser(); - user.setLogin("hsimpson"); - user.setEmail("hsimpson@springfield.us"); - user.setNewPassword("wouhou"); - serviceUser.createUser(user); - log.info("test 1 : Connection OK"); - UserAccount connected = serviceUser.connect("hsimpson", "wouhou"); + UserAccount connected = getServiceUser().connect("homer", "wouhou"); Assert.assertEquals(user, connected); log.info("test 2 : Connection problem on login -> user not exist"); try { - serviceUser.connect("homer", "wouhou"); + getServiceUser().connect("marge", "wouhou"); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_NOT_EXIST, eee.getType()); } - log.info("test 3 : Connection problem on password -> don't match with login"); + log.info("test 3 : Connection problem on password -> " + + "don't match with login"); try { - serviceUser.connect("hsimpson", "coucou"); + getServiceUser().connect("homer", "coucou"); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_WRONG_PASSWORD, @@ -150,10 +116,9 @@ */ @Test public void testExecuteGetNewUser() throws Exception { - TestManager.start("testGetNewUser"); - ServiceUser serviceUser = TestManager.getServiceUser(); + start("testGetNewUser"); - UserAccount user = serviceUser.getNewUser(); + UserAccount user = getServiceUser().getNewUser(); Assert.assertNotNull(user); Assert.assertEquals(false, user.getAdmin()); } @@ -163,31 +128,29 @@ */ @Test public void testExecuteCreateUser() throws Exception { - TestManager.start("testCreateUser"); - ServiceUser serviceUser = TestManager.getServiceUser(); + start("testCreateUser"); - UserAccount user = serviceUser.getNewUser(); + UserAccount user = getServiceUser().getNewUser(); user.setLogin("hsimpson"); user.setEmail("hsimpson@springfield.us"); user.setNewPassword("wouhou"); - String encodedPassword = - TestManager.getContext().encodePassword("wouhou"); + String encodedPassword = getContext().encodePassword("wouhou"); log.info("test 1 : Creation OK"); - serviceUser.createUser(user); - Assert.assertNotNull(user.getTopiaId()); + getServiceUser().createUser(user); + //Assert.assertNotNull(user.getTopiaId()); Assert.assertNotSame(encodedPassword, user.getPassword()); log.info("test 2 : Creation problem on login -> user exist"); - UserAccount user2 = serviceUser.getNewUser(); + UserAccount user2 = getServiceUser().getNewUser(); user2.setLogin("hsimpson"); // Not the same email user2.setEmail("hsimpson@springfield.com"); user2.setNewPassword("troubidou"); try { - serviceUser.createUser(user2); + getServiceUser().createUser(user2); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_LOGIN_EXIST, @@ -195,13 +158,13 @@ } log.info("test 3 : Creation problem on email -> user exist"); - UserAccount user3 = serviceUser.getNewUser(); + UserAccount user3 = getServiceUser().getNewUser(); user3.setLogin("homer"); user3.setEmail("hsimpson@springfield.us"); user3.setNewPassword("troubidou"); try { - serviceUser.createUser(user3); + getServiceUser().createUser(user3); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_EMAIL_EXIST, @@ -209,11 +172,11 @@ } log.info("test 4 : Creation OK with no email"); - UserAccount user4 = serviceUser.getNewUser(); + UserAccount user4 = getServiceUser().getNewUser(); user4.setLogin("marge"); user4.setNewPassword("troubidou"); - serviceUser.createUser(user4); + getServiceUser().createUser(user4); Assert.assertNull(user4.getEmail()); } @@ -222,27 +185,26 @@ */ @Test public void testExecuteUpdateUser() throws Exception { - TestManager.start("testUpdateUser"); - ServiceUser serviceUser = TestManager.getServiceUser(); + start("testUpdateUser"); - UserAccount user1 = serviceUser.getNewUser(); + UserAccount user1 = getServiceUser().getNewUser(); user1.setLogin("hsimpson"); user1.setEmail("hsimpson@springfield.us"); user1.setNewPassword("wouhou"); - serviceUser.createUser(user1); + getServiceUser().createUser(user1); - UserAccount user2 = serviceUser.getNewUser(); + UserAccount user2 = getServiceUser().getNewUser(); String user2Password = "wouhou"; user2.setLogin("homer"); user2.setEmail("hsimpson@springfield.fr"); user2.setNewPassword(user2Password); - serviceUser.createUser(user2); + getServiceUser().createUser(user2); log.info("test 1 : Can't change login -> don't match with password"); user2.setLogin("homersimpson"); user2.setPassword(user2Password); try { - serviceUser.updateUser(user2, false); + getServiceUser().updateUser(user2, false); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_WRONG_PASSWORD, @@ -253,13 +215,13 @@ log.info("test 2 : Change email OK"); user2.setEmail("homersimpson@springield.fr"); user2.setPassword(user2Password); - serviceUser.updateUser(user2, false); + getServiceUser().updateUser(user2, false); log.info("test 3 : Change email problem -> user exist"); user2.setEmail(user1.getEmail()); user2.setPassword(user2Password); try { - serviceUser.updateUser(user2, false); + getServiceUser().updateUser(user2, false); } catch (PollenBusinessException eee) { log.error("Error : " + eee.getMessage()); Assert.assertEquals(PollenExceptionType.USER_EMAIL_EXIST, @@ -275,26 +237,25 @@ */ @Test public void testExecuteDeleteUser() throws Exception { - TestManager.start("testUpdateUser"); - ServiceUser serviceUser = TestManager.getServiceUser(); + start("testUpdateUser"); try { - serviceUser.deleteUser("test"); + getServiceUser().deleteUser("test"); } catch (PollenException eee) { log.error(eee); Assert.assertEquals(IllegalArgumentException.class, eee.getCause().getClass()); } - UserAccount user = serviceUser.getNewUser(); + UserAccount user = getServiceUser().getNewUser(); user.setLogin("user"); - serviceUser.createUser(user); + getServiceUser().createUser(user); - serviceUser.deleteUser("user"); + getServiceUser().deleteUser("user"); TopiaContext transaction = null; try { - transaction = TestManager.beginTransaction(); + transaction = beginTransaction(); UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction); UserAccount userFound = dao.findByLogin("user"); Assert.assertNull(userFound); @@ -303,60 +264,14 @@ } } - /** - * Test of executeGetUsers method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteGetUsers() throws Exception { - System.out.println("executeGetUsers"); - } + @Test + public void testCreateFavoriteParticipant() throws Exception { + start("testCreateFavoriteParticipant"); + + UserAccount user = createUser(false); - /** - * Test of executeGetNewList method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteGetNewList() throws Exception { - System.out.println("executeGetNewList"); + // TODO : test on naturalId and nullity + } - /** - * Test of executeCreateUpdateList method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteCreateUpdateList() throws Exception { - System.out.println("executeCreateUpdateList"); - } - - /** - * Test of executeDeleteList method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteDeleteList() throws Exception { - System.out.println("executeDeleteList"); - } - - /** - * Test of executeGetFavoriteLists method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteGetFavoriteLists() throws Exception { - System.out.println("executeGetFavoriteLists"); - } - - /** - * Test of executeGetNewPerson method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteGetNewPerson() throws Exception { - System.out.println("executeGetNewPerson"); - } - - /** - * Test of executeGetPerson method, of class ServiceUserImpl. - */ - //@Test - public void testExecuteGetPerson() throws Exception { - System.out.println("executeGetPerson"); - } - } \ No newline at end of file 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-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -44,19 +44,20 @@ @Inject private ServiceUser serviceUser; + @Persist @Property private FavoriteList favoriteListSelected; private EvenOdd evenOdd; @Persist - private FavoriteParticipantDataSource accounts; + private FavoriteParticipantDataSource participants; @Property - private FavoriteParticipant account; + private FavoriteParticipant participant; @Property - private FavoriteParticipant newAccount; + private FavoriteParticipant newParticipant; @InjectComponent private Zone updateZone; @@ -76,28 +77,32 @@ return favoriteListSelected != null; } - public FavoriteParticipantDataSource getAccounts() { - if (accounts == null) { + public FavoriteParticipantDataSource getParticipants() { + if (participants == null) { + if (logger.isDebugEnabled()) { + logger.debug("Create DATASOURCE"); + } Filter filter = new Filter(); filter.setReference(favoriteListSelected); - accounts = new FavoriteParticipantDataSource(serviceUser, filter); + participants = + new FavoriteParticipantDataSource(serviceUser, filter); } - return accounts; + return participants; } - void onActionFromRemoveAccount(String UId) { + void onActionFromRemoveParticipant(String UId) { // NEED DELETE ACCOUNT FOR LIST } - void onPrepareFromAddAccount() { - if (newAccount == null) { - newAccount = + void onPrepareFromAddParticipant() { + if (newParticipant == null) { + newParticipant = serviceUser.getNewFavoriteParticipant(favoriteListSelected); } } - Object onSuccessFromAddAccount() { - // NEED CREATE ACCOUNT FOR LIST + Object onSuccessFromAddParticipant() { + serviceUser.createFavoriteParticipant(newParticipant); 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-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -1,32 +1,7 @@ -/* - * #%L - * Wao :: Web Interface - * - * $Id$ - * $HeadURL: svn+ssh://fdesbois@labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java $ - * %% - * Copyright (C) 2009 - 2010 Ifremer - * %% - * 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/gpl-3.0.html>. - * #L% - */ 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; @@ -49,13 +24,17 @@ * @param <E> Type of the map value * @author fdesbois <fdesbois@codelutin.com> */ -public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity> implements GridDataSource { +public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity> + implements GridDataSource { - private Logger log = LoggerFactory.getLogger(AbstractMappedGridDataSource.class); + private Logger log = + LoggerFactory.getLogger(AbstractMappedGridDataSource.class); private Map<K, E> mapResults; + private List<E> listResults; + private int nbRows = -1; private int nbRowsPerPage; @@ -65,8 +44,8 @@ if (nbRows < 0) { try { nbRows = count(); - if (log.isTraceEnabled()) { - log.trace("Count : " + nbRows); + if (log.isDebugEnabled()) { + log.debug("Count : " + nbRows); } } catch (PollenException eee) { throw new TapestryException("", eee); @@ -76,14 +55,15 @@ } @Override - public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) { - if (log.isTraceEnabled()) { - log.trace("Prepare results : " + startIndex + ", " + endIndex); + public void prepare(int startIndex, int endIndex, + List<SortConstraint> sortConstraints) { + if (log.isDebugEnabled()) { + log.debug("Prepare results : " + startIndex + ", " + endIndex); } nbRowsPerPage = endIndex - startIndex + 1; try { mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints)); - + listResults = new ArrayList<E>(mapResults.values()); } catch (PollenException eee) { throw new TapestryException("", eee); } @@ -123,17 +103,17 @@ } return filterOrder; } - + @Override public Object getRowValue(int index) { index = index % nbRowsPerPage; - if (index >= mapResults.size()) { + if (index >= listResults.size()) { if (log.isErrorEnabled()) { - log.error("Size error : " + index + " / " + mapResults.size()); + log.error("Size error : " + index + " / " + listResults.size()); } return null; } - return CollectionUtils.get(mapResults, index); + return CollectionUtils.get(listResults, index); } @Override @@ -143,8 +123,8 @@ return mapResults.get(key); } - public Collection<E> values() { - return mapResults.values(); + public List<E> values() { + return listResults; } public boolean contains(K key) { Modified: 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-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-04-30 08:47:02 UTC (rev 2981) @@ -8,6 +8,8 @@ import org.chorem.pollen.entity.FavoriteParticipant; import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.service.ServiceUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * UserAccountDataSource @@ -23,6 +25,9 @@ public class FavoriteParticipantDataSource extends AbstractMappedGridDataSource<String, FavoriteParticipant> { + private static final Logger logger = + LoggerFactory.getLogger(FavoriteParticipantDataSource.class); + private ServiceUser service; private Filter filter; @@ -39,6 +44,9 @@ filter.setStartIndex(startIndex); filter.setEndIndex(endIndex); filter.setOrderBy(resolveOrderBy(orderBy)); + if (logger.isDebugEnabled()) { + logger.debug("LOAD DATA"); + } return service.getFavoriteParticipants(filter); } 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-04-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-30 08:47:02 UTC (rev 2981) @@ -36,7 +36,7 @@ pollen.ui.list.create.success=La liste %1$s a \u00E9t\u00E9 cr\u00E9\u00E9e avec succ\u00E8s. pollen.ui.list.update.notSelected=Aucune liste s\u00E9lectionn\u00E9e. pollen.ui.list.update.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email. -pollen.ui.list.update.addAccount=Ajouter un nouvel utilisateur \u00E0 la liste +pollen.ui.list.update.addParticipant=Ajouter un nouvel utilisateur \u00E0 la liste # FORM:: user firstName-label=Pr\u00E9nom 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-29 06:05:03 UTC (rev 2980) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-30 08:47:02 UTC (rev 2981) @@ -13,11 +13,11 @@ <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="accounts.values()" t:row="account" + <div t:type="grid" t:source="participants" t:row="participant" t:include="name, email, weight" t:add="actions" t:rowsPerPage="20" t:rowClass="prop:evenodd.next" t:inPlace="true"> <p:actionsCell> - <a t:type="actionlink" t:id="removeAccount" t:context="account.UId"> + <a t:type="actionlink" t:id="removeParticipant" t:context="participant.id"> <img src="${asset:context:img/delete.png}" alt="${message:pollen.ui.list.remove}"/> </a> </p:actionsCell> @@ -26,22 +26,21 @@ </p:empty> </div> - <!-- Add a new PollAccount to favoriteListSelected --> - <form t:type="form" t:id="addAccount" t:zone="updateZone" action="tapestry"> + <!-- Add a new FavoriteParticipant to favoriteListSelected --> + <form t:type="form" t:id="addParticipant" t:zone="updateZone" action="tapestry"> <table class="t-data-grid"> <tr> <td class="votingId"> - <input t:type="textfield" t:id="name" t:value="newAccount.name" t:validate="required" size="10"/> + <input t:type="textfield" t:id="name" t:value="newParticipant.name" t:validate="required" size="10"/> </td> <td class="email"> - <input t:type="textfield" t:id="email" t:value="newAccount.email" t:validate="email" size="15"/> + <input t:type="textfield" t:id="email" t:value="newParticipant.email" t:validate="regexp" size="15"/> </td> <td class="weight"> - <input t:type="textfield" t:id="weight" t:value="newAccount.weight" size="5"/> + <input t:type="textfield" t:id="weight" t:value="newParticipant.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}"/> + <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addParticipant}"/> </td> </tr> </table>
participants (1)
-
fdesbois@users.chorem.org