r3109 - in branches/pollen-2.0-beta-1/pollen-services/src: main/java/org/chorem/pollen main/java/org/chorem/pollen/mail main/java/org/chorem/pollen/service/legacy main/java/org/chorem/pollen/services main/java/org/chorem/pollen/services/exceptions test/java/org/chorem/pollen/service/legacy test/java/org/chorem/pollen/services
Author: tchemit Date: 2012-01-23 23:29:31 +0100 (Mon, 23 Jan 2012) New Revision: 3109 Url: http://chorem.org/repositories/revision/pollen/3109 Log: - introduce exceptions package - copy all code from legacy services to new services - depreciates all old stuff Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListAlreadyExistException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantAlreadyFoundInListException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantExistWithoutMailException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyClosedException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyExistException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollNotFoundException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserEmailAlreadyUsedException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserInvalidPasswordException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserLoginAlreadyUsedException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserNotFoundException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteDoubloonException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotAllowedException.java Removed: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserEmailAlreadyUsedException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserInvalidPasswordException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserLoginAlreadyUsedException.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserNotFoundException.java Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/PollenContextImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmail.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailAbstract.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavorite.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteAbstract.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePoll.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollAbstract.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserAbstract.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVote.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteAbstract.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteImpl.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteService.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/PollService.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/VoteService.java branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/AbstractServiceTest.java branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceFavoriteImplTest.java branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServicePollImplTest.java branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceUserImplTest.java branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceVoteImplTest.java branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/PollenContextImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/PollenContextImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/PollenContextImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -56,6 +56,7 @@ * Mise a jour: $Date$ * par : $Author$ */ +@Deprecated public class PollenContextImpl implements PollenContext { /** log. */ @@ -74,7 +75,7 @@ /** * Default configuration file will be loaded using - * {@link org.nuiton.util.ApplicationConfig }. + * {@link ApplicationConfig }. * Then the other configuration initialization will be done in * {@link #loadConfiguration(ApplicationConfig)} method. */ @@ -82,18 +83,18 @@ try { if (log.isInfoEnabled()) { log.info("load default configuration from " + - PollenContextImpl.DEFAULT_FILENAME); + DEFAULT_FILENAME); } ApplicationConfig conf = new ApplicationConfig(); - conf.setConfigFileName(PollenContextImpl.DEFAULT_FILENAME); - conf.parse(new String[]{}); + conf.setConfigFileName(DEFAULT_FILENAME); + conf.parse(); conf.printConfig(); loadConfiguration(conf); } catch (ArgumentsParserException eee) { treateError(eee, n_("pollen.error.context.parse"), - PollenContextImpl.DEFAULT_FILENAME); + DEFAULT_FILENAME); } } @@ -234,7 +235,6 @@ * * @param key of the property * @return value of this property - * @throws PollenBusinessException */ public String getProperty(String key) { return getConfiguration().getOption(key); @@ -244,7 +244,6 @@ * Get all properties from the configuration * * @return the Properties of the application - * @throws PollenBusinessException */ public Properties getProperties() { return getConfiguration().getOptions(); @@ -267,8 +266,6 @@ * Get the Topia rootContext. * * @return the main TopiaContext needed to begin new transaction - * @throws PollenException - * @throws PollenBusinessException */ public TopiaContext getTopiaRootContext() { try { Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -143,6 +143,7 @@ * Envoi du mail de notification. * * @param poll sondage concerné + * @param timeValue */ private void sendMailNotification(Poll poll, Long timeValue) { // FIXME : create ServiceMail Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -81,6 +81,7 @@ /** * Exécution de la méthode définie par la règle. La méthode s'exécute sans * prise en compte de la sensibilité de la règle. + * @return */ public boolean execute() { return execute(null, null, null); @@ -91,6 +92,7 @@ * valeur correspond à la sensibilité de la règle. * * @param value valeur conditionnant l'exécution de la règle. + * @return */ public boolean execute(Integer value) { return execute(null, value, null); @@ -101,6 +103,7 @@ * portée est égale à la portée de la règle. * * @param scope portée de la règle. + * @return */ public boolean execute(String scope) { return execute(scope, null, null); @@ -113,6 +116,7 @@ * * @param scope portée de la règle. * @param value valeur conditionnant l'exécution de la règle. + * @return */ public boolean execute(String scope, Integer value) { return execute(scope, value, null); @@ -176,6 +180,8 @@ * Action qui ne fait rien. * * TODO set this method to protected + * @param data + * @param data */ public static void nullAction(Object data) { // ne fait rien @@ -185,6 +191,8 @@ * Action qui écrit sur la sortie standard. * * TODO set this method to protected + * @param data + * @param data */ public static void printAction(Object data) { String message = ""; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmail.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmail.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmail.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -28,6 +28,7 @@ import org.chorem.pollen.bean.PollenEmail; import org.chorem.pollen.entity.UserAccount; +@Deprecated public interface ServiceEmail { PollenEmail createEmail(); Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailAbstract.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailAbstract.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailAbstract.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -33,6 +33,7 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; +@Deprecated public abstract class ServiceEmailAbstract implements ServiceEmail { protected abstract TopiaContext beginTransaction() throws TopiaException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceEmailImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -49,6 +49,7 @@ * Mise a jour: $Date$ * par : $Author$ */ +@Deprecated public class ServiceEmailImpl extends ServiceEmailAbstract { private static final Log log = LogFactory.getLog(ServiceEmailImpl.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavorite.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavorite.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavorite.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -32,6 +32,7 @@ import org.chorem.pollen.entity.UserAccount; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public interface ServiceFavorite { void createFavoriteParticipant(FavoriteParticipant participant) throws PollenException, PollenBusinessException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteAbstract.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteAbstract.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteAbstract.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -35,6 +35,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public abstract class ServiceFavoriteAbstract implements ServiceFavorite { protected abstract TopiaContext beginTransaction() throws TopiaException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceFavoriteImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -57,6 +57,7 @@ * @author fdesbois $Id: ServiceFavoriteImpl.java 2996 2010-05-14 12:06:15Z * fdesbois $ */ +@Deprecated public class ServiceFavoriteImpl extends ServiceFavoriteAbstract { private Log log = LogFactory.getLog(ServiceUserImpl.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePoll.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePoll.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePoll.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -37,6 +37,7 @@ import org.chorem.pollen.entity.UserAccount; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public interface ServicePoll { /** Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollAbstract.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollAbstract.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollAbstract.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -41,6 +41,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public abstract class ServicePollAbstract implements ServicePoll { protected abstract TopiaContext beginTransaction() throws TopiaException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServicePollImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -72,6 +72,7 @@ * @author fdesbois * $Id$ */ +@Deprecated public class ServicePollImpl extends ServicePollAbstract { private static final Log log = LogFactory.getLog(ServicePollImpl.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserAbstract.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserAbstract.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserAbstract.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -34,6 +34,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public abstract class ServiceUserAbstract implements ServiceUser { protected abstract TopiaContext beginTransaction() throws TopiaException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceUserImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -58,6 +58,7 @@ * Mise a jour: $Date$ * par : $Author$ */ +@Deprecated public class ServiceUserImpl extends ServiceUserAbstract { private Log log = LogFactory.getLog(ServiceUserImpl.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVote.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVote.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVote.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -33,6 +33,7 @@ import org.chorem.pollen.entity.Vote; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public interface ServiceVote { boolean canVote(Poll poll, PollAccount participant) throws PollenException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteAbstract.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteAbstract.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteAbstract.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -36,6 +36,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +@Deprecated public abstract class ServiceVoteAbstract implements ServiceVote { protected abstract TopiaContext beginTransaction() throws TopiaException; Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteImpl.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteImpl.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/service/legacy/ServiceVoteImpl.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -56,6 +56,7 @@ * @author fdesbois <fdesbois@codelutin.com> * @version $Id$ */ +@Deprecated public class ServiceVoteImpl extends ServiceVoteAbstract { private static final Log log = LogFactory.getLog(ServiceVoteImpl.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteService.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteService.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -23,42 +23,77 @@ */ package org.chorem.pollen.services; -import org.chorem.pollen.PollenBusinessException; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.PollenDAOHelper; +import org.chorem.pollen.PollenQueryHelper; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.entity.FavoriteList; +import org.chorem.pollen.entity.FavoriteListDAO; +import org.chorem.pollen.entity.FavoriteListImpl; import org.chorem.pollen.entity.FavoriteParticipant; +import org.chorem.pollen.entity.FavoriteParticipantDAO; +import org.chorem.pollen.entity.FavoriteParticipantImpl; import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.service.legacy.ServiceFavoriteImpl; +import org.chorem.pollen.services.exceptions.FavoriteListAlreadyExistException; +import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException; +import org.chorem.pollen.services.exceptions.ParticipantExistWithoutMailException; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.persistence.TopiaEntity; import java.util.List; import java.util.Map; public class FavoriteService extends PollenServiceSupport { - public void createFavoriteParticipant(FavoriteParticipant participant) throws PollenBusinessException { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); + /** Logger. */ + private static final Log log = LogFactory.getLog(FavoriteService.class); + + public void createFavoriteParticipant(FavoriteParticipant participant) throws ParticipantExistWithoutMailException, ParticipantAlreadyFoundInListException { try { - service.executeCreateFavoriteParticipant(getTransaction(), participant); + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(getTransaction()); + + checkFavoriteParticipant(dao, participant); + + // Create newParticipant with naturalId + FavoriteParticipant result = + dao.create(participant.getName(), + participant.getEmail(), + participant.getFavoriteList()); + + // Set other field + result.setWeight(participant.getWeight()); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public void deleteFavoriteParticipant(String id) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); try { - service.executeDeleteFavoriteParticipant(getTransaction(), id); + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(getTransaction()); + + FavoriteParticipant participantLoaded = dao.findByTopiaId(id); + dao.delete(participantLoaded); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public FavoriteParticipant getFavoriteParticipant(String id) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); try { - FavoriteParticipant result = service.executeGetFavoriteParticipant(getTransaction(), id); + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(getTransaction()); + + FavoriteParticipant result = dao.findByTopiaId(id); + //No more needed +// // Load parent list +// result.getFavoriteList(); + return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -66,19 +101,37 @@ } public Map<String, FavoriteParticipant> getFavoriteParticipants(EntityFilter filter) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); try { - Map<String, FavoriteParticipant> result = service.executeGetFavoriteParticipants(getTransaction(), filter); - return result; + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(getTransaction()); + + PollenQueryHelper.FavoriteParticipantProperty participantProperty = + PollenQueryHelper.newFavoriteParticipantProperty(); + + TopiaQuery query = dao.createQueryFindAllByFavoriteList(filter); + + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } + + query.addLoad(participantProperty.favoriteList()); + + Map<String, FavoriteParticipant> results = + dao.findAllMappedByQuery(query); + + return results; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public List<FavoriteList> getFavoriteLists(UserAccount user) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); try { - List<FavoriteList> result = service.executeGetFavoriteLists(getTransaction(), user); + FavoriteListDAO dao = + PollenDAOHelper.getFavoriteListDAO(getTransaction()); + + List<FavoriteList> result = dao.findAllByUserAccount(user); + return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -86,27 +139,44 @@ } public void deleteFavoriteList(FavoriteList list) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); try { - service.executeDeleteFavoriteList(getTransaction(), list); + FavoriteListDAO dao = + PollenDAOHelper.getFavoriteListDAO(getTransaction()); + + FavoriteList listLoaded = dao.findByTopiaId(list.getId()); + dao.delete(listLoaded); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } - public void createFavoriteList(FavoriteList list) throws PollenBusinessException { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); + public void createFavoriteList(FavoriteList list) throws FavoriteListAlreadyExistException { try { - service.executeCreateFavoriteList(getTransaction(), list); + FavoriteListDAO dao = + PollenDAOHelper.getFavoriteListDAO(getTransaction()); + + // check favoriteList name exist for user + UserAccount user = list.getUserAccount(); + + // existing list found + if (dao.existByNaturalId(list.getName(), user)) { + throw new FavoriteListAlreadyExistException(); + } + + dao.create(list.getName(), list.getUserAccount()); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public int getNbFavoriteParticipants(EntityFilter filter) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); try { - int result = service.executeGetNbFavoriteParticipants(getTransaction(), filter); + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(getTransaction()); + + TopiaQuery query = dao.createQueryFindAllByFavoriteList(filter); + + int result = dao.countByQuery(query); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -114,23 +184,75 @@ } public FavoriteParticipant getNewFavoriteParticipant(FavoriteList list) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); - FavoriteParticipant result = service.executeGetNewFavoriteParticipant(list); + FavoriteParticipant result = new FavoriteParticipantImpl(); + result.setFavoriteList(list); + result.setWeight(1.); return result; } public FavoriteList getNewFavoriteList(UserAccount user) { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); - FavoriteList result = service.executeGetNewFavoriteList(user); + FavoriteList result = new FavoriteListImpl(); + result.setUserAccount(user); return result; } - public void updateFavoriteParticipant(FavoriteParticipant participant) throws PollenBusinessException { - ServiceFavoriteImpl service = new ServiceFavoriteImpl(); + public void updateFavoriteParticipant(FavoriteParticipant participant) throws ParticipantExistWithoutMailException, ParticipantAlreadyFoundInListException { try { - service.executeUpdateFavoriteParticipant(getTransaction(), participant); + FavoriteParticipantDAO dao = + PollenDAOHelper.getFavoriteParticipantDAO(getTransaction()); + + checkFavoriteParticipant(dao, participant); + + FavoriteParticipant participantLoaded = + dao.findByTopiaId(participant.getId()); + + // Set all fields except favoriteList that can't be changed + participantLoaded.setName(participant.getName()); + participantLoaded.setEmail(participant.getEmail()); + participantLoaded.setWeight(participant.getWeight()); + + dao.update(participantLoaded); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + + /** + * Check if the {@code participant} doesn't already exists with same email, + * name and favoriteList. + * + * @param dao used to verify the existing participant + * @param participant FavoriteParticipant to check + * @throws TopiaException for technical errors from ToPIA + * @throws ParticipantAlreadyFoundInListException + * if a participant already exist in list + * @throws ParticipantExistWithoutMailException + * if a participan was found without email + */ + protected void checkFavoriteParticipant(FavoriteParticipantDAO dao, + FavoriteParticipant participant) + throws TopiaException, ParticipantExistWithoutMailException, ParticipantAlreadyFoundInListException { + + FavoriteList list = participant.getFavoriteList(); + + TopiaQuery query = dao.createQuery(). + addEquals(FavoriteParticipant.PROPERTY_FAVORITE_LIST, list). + addEquals(FavoriteParticipant.PROPERTY_NAME, participant.getName()). + addEquals(FavoriteParticipant.PROPERTY_EMAIL, participant.getEmail()); + + // Check only on entities different from the one in argument + if (StringUtils.isNotEmpty(participant.getId())) { + query.addWhere(TopiaEntity.TOPIA_ID, TopiaQuery.Op.NEQ, participant.getId()); + } + + // existing participant found + if (dao.existByQuery(query)) { + // The error type (message) depends on email nullity + if (participant.getEmail() == null) { + throw new ParticipantExistWithoutMailException(); + } else { + throw new ParticipantAlreadyFoundInListException(); + } + } + } } Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/PollService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/PollService.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/PollService.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -24,28 +24,54 @@ package org.chorem.pollen.services; import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import org.chorem.pollen.PollenBusinessException; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.PollenBinderHelper; +import org.chorem.pollen.PollenDAOHelper; import org.chorem.pollen.PollenException; +import org.chorem.pollen.PollenQueryHelper; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.bean.UserPoll; +import org.chorem.pollen.common.ChoiceType; +import org.chorem.pollen.common.PollType; +import org.chorem.pollen.common.VoteCountingType; import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.ChoiceDAO; +import org.chorem.pollen.entity.ChoiceImpl; import org.chorem.pollen.entity.Comment; +import org.chorem.pollen.entity.CommentDAO; +import org.chorem.pollen.entity.CommentImpl; import org.chorem.pollen.entity.Participant; import org.chorem.pollen.entity.ParticipantList; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.PollAccountDAO; +import org.chorem.pollen.entity.PollAccountImpl; +import org.chorem.pollen.entity.PollDAO; +import org.chorem.pollen.entity.PollImpl; import org.chorem.pollen.entity.UserAccount; -import org.chorem.pollen.service.legacy.ServicePollImpl; +import org.chorem.pollen.services.exceptions.PollAlreadyClosedException; +import org.chorem.pollen.services.exceptions.PollAlreadyExistException; +import org.chorem.pollen.services.exceptions.PollNotFoundException; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +import org.nuiton.topia.framework.TopiaFilter; +import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; +import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class PollService extends PollenServiceSupport { + /** Logger. */ + private static final Log log = LogFactory.getLog(PollService.class); + /** * Build a new Poll instance with given {@code user} as administrator * @@ -54,8 +80,23 @@ * @throws PollenException */ public Poll getNewPoll(UserAccount user) { - ServicePollImpl service = new ServicePollImpl(); - Poll result = service.executeGetNewPoll(user); + Poll result = new PollImpl(); + result.setChoiceType(ChoiceType.TEXT); + result.setVoteCounting(VoteCountingType.NORMAL); + result.setType(PollType.FREE); + // Initialize creator as an admin for the poll + PollAccount creator = new PollAccountImpl(); + creator.setAdmin(true); + if (user != null) { + // Link the creator with the user + creator.setName(user.getDisplayName()); + creator.setEmail(user.getEmail()); + creator.setUserAccount(user); + } + result.setCreator(creator); + // Generate Uid to have a unique poll. Will avoid multi-submit, existing + // poll will be check by its uid. + result.setUid(serviceContext.createPollenUrlId()); return result; } @@ -67,25 +108,135 @@ * @throws PollenException */ public Poll getNewPoll(Poll poll) { - ServicePollImpl service = new ServicePollImpl(); - Poll result = service.executeGetNewPoll(poll); + Poll result = new PollImpl(); + TopiaEntityBinder<Poll> binder = PollenBinderHelper.getSimpleTopiaBinder(Poll.class); + //TODO-fdesbois-2010-07-13 : add test and check if exluding only those properties is realistic + binder.copyExcluding(poll, result, + Poll.PROPERTY_UID, + Poll.PROPERTY_CLOSED, + Poll.PROPERTY_RESULT, + Poll.PROPERTY_POLL_ACCOUNT + ); + // Copy of participants only for no free poll + if (poll.getType().isRestrictedOrGroup()) { + result.setPollAccount(poll.getPollAccount()); + } return result; } - public Poll createPoll(Poll poll, Collection<ParticipantList> lists) throws PollenBusinessException { - ServicePollImpl service = new ServicePollImpl(); + public Poll createPoll(Poll poll, + Collection<ParticipantList> lists) throws PollAlreadyExistException { try { - Poll result = service.executeCreatePoll(getTransaction(), Lists.newArrayList(), poll, lists); - return result; + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + if (dao.existByNaturalId(poll.getUid())) { + throw new PollAlreadyExistException(); + } + + // Create newPoll and copy simple properties from poll source + Poll newPoll = createBasicPoll(poll); + + // Create accounts only for non free poll + if (!newPoll.getType().isFree()) { + // Create accounts depends on pollType and lists argument + List<PollAccount> accounts = + createPollAccounts(newPoll.getType(), lists); + newPoll.setPollAccount(accounts); + } + + // Create newPoll choices + List<Choice> choices = createPollChoices(poll.getChoice()); + + newPoll.setChoice(choices); + + dao.update(newPoll); + + return newPoll; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } - public Poll updatePoll(Poll poll) { - ServicePollImpl service = new ServicePollImpl(); + public Poll updatePoll(Poll poll) throws PollAlreadyClosedException { try { - Poll result = service.executeUpdatePoll(getTransaction(), poll); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + // Updating a Poll : + // - TITLE + // - DESCRIPTION + // - BEGIN/END DATE + // - CHOICE_ADD_ALLOWED + // - BEGIN/END ADD CHOICE DATE + // - MAX_CHOICE_NB + // - CONTINUOUS_RESULTS + // - PUBLIC_RESULTS + // - ANONYMOUS_VOTE_ALLOWED + + // Anonymous change is not supported (need to manage accounts) + // PollType change is not supported (need to manage accounts) + // VoteCounting change is not supported (need to manage existing votes) + + // Comments, Results, Choices and Accounts will not be updated here + + // Update only for not started poll : + // - VOTE_COUNTING + // - CHOICE_TYPE + // - CHOICES + + Poll pollToUpdate = dao.findByTopiaId(poll.getTopiaId()); + + // Can't update a closed poll + if (pollToUpdate.isClosed()) { + throw new PollAlreadyClosedException(); + } + + TopiaEntityBinder<Poll> binder = PollenBinderHelper.getSimpleTopiaBinder(Poll.class); + + // Idea, if we can use Embeddable object for Hibernate, Options will be a good use case + binder.copy(poll, pollToUpdate, + Poll.PROPERTY_TITLE, + Poll.PROPERTY_DESCRIPTION, + Poll.PROPERTY_BEGIN_DATE, + Poll.PROPERTY_END_DATE, + Poll.PROPERTY_ANONYMOUS_VOTE_ALLOWED, + Poll.PROPERTY_CHOICE_ADD_ALLOWED, + Poll.PROPERTY_BEGIN_CHOICE_DATE, + Poll.PROPERTY_END_CHOICE_DATE, + Poll.PROPERTY_CONTINUOUS_RESULTS, + Poll.PROPERTY_PUBLIC_RESULTS, + Poll.PROPERTY_MAX_CHOICE_NB + ); + + // if not started + if (!pollToUpdate.isStarted()) { + + log.debug("Poll is not started, update voteCounting and choices"); + + // Update voteCounting is simple when poll have no vote + pollToUpdate.setVoteCounting(poll.getVoteCounting()); + + // Override choices if type has changed, otherwise the choice entity will automatically be updated + if (!pollToUpdate.getChoiceType().equals(poll.getChoiceType())) { + pollToUpdate.setChoiceType(poll.getChoiceType()); + + ChoiceDAO choiceDAO = PollenDAOHelper.getChoiceDAO(getTransaction()); + // Clear previous choices, will properly delete orphans + pollToUpdate.getChoice().clear(); + // Create new choices and add them to the poll + for (Choice choice : poll.getChoice()) { + Choice newChoice = pollToUpdate.addNewChoice(choice.getName(), choice.getDescription()); + choiceDAO.create(newChoice); + } + } + } + + // If continuous results is now activated, execute a voteCounting + if (!pollToUpdate.isContinuousResults() && + poll.isContinuousResults()) { + // TODO-fdesbois-2011-07-13 : execute vote counting + } + + Poll result = dao.update(pollToUpdate); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -93,70 +244,137 @@ } public void deletePoll(Poll poll) { - ServicePollImpl service = new ServicePollImpl(); try { - service.executeDeletePoll(getTransaction(), poll); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + dao.delete(poll); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public boolean deleteChoice(Choice choice) { - ServicePollImpl service = new ServicePollImpl(); try { - boolean result = service.executeDeleteChoice(getTransaction(), choice); - return result; + ChoiceDAO dao = PollenDAOHelper.getChoiceDAO(getTransaction()); + dao.delete(choice); + //FIXME tchemit-20120123 Why return true ? + return true; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + //FIXME tchemit-20120123 Replace the filter by a simple PagerBean public List<UserPoll> getPolls(EntityFilter filter) { - ServicePollImpl service = new ServicePollImpl(); try { - List<UserPoll> result = service.executeGetPolls(getTransaction(), filter); - return result; + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + PollenQueryHelper.PollAccountProperty participantProperty = + PollenQueryHelper.newPollAccountChildProperty(); + + // Filter can be apply on userAccount as reference + TopiaQuery query = dao.createQueryFindAllByUser(filter); + + query.addSelect(participantProperty.$alias()); + + log.debug("Query : " + query); + + List<UserPoll> results = retrieveUserPolls(query); + + return results; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + //FIXME tchemit-20120123 Replace the filter by a simple PagerBean public List<Comment> getComments(EntityFilter filter) { - ServicePollImpl service = new ServicePollImpl(); try { - List<Comment> result = service.executeGetComments(getTransaction(), filter); - return result; + CommentDAO dao = PollenDAOHelper.getCommentDAO(getTransaction()); + +// String pollAlias = PollenQueryHelper.ALIAS_POLL; +// String pollCommentProperty = +// TopiaQuery.getProperty(pollAlias, Poll.PROPERTY_COMMENT); +// String commentAlias = PollenQueryHelper.ALIAS_COMMENT; + + PollenQueryHelper.PollProperty pollProperty = + PollenQueryHelper.newPollProperty(); + PollenQueryHelper.CommentProperty commentProperty = + PollenQueryHelper.newCommentProperty(); + + filter.checkReference(Poll.class, true); + filter.setReferenceProperty(pollProperty.$alias()); + + TopiaQuery query = PollenQueryHelper.createQuery(pollProperty). + setSelect(commentProperty.$alias()). + addJoin(pollProperty.comment(), commentProperty.$alias(), false). + addFilter(filter); + + List<Comment> comments = dao.findAllByQuery(query); + return comments; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public ParticipantList getNewPollList() { - ServicePollImpl service = new ServicePollImpl(); - ParticipantList result = service.executeGetNewPollList(); + PollAccount result = new PollAccountImpl(); + result.setList(true); + result.setChild(new ArrayList<PollAccount>()); return result; } public Participant getNewPollParticipant() { - ServicePollImpl service = new ServicePollImpl(); - Participant result = service.executeGetNewPollParticipant(); + PollAccount result = new PollAccountImpl(); + result.setWeight(1.); return result; } - public Poll getPoll(String pollUid, String... properties) throws PollenBusinessException { - ServicePollImpl service = new ServicePollImpl(); + //FIXME tchemit-20120123 Remove the fetch system we don't need it with our transaction management + public Poll getPoll(String pollUid, String... properties) throws PollNotFoundException { try { - Poll result = service.executeGetPoll(getTransaction(), pollUid, properties); + // Property is used to control the alias and dependencies inside the query + PollenQueryHelper.PollProperty pollProperty = + PollenQueryHelper.newPollProperty(); + + // Need to control the alias for fetching, add it to each property + String[] fetchProperties = new String[properties.length]; + for (int i = 0; i < properties.length; i++) { + // This will clean properties for fetching + fetchProperties[i] = pollProperty.$property(properties[i]); + } + + // Create the query using default alias for Poll + TopiaQuery query = PollenQueryHelper.createQuery(pollProperty). + addFetch(fetchProperties). + addEquals(pollProperty.uid(), pollUid); + + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + Poll result = dao.findByQuery(query); + if (result == null) { + throw new PollNotFoundException(); + } return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + //FIXME tchemit-20120123 Should check userAccount and pollUid exist ? public boolean canAdminPoll(String accountUid, String pollUid) { - ServicePollImpl service = new ServicePollImpl(); try { - boolean result = service.executeCanAdminPoll(getTransaction(), accountUid, pollUid); + PollenQueryHelper.PollProperty pollProperty = + PollenQueryHelper.newPollProperty(); + + TopiaQuery query = PollenQueryHelper.createQuery(pollProperty). + addEquals(pollProperty.uid(), pollUid). + addEquals(pollProperty.creatorProperty().uid(), accountUid); + + + // Note a boolean admin exist in PollAccount, maybe + // find the account in lists + + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + boolean result = dao.existByQuery(query); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -164,19 +382,26 @@ } public int getNbTotalPolls() { - ServicePollImpl service = new ServicePollImpl(); try { - int result = service.executeGetNbTotalPolls(getTransaction()); - return result; + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + Long result = dao.count(); + return result.intValue(); } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + //FIXME tchemit-20120123 Remove this from dao, remove EntityFilter... public int getNbPollsByUser(UserAccount user) { - ServicePollImpl service = new ServicePollImpl(); try { - int result = service.executeGetNbPollsByUser(getTransaction(), user); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + EntityFilter filter = new TopiaFilter(); + filter.setReference(user); + TopiaQuery query = dao.createQueryFindAllByUser(filter); + + int result = dao.countByQuery(query); + return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -184,9 +409,21 @@ } public List<Poll> getRunningPolls() { - ServicePollImpl service = new ServicePollImpl(); try { - List<Poll> result = service.executeGetRunningPolls(getTransaction()); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + // isRunning : isStarted() && !isFinished() && !isClosed() + + Date now = serviceContext.getCurrentTime(); + + TopiaQuery query = dao.createQuery(). + addWhere(Poll.PROPERTY_BEGIN_DATE, TopiaQuery.Op.LE, now). + addWhere(Poll.PROPERTY_END_DATE, TopiaQuery.Op.GE, now). + addEquals(Poll.PROPERTY_CLOSED, Boolean.FALSE). + addOrderDesc(Poll.TOPIA_CREATE_DATE); + + List<Poll> result = dao.findAllByQuery(query); + return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -194,9 +431,12 @@ } public int getNbComments(Poll poll) { - ServicePollImpl service = new ServicePollImpl(); try { - int result = service.executeGetNbComments(getTransaction(), poll); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + Poll pollFound = dao.findByTopiaId(poll.getTopiaId()); + + int result = pollFound.sizeComment(); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -204,51 +444,85 @@ } public Comment createComment(Poll poll, Comment comment) { - ServicePollImpl service = new ServicePollImpl(); try { - Comment result = service.executeCreateComment(getTransaction(), poll, comment); - return result; + CommentDAO dao = PollenDAOHelper.getCommentDAO(getTransaction()); + + Comment commentCreated = dao.create( + Comment.PROPERTY_AUTHOR, comment.getAuthor(), + Comment.PROPERTY_COMMENT_DATE, serviceContext.getCurrentTime(), + Comment.PROPERTY_TEXT, comment.getText() + ); + + PollDAO pollDAO = PollenDAOHelper.getPollDAO(getTransaction()); + + Poll pollToUpdate = pollDAO.findByTopiaId(poll.getTopiaId()); + + pollToUpdate.addComment(commentCreated); + + pollDAO.update(pollToUpdate); + return commentCreated; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + //FIXME tchemit-20120123 Why returning true ? public boolean deleteComment(Comment comment) { - ServicePollImpl service = new ServicePollImpl(); try { - boolean result = service.executeDeleteComment(getTransaction(), comment); - return result; + CommentDAO dao = PollenDAOHelper.getCommentDAO(getTransaction()); + dao.delete(comment); + return true; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public Comment getNewComment(PollAccount account) { - ServicePollImpl service = new ServicePollImpl(); - Comment result = service.executeGetNewComment(account); + Comment result = new CommentImpl(); + if (account != null) { + result.setAuthor(account.getName()); + } return result; } public Choice createChoice(Poll poll, Choice choice) { - ServicePollImpl service = new ServicePollImpl(); try { - Choice result = service.executeCreateChoice(getTransaction(), poll, choice); - return result; + ChoiceDAO dao = PollenDAOHelper.getChoiceDAO(getTransaction()); + + Choice choiceCreated = dao.create( + Choice.PROPERTY_NAME, choice.getName(), + Choice.PROPERTY_DESCRIPTION, choice.getDescription(), + Choice.PROPERTY_TYPE, choice.getType() + ); + + PollDAO pollDAO = PollenDAOHelper.getPollDAO(getTransaction()); + + Poll pollToUpdate = pollDAO.findByTopiaId(poll.getTopiaId()); + + pollToUpdate.addChoice(choiceCreated); + + pollDAO.update(pollToUpdate); + + return choiceCreated; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public Choice getNewChoice(Poll poll) { - ServicePollImpl service = new ServicePollImpl(); - Choice result = service.executeGetNewChoice(poll); + Choice result = new ChoiceImpl(); + result.setType(poll.getChoiceType()); return result; } public void setPollClosed(Poll poll, boolean closed) throws Exception { - ServicePollImpl service = new ServicePollImpl(); try { - service.executeSetPollClosed(getTransaction(), poll, closed); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + Poll pollToUpdate = dao.findByTopiaId(poll.getTopiaId()); + pollToUpdate.setClosed(closed); + + dao.update(pollToUpdate); } catch (TopiaException e) { throw new PollenTechnicalException(e); } @@ -256,9 +530,37 @@ public Poll createBasicPoll(Poll source) throws TopiaException { - ServicePollImpl service = new ServicePollImpl(); try { - Poll result = service.createBasicPoll(getTransaction(), source); + PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction()); + + PollAccountDAO accountDAO = + PollenDAOHelper.getPollAccountDAO(getTransaction()); + + // Create newPoll and copy simple properties from poll source + Poll result = dao.create(source.getUid()); + + // Copy all properties instead of Uid (already set at creation), + // Closed (not used in this case) and Creator (managed separately) + PollenBinderHelper.getSimpleTopiaBinder(Poll.class). + copyExcluding(source, result, + Poll.PROPERTY_UID, + Poll.PROPERTY_CLOSED, + Poll.PROPERTY_CREATOR); + + // Create creator and set him to the poll + PollAccount creator = accountDAO.create( + serviceContext.createPollenUrlId()); + + PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class). + copy(source.getCreator(), creator, + PollAccount.PROPERTY_NAME, + PollAccount.PROPERTY_EMAIL, +// PollAccount.WEIGHT, + PollAccount.PROPERTY_ADMIN, + PollAccount.PROPERTY_USER_ACCOUNT); + accountDAO.update(creator); + + result.setCreator(creator); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -295,6 +597,120 @@ Preconditions.checkArgument(poll.getEndChoiceDate().after(poll.getBeginChoiceDate())); } } + } + protected List<PollAccount> createPollAccounts(PollType type, + Collection<ParticipantList> lists) + throws TopiaException, IllegalArgumentException { + + List<PollAccount> results = new ArrayList<PollAccount>(); + + PollAccountDAO accountDAO = + PollenDAOHelper.getPollAccountDAO(getTransaction()); + + switch (type) { + case RESTRICTED: + if (CollectionUtils.isEmpty(lists)) { + throw new IllegalArgumentException("lists can't be empty" + + " for restricted poll"); + } + // Create accounts only on first participant list + results = createPersonAccounts(accountDAO, + lists.iterator().next()); + break; + case GROUP: + if (CollectionUtils.isEmpty(lists)) { + throw new IllegalArgumentException("lists can't be empty" + + " for group poll"); + } + + for (ParticipantList list : lists) { + // Create the accountList + PollAccount accountList = accountDAO.create( + serviceContext.createPollenUrlId()); + accountList.setList(true); + accountList.setName(list.getName()); + + // Create account children + List<PollAccount> accounts = + createPersonAccounts(accountDAO, list); + accountList.setChild(accounts); + + // Add the accountList to the results + results.add(accountList); + } + } + return results; } + + protected List<PollAccount> createPersonAccounts(PollAccountDAO dao, + ParticipantList list) + throws TopiaException { + + List<PollAccount> results = new ArrayList<PollAccount>(); + + for (Participant participant : list.getParticipants()) { + String accountUid = serviceContext.createPollenUrlId(); + PollAccount account = dao.create(accountUid); + account.setName(participant.getName()); + account.setEmail(participant.getEmail()); + account.setWeight(participant.getWeight()); + dao.update(account); + results.add(account); + } + return results; + } + + protected List<Choice> createPollChoices(List<Choice> source) + throws TopiaException { + + ChoiceDAO dao = PollenDAOHelper.getChoiceDAO(getTransaction()); + + List<Choice> results = new ArrayList<Choice>(); + + for (Choice choice : source) { + Choice newChoice = dao.create(); + PollenBinderHelper.getSimpleTopiaBinder(Choice.class). + copy(choice, newChoice); + results.add(newChoice); + } + return results; + } + + //FIXME tchemit-20120123 : help me to destroy this :( + protected List<UserPoll> retrieveUserPolls(TopiaQuery query) + throws TopiaException { + + List<UserPoll> results = new ArrayList<UserPoll>(); + + Map<String, UserPoll> pollsCache = + new HashMap<String, UserPoll>(); + + + List<Object[]> queryResults = getTransaction().findByQuery(query); + for (Object[] row : queryResults) { + Poll poll = (Poll) row[0]; + PollAccount account = (PollAccount) row[1]; + if (log.isDebugEnabled()) { + log.debug("account : " + account.getUid() + " : " + + account.getName() + + " list(" + account.isList() + ")" + + " admin(" + account.isAdmin() + ")" + + " for poll " + poll.getTitle()); + } + + UserPoll userPoll = pollsCache.get(poll.getTopiaId()); + + if (userPoll == null) { + userPoll = new UserPoll(); + userPoll.setPoll(poll); + results.add(userPoll); + pollsCache.put(poll.getTopiaId(), userPoll); + } + + userPoll.addAccount(account); + } + + return results; + } } Deleted: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserEmailAlreadyUsedException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserEmailAlreadyUsedException.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserEmailAlreadyUsedException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -1,36 +0,0 @@ -/* - * #%L - * Pollen :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.services; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class UserEmailAlreadyUsedException extends Exception { - - private static final long serialVersionUID = 1L; - -} Deleted: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserInvalidPasswordException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserInvalidPasswordException.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserInvalidPasswordException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -1,36 +0,0 @@ -/* - * #%L - * Pollen :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.services; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class UserInvalidPasswordException extends Exception { - - private static final long serialVersionUID = 1L; - -} Deleted: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserLoginAlreadyUsedException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserLoginAlreadyUsedException.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserLoginAlreadyUsedException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -1,36 +0,0 @@ -/* - * #%L - * Pollen :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.services; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class UserLoginAlreadyUsedException extends Exception { - - private static final long serialVersionUID = 1L; - -} Deleted: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserNotFoundException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserNotFoundException.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserNotFoundException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -1,36 +0,0 @@ -/* - * #%L - * Pollen :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.services; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class UserNotFoundException extends Exception { - - private static final long serialVersionUID = 1L; - -} Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -23,22 +23,22 @@ */ package org.chorem.pollen.services; -import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenBinderHelper; import org.chorem.pollen.PollenDAOHelper; -import org.chorem.pollen.PollenException; -import org.chorem.pollen.PollenFunctions; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.bean.PollenEmail; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountDAO; import org.chorem.pollen.entity.UserAccountImpl; +import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException; +import org.chorem.pollen.services.exceptions.UserInvalidPasswordException; +import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException; +import org.chorem.pollen.services.exceptions.UserNotFoundException; import org.nuiton.topia.TopiaException; -import org.nuiton.topia.framework.EntityFilter; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.persistence.util.TopiaEntityBinder; import org.nuiton.util.PagerUtil; @@ -48,7 +48,6 @@ import java.net.URL; import java.util.List; import java.util.Locale; -import java.util.Map; import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.l_; @@ -148,17 +147,20 @@ UserAccount userToUpdate = dao.findByTopiaId(user.getTopiaId()); // Do not manage password for an admin update - // neither if password was not asked to change - if (!byAdmin && StringUtils.isNotEmpty(newPassword)) { + if (!byAdmin) { - // Check the password + // Check original password String encodedPassword = encodePassword(user.getPassword()); if (!encodedPassword.equals(userToUpdate.getPassword())) { throw new UserInvalidPasswordException(); } - String newEncodedPassword = encodePassword(newPassword); - userToUpdate.setPassword(newEncodedPassword); + if (StringUtils.isNotEmpty(newPassword)) { + + // encode new password and store it in user account + String newEncodedPassword = encodePassword(newPassword); + userToUpdate.setPassword(newEncodedPassword); + } } // In case of email change, check if an other user has not already @@ -183,7 +185,7 @@ } } - public UserAccount getNewUser() throws PollenException { + public UserAccount getNewUser() { UserAccount result = new UserAccountImpl(); return result; } @@ -216,22 +218,6 @@ } } - public Map<String, UserAccount> getUsers(EntityFilter filter) { - - try { - UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(getTransaction()); - - TopiaQuery query = dao.createQuery().addFilter(filter); - - List<UserAccount> users = dao.findAllByQuery(query); - Map<String, UserAccount> result = - Maps.uniqueIndex(users, PollenFunctions.USER_BY_LOGIN); - return result; - } catch (TopiaException e) { - throw new PollenTechnicalException(e); - } - } - public int getNbUsers() { try { UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(getTransaction()); @@ -242,10 +228,6 @@ } } - public String encodePassword(String password) { - return StringUtil.encodeMD5(password); - } - public void createDefaultUsers() { UserAccount user = getNewUser(); user.setAdmin(true); @@ -254,7 +236,7 @@ user.setEmail(getConfiguration().getAdminEmail()); user.setNewPassword(getConfiguration().getAdminPassword()); try { - createUser(user,false, null); + createUser(user, false, null); if (log.isInfoEnabled()) { log.info(_("pollen.info.admin.created", login)); } @@ -266,6 +248,10 @@ } } + protected String encodePassword(String password) { + return StringUtil.encodeMD5(password); + } + /** * Copy {@code source} user account to {@code destination} one. * The email is lower cased in the {@code destination} user account. @@ -285,12 +271,5 @@ // Don't keep case for email destination.setEmail(StringUtils.lowerCase(source.getEmail())); - -// // Manage new password if needed -// String password = source.getNewPassword(); -// if (StringUtils.isNotEmpty(password)) { -//// destination.setPassword(context.encodePassword(password)); -// destination.setPassword(encodePassword(password)); -// } } } Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/VoteService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/VoteService.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/VoteService.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -23,26 +23,80 @@ */ package org.chorem.pollen.services; -import org.chorem.pollen.PollenBusinessException; +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.PollenDAOHelper; import org.chorem.pollen.PollenException; +import org.chorem.pollen.PollenQueryHelper; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.entity.Choice; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.PollAccountDAO; +import org.chorem.pollen.entity.PollAccountImpl; +import org.chorem.pollen.entity.PollDAO; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.Vote; -import org.chorem.pollen.service.legacy.ServiceVoteImpl; +import org.chorem.pollen.entity.VoteDAO; +import org.chorem.pollen.entity.VoteImpl; +import org.chorem.pollen.services.exceptions.VoteDoubloonException; +import org.chorem.pollen.services.exceptions.VoteNotAllowedException; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.EntityFilter; +import org.nuiton.topia.framework.TopiaFilter; +import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; import java.util.List; public class VoteService extends PollenServiceSupport { + /** Logger. */ + private static final Log log = LogFactory.getLog(VoteService.class); + public boolean canVote(Poll poll, PollAccount participant) { - ServiceVoteImpl service = new ServiceVoteImpl(); try { - boolean result = service.executeCanVote(getTransaction(), poll, participant); + if (log.isDebugEnabled()) { + log.debug("Poll started : " + poll.isStarted()); + log.debug("Poll finished : " + poll.isFinished()); + log.debug("Poll closed : " + poll.isClosed()); + } + boolean result = true; + if (!poll.isRunning()) { + if (log.isInfoEnabled()) { + log.info("Poll is no longer running... Participant can't vote"); + } + result = false; + // Creator can't vote + } else if (poll.getCreator().equals(participant)) { + return false; + } else if (poll.getType().isRestrictedOrGroup()) { + if (log.isInfoEnabled()) { + log.info("Poll is restricted... Participant need to be identified"); + } + + PollAccountDAO dao = + PollenDAOHelper.getPollAccountDAO(getTransaction()); + + TopiaQuery query = dao.createQueryFindAllParticipantsByPoll(poll); + + String participantAlias = PollenQueryHelper.ALIAS_POLL_ACCOUNT_CHILD; + + String pollCreatorProperty = + TopiaQuery.getProperty(PollenQueryHelper.ALIAS_POLL, + Poll.PROPERTY_CREATOR); + + query.addEquals(participantAlias, participant). + addWhere(pollCreatorProperty, TopiaQuery.Op.NEQ, participant); + + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } + + result = dao.existByQuery(query); + } return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -50,15 +104,29 @@ } public PollAccount getNewPollAccount(UserAccount user) { - ServiceVoteImpl service = new ServiceVoteImpl(); - PollAccount result = service.executeGetNewPollAccount(user); + PollAccount result = new PollAccountImpl(); + if (user != null) { + result.setName(user.getDisplayName()); + result.setEmail(user.getEmail()); + result.setUserAccount(user); + } return result; } public PollAccount getPollAccount(String accountUid) { - ServiceVoteImpl service = new ServiceVoteImpl(); try { - PollAccount result = service.executeGetPollAccount(getTransaction(), accountUid); + PollenQueryHelper.PollAccountProperty accountProperty = + PollenQueryHelper.newPollAccountProperty(); + + TopiaQuery query = PollenQueryHelper.createQuery(accountProperty). + addEquals(accountProperty.uid(), accountUid). + // Need fetching account votes to edit them + addFetch(accountProperty.choiceVote()); + + PollAccount result = + PollenDAOHelper.getPollAccountDAO(getTransaction()). + findByQuery(query); + return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -66,28 +134,80 @@ } public List<PollAccount> getVotes(EntityFilter filter) { - ServiceVoteImpl service = new ServiceVoteImpl(); try { - List<PollAccount> result = service.executeGetVotes(getTransaction(), filter); - return result; + PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(getTransaction()); + +// String participantChoiceProperty = +// TopiaQuery.getProperty(PollenQueryHelper.ALIAS_POLL_ACCOUNT, +// PollAccount.PROPERTY_CHOICE_VOTE, +// Vote.PROPERTY_CHOICE); +// +// TopiaQuery query = dao.createQueryFindAllByPoll(filter). +// addDistinct(). +// addFetch(participantChoiceProperty); + + PollenQueryHelper.PollAccountProperty accountProperty = + PollenQueryHelper.newPollAccountProperty(); + + TopiaQuery query = dao.createQueryFindAllByPoll(filter). + addDistinct(). + addFetch(accountProperty.choiceVoteProperty().choice()); + + List<PollAccount> results = dao.findAllByQuery(query); + + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } + + return results; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public void deleteVote(Poll poll, PollAccount participant) { - ServiceVoteImpl service = new ServiceVoteImpl(); try { - service.executeDeleteVote(getTransaction(), poll, participant); + // For free poll, delete the participant + // For other types, delete all votes and set voteDate to null + + PollAccountDAO dao = + PollenDAOHelper.getPollAccountDAO(getTransaction()); + + if (poll.getType().isFree()) { + + PollAccount participantToDelete = + dao.findByTopiaId(participant.getTopiaId()); + + dao.delete(participantToDelete); + + } else if (poll.getType().isRestrictedOrGroup()) { + + PollAccount participantToUpdate = + dao.findByTopiaId(participant.getTopiaId()); + + // Remove all votes deleted by cascade + participantToUpdate.clearChoiceVote(); + // Reset date, the participant is considered like he has not alerady + // voted + participantToUpdate.setVoteDate(null); + + dao.update(participantToUpdate); + } } catch (TopiaException e) { throw new PollenTechnicalException(e); } } public int getNbVotes(Poll poll) throws PollenException { - ServiceVoteImpl service = new ServiceVoteImpl(); try { - int result = service.executeGetNbVotes(getTransaction(), poll); + PollAccountDAO dao = + PollenDAOHelper.getPollAccountDAO(getTransaction()); + + EntityFilter filter = new TopiaFilter(); + filter.setReference(poll); + TopiaQuery query = dao.createQueryFindAllByPoll(filter); + + int result = dao.countByQuery(query); return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); @@ -95,29 +215,209 @@ } public Vote getNewVote(Choice choice) { - ServiceVoteImpl service = new ServiceVoteImpl(); - Vote result = service.executeGetNewVote(choice); + Vote result = new VoteImpl(); + result.setChoice(choice); return result; } - public PollAccount saveVote(Poll poll, PollAccount participant) throws PollenBusinessException { - ServiceVoteImpl service = new ServiceVoteImpl(); + public PollAccount saveVote(Poll poll, PollAccount participant) throws VoteNotAllowedException, VoteDoubloonException { try { - PollAccount result = service.executeSaveVote(getTransaction(), poll, participant); + // 1- executeCanVote(transaction, poll, participant); + // 2- generate uid if needed + // 3- update or create participant + // 4- add participant in the poll if needed + // 5- save only votes with voteValue != 0 : update/create/delete + // 6- execute calcul for continuousResults poll + + // NEED test : + // need existing poll with choices + // getNewPollAccount + // set some votes for poll choices + // saveVote + + PollAccount result; + if (canVote(poll, participant)) { + + PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(getTransaction()); + + checkParticipantDoubloons(dao, poll, participant); + + PollAccount participantToSave = + dao.findByTopiaId(participant.getTopiaId()); + + // canVote method check the existence of participant for a + // restricted poll, so the create case is only for FREE poll. + if (participantToSave == null) { + if (log.isInfoEnabled()) { + log.info("Create new participant for FREE poll"); + } + participantToSave = createNewParticipant(poll); + } + + // Copy data (care about anonymous case) + copyPollAccount(participant, participantToSave); + + // Update vote date + participantToSave.setVoteDate(serviceContext.getCurrentTime()); + + if (log.isDebugEnabled()) { + log.debug("Vote " + participantToSave.getName() + + " updated : " + participantToSave.getVoteDate()); + } + + // Save votes + saveParticipantVotes(participant, participantToSave); + + dao.update(participantToSave); + + result = participantToSave; + + // TODO-fdesbois-2010-05-27 : execute vote counting if poll.isContinuousResults() + + } else { + throw new VoteNotAllowedException(); + } + return result; } catch (TopiaException e) { throw new PollenTechnicalException(e); } } + //FIXME tchemit-20120123 : what is the need ? :( public PollAccount findPollAccount(Poll poll, UserAccount user) { - ServiceVoteImpl service = new ServiceVoteImpl(); - try { - PollAccount result = service.executeFindPollAccount(getTransaction(), poll, user); - return result; - } catch (Exception e) { - throw new PollenTechnicalException(e); + throw new UnsupportedOperationException("unsupported operation findPollAccount"); + } + + protected void checkParticipantDoubloons(PollAccountDAO dao, + Poll poll, + PollAccount participant) + throws TopiaException, VoteDoubloonException { + + TopiaQuery query = dao.createQueryFindAllParticipantsByPoll(poll); + + String participantAlias = PollenQueryHelper.ALIAS_POLL_ACCOUNT_CHILD; + + String participantNameProperty = + TopiaQuery.getProperty(participantAlias, + PollAccount.PROPERTY_NAME); + + query.addEquals(participantNameProperty, participant.getName()); + + if (StringUtils.isNotEmpty(participant.getTopiaId())) { + query.addWhere(participantAlias, TopiaQuery.Op.NEQ, participant); } + + if (dao.existByQuery(query)) { + throw new VoteDoubloonException(); + } } + /** + * Create a new participant for a running {@code poll}. The participant uid + * will be generated and the new instance of pollAccount will be added to + * the {@code poll}. + * + * @param poll Poll where the new participant will be added + * @return a new PollAccount added to the poll + * @throws TopiaException for Topia errors + */ + protected PollAccount createNewParticipant(Poll poll) + throws TopiaException { + + PollAccountDAO dao = + PollenDAOHelper.getPollAccountDAO(getTransaction()); + + // Generate new uid + String newUid = serviceContext.createPollenUrlId(); + PollAccount newParticipant = dao.create(newUid); + + // Add the new participant in poll + PollDAO pollDAO = PollenDAOHelper.getPollDAO(getTransaction()); + + Poll pollFound = pollDAO.findByTopiaId(poll.getTopiaId()); + pollFound.addPollAccount(newParticipant); + + pollDAO.update(pollFound); + return newParticipant; + } + + /** + * Save all votes from a participant. Votes will be added/updated or deleted + * depends on voteValue and existence in database. + * + * @param source PollAccount source that contains vote to save + * @param destination PollAccount destination where votes will be added to + * be persisted + * @throws TopiaException for Topia errors + */ + protected void saveParticipantVotes(PollAccount source, + PollAccount destination) + throws TopiaException { + + VoteDAO voteDAO = PollenDAOHelper.getVoteDAO(getTransaction()); + for (Vote vote : source.getChoiceVote()) { + + Vote voteToSave = voteDAO.findByTopiaId(vote.getTopiaId()); + + if (vote.getVoteValue() != 0) { + // Create vote + if (voteToSave == null) { + if (log.isDebugEnabled()) { + log.debug("Create vote for " + destination.getUid()); + } + voteToSave = voteDAO.create(); + voteToSave.setChoice(vote.getChoice()); + // Add new vote to destination participant + destination.addChoiceVote(voteToSave); + } + + // Update vote + voteToSave.setVoteValue(vote.getVoteValue()); + voteDAO.update(voteToSave); + + // Delete vote if exist and new value is 0 + } else if (voteToSave != null) { + if (log.isDebugEnabled()) { + log.debug("Delete vote for " + destination.getUid()); + } + // Normally the vote will be deleted + destination.removeChoiceVote(voteToSave); + } + } + } + + /** + * Copy from account {@code source} to {@code destination}. The {@code + * destination} will be persisted. The anonymous case is manage, properties + * that identify the person are excluded from the copy in this case. + * + * @param source PollAccount to save + * @param destination PollAccount with up to date data to persist + * @see TopiaEntityBinder#copyExcluding(Object, Object, String...) + */ + protected void copyPollAccount(PollAccount source, PollAccount destination) { + // Uid is the naturalId, don't copy it + String[] excludes = new String[]{PollAccount.PROPERTY_UID}; + + // Exclude properties for anonymous account + if (source.isAnonymous()) { + if (log.isInfoEnabled()) { + log.info("Anonymous vote, doesn't copy participant's data : " + + "name, email, userAccount"); + } + + excludes = new String[]{ + PollAccount.PROPERTY_UID, + PollAccount.PROPERTY_NAME, + PollAccount.PROPERTY_EMAIL, + PollAccount.PROPERTY_USER_ACCOUNT}; + } + + TopiaEntityBinder<PollAccount> binder = + PollenBinderHelper.getSimpleTopiaBinder(PollAccount.class); + + binder.copyExcluding(source, destination, excludes); + } + } //ServiceVote Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListAlreadyExistException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListAlreadyExistException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListAlreadyExistException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class FavoriteListAlreadyExistException extends Exception { + + private static final long serialVersionUID = 1L; + +} Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantAlreadyFoundInListException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantAlreadyFoundInListException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantAlreadyFoundInListException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class ParticipantAlreadyFoundInListException extends Exception { + + private static final long serialVersionUID = 1L; + +} Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantExistWithoutMailException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantExistWithoutMailException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/ParticipantExistWithoutMailException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class ParticipantExistWithoutMailException extends Exception { + + private static final long serialVersionUID = 1L; + +} Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyClosedException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyClosedException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyClosedException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollAlreadyClosedException extends Exception { + + private static final long serialVersionUID = 1L; + +} Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyExistException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyExistException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollAlreadyExistException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollAlreadyExistException extends Exception { + + private static final long serialVersionUID = 1L; + +} Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollNotFoundException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollNotFoundException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/PollNotFoundException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollNotFoundException extends Exception { + + private static final long serialVersionUID = 1L; + +} Copied: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserEmailAlreadyUsedException.java (from rev 3105, branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserEmailAlreadyUsedException.java) =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserEmailAlreadyUsedException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserEmailAlreadyUsedException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,36 @@ +/* + * #%L + * Pollen :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserEmailAlreadyUsedException extends Exception { + + private static final long serialVersionUID = 1L; + +} Property changes on: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserEmailAlreadyUsedException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserInvalidPasswordException.java (from rev 3105, branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserInvalidPasswordException.java) =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserInvalidPasswordException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserInvalidPasswordException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,36 @@ +/* + * #%L + * Pollen :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserInvalidPasswordException extends Exception { + + private static final long serialVersionUID = 1L; + +} Property changes on: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserInvalidPasswordException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserLoginAlreadyUsedException.java (from rev 3105, branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserLoginAlreadyUsedException.java) =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserLoginAlreadyUsedException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserLoginAlreadyUsedException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,36 @@ +/* + * #%L + * Pollen :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserLoginAlreadyUsedException extends Exception { + + private static final long serialVersionUID = 1L; + +} Property changes on: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserLoginAlreadyUsedException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserNotFoundException.java (from rev 3105, branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserNotFoundException.java) =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserNotFoundException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserNotFoundException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,36 @@ +/* + * #%L + * Pollen :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserNotFoundException extends Exception { + + private static final long serialVersionUID = 1L; + +} Property changes on: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/UserNotFoundException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteDoubloonException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteDoubloonException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteDoubloonException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoteDoubloonException extends Exception { + + private static final long serialVersionUID = 1L; + +} Added: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotAllowedException.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotAllowedException.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/VoteNotAllowedException.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -0,0 +1,13 @@ +package org.chorem.pollen.services.exceptions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoteNotAllowedException extends Exception { + + private static final long serialVersionUID = 1L; + +} Modified: branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/AbstractServiceTest.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/AbstractServiceTest.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/AbstractServiceTest.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -72,6 +72,7 @@ * @version $Id$ */ @Ignore +@Deprecated public abstract class AbstractServiceTest { protected static final String PROPERTY_CHOICE_VOTE = Modified: branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceFavoriteImplTest.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceFavoriteImplTest.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceFavoriteImplTest.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -45,6 +45,7 @@ * @author fdesbois * $Id$ */ +@Deprecated public class ServiceFavoriteImplTest extends AbstractServiceTest { private static final Log log = LogFactory.getLog(ServiceUserImplTest.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServicePollImplTest.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServicePollImplTest.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServicePollImplTest.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -61,6 +61,7 @@ * @author fdesbois <fdesbois@codelutin.com> * @version $Id$ */ +@Deprecated public class ServicePollImplTest extends AbstractServiceTest { private static final Log log = LogFactory.getLog(ServicePollImplTest.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceUserImplTest.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceUserImplTest.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceUserImplTest.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -41,6 +41,7 @@ * * @author fdesbois */ +@Deprecated public class ServiceUserImplTest extends AbstractServiceTest { private static final Log log = LogFactory.getLog(ServiceUserImplTest.class); @@ -105,6 +106,7 @@ /** * Test of executeConnect method, of class ServiceUserImpl. + * @throws Exception */ @Test public void testExecuteConnect() throws Exception { @@ -139,6 +141,7 @@ /** * Test of executeGetNewUser method, of class ServiceUserImpl. + * @throws Exception */ @Test public void testExecuteGetNewUser() throws Exception { @@ -151,6 +154,7 @@ /** * Test of executeCreateUpdateUser method, of class ServiceUserImpl. + * @throws Exception */ @Test public void testExecuteCreateUser() throws Exception { @@ -208,6 +212,7 @@ /** * Test of executeDeleteUser method, of class ServiceUserImpl. + * @throws Exception */ @Test public void testExecuteUpdateUser() throws Exception { Modified: branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceVoteImplTest.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceVoteImplTest.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/service/legacy/ServiceVoteImplTest.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -53,6 +53,7 @@ * @author fdesbois <fdesbois@codelutin.com> * @version $Id$ */ +@Deprecated public class ServiceVoteImplTest extends AbstractServiceTest { private static final Log log = LogFactory.getLog(ServiceVoteImplTest.class); Modified: branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java 2012-01-23 22:27:46 UTC (rev 3108) +++ branches/pollen-2.0-beta-1/pollen-services/src/test/java/org/chorem/pollen/services/FakeServiceContext.java 2012-01-23 22:29:31 UTC (rev 3109) @@ -28,7 +28,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenConfiguration; -import org.chorem.pollen.PollenTopiaRootContextSupplierFactory; +import org.chorem.pollen.PollenTopiaRootContextFactory; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.nuiton.topia.TopiaContext; @@ -94,8 +94,8 @@ protected void starting(Description description) { super.starting(description); description.getMethodName(); - PollenTopiaRootContextSupplierFactory factory = - new PollenTopiaRootContextSupplierFactory(); + PollenTopiaRootContextFactory factory = + new PollenTopiaRootContextFactory(); File testDir = getTestSpecificDirectory(description); if (log.isInfoEnabled()) { log.info("Test dir = " + testDir);
participants (1)
-
tchemit@users.chorem.org