Author: fdesbois Date: 2010-05-25 11:29:17 +0200 (Tue, 25 May 2010) New Revision: 3011 Url: http://chorem.org/repositories/revision/pollen/3011 Log: - Start refactor Vote page - Add pollenUtils for entities - Move votes methods in a new ServiceVote Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties trunk/pollen-business/src/main/xmi/pollen.zargo trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -121,6 +121,7 @@ // Set context in PollenProperty enum to use easily method // getValue() on PollenProperty PollenProperty.setContext(this); + PollenUtils.setContext(this); createSuperAdmin(serviceUser); // Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -0,0 +1,22 @@ +package org.chorem.pollen; + +import java.util.Date; + +/** + * Created: 21 mai 2010 + * + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + */ +public class PollenUtils { + + private static PollenContext context; + + public static void setContext(PollenContext context) { + PollenUtils.context = context; + } + + public static Date getCurrentDate() { + return context.getCurrentDate(); + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenUtils.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -1,10 +1,14 @@ package org.chorem.pollen.entity; +import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.PollenUtils; import org.chorem.pollen.common.ChoiceType; import org.chorem.pollen.common.PollType; import org.chorem.pollen.common.VoteCountingType; +import java.util.Date; + /** * PollImpl * @@ -21,26 +25,6 @@ private static final long serialVersionUID = 1L; @Override - public boolean canVote(PollAccount person) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean canAdminPoll(PollAccount person) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean canCreateChoice(PollAccount person) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean canAccessPoll(PollAccount person) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override public ChoiceType getChoiceType() { return ChoiceType.valueOf(getTypeChoice()); } @@ -71,6 +55,7 @@ } @Override + @Deprecated public Choice addNewChoice(String name, String description) { // check exist Choice choice = new ChoiceImpl(); @@ -80,4 +65,21 @@ addChoice(choice); return choice; } + + @Override + public boolean isStarted() { + Date now = PollenUtils.getCurrentDate(); + return getBeginDate() == null || getBeginDate().before(now); + } + + @Override + public boolean isFinished() { + Date now = PollenUtils.getCurrentDate(); + return getEndDate() != null && getEndDate().before(now); + } + + @Override + public boolean isRunning() { + return isStarted() && !isFinished() && !getClosed(); + } } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -269,24 +269,6 @@ } @Override - protected void executeCreateUpdateVote(TopiaContext transaction, - PollAccount person) throws TopiaException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - protected void executeDeleteVote(TopiaContext transaction, Poll poll, - PollAccount person) throws TopiaException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - protected Poll executeGetPollForUpdate(TopiaContext transaction, - String pollUId) throws PollenBusinessException, TopiaException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override protected List<Poll> executeGetAllPolls(TopiaContext transaction) throws TopiaException { throw new UnsupportedOperationException("Not supported yet."); @@ -312,25 +294,6 @@ } @Override - protected List<PollAccount> executeGetVotes(TopiaContext transaction, - Poll poll, int startIndex, int endIndex) - throws TopiaException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - protected Poll executeGetPollForResults(TopiaContext transaction, - String pollUId) throws PollenBusinessException, TopiaException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - protected Poll executeGetPollForVote(TopiaContext transaction, - String pollUId) throws PollenBusinessException, TopiaException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override protected ParticipantList executeGetNewPollList() { PollAccount list = new PollAccountImpl(); list.setList(true); @@ -380,7 +343,7 @@ @Override protected Poll executeGetPoll(TopiaContext transaction, String pollUid, String... properties) - throws TopiaException { + throws TopiaException, PollenBusinessException { PollDAO dao = PollenDAOHelper.getPollDAO(transaction); @@ -389,6 +352,10 @@ addLoad(properties); Poll result = dao.findByQuery(query); + if (result == null) { + throw new PollenBusinessException( + PollenBusinessException.PollenExceptionType.POLL_NOT_EXIST); + } return result; } Added: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -0,0 +1,68 @@ +package org.chorem.pollen.service; + +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenException; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.PollAccountImpl; +import org.chorem.pollen.entity.UserAccount; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; + +import java.util.List; + +/** + * Created: 21 mai 2010 + * + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + */ +public class ServiceVoteImpl extends ServiceVoteAbstract { + + private PollenContext context; + + public void setContext(PollenContext context) { + this.context = context; + } + + @Override + protected TopiaContext beginTransaction() throws TopiaException { + return context.beginTransaction(); + } + + @Override + protected void treateError(TopiaContext transaction, Exception eee, + String message, Object... args) throws PollenException { + context.treateError(transaction, eee, message, args); + } + + @Override + protected void closeTransaction(TopiaContext transaction) { + context.closeTransaction(transaction); + } + + @Override + protected boolean executeCanVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception { + return false; + } + + @Override + protected PollAccount executeGetNewPollAccount() throws Exception { + PollAccount account = new PollAccountImpl(); + return account; + } + + @Override + protected PollAccount executeGetPollAccount(TopiaContext transaction, String accountUid) throws Exception { + return null; + } + + @Override + protected List<PollAccount> executeGetVotes(TopiaContext transaction, Poll poll, int startIndex, int endIndex) throws Exception { + return null; + } + + @Override + protected void executeDeleteVote(TopiaContext transaction, Poll poll, PollAccount participant) throws Exception { + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceVoteImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties =================================================================== --- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-05-25 09:29:17 UTC (rev 3011) @@ -75,7 +75,12 @@ pollen.error.serviceUser.getUsers= pollen.error.serviceUser.updateFavoriteParticipant= pollen.error.serviceUser.updateUser= +pollen.error.serviceVote.canVote= +pollen.error.serviceVote.deleteVote= +pollen.error.serviceVote.getNewPollAccount= +pollen.error.serviceVote.getPollAccount= pollen.error.serviceVote.getVote= +pollen.error.serviceVote.getVotes= pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s pollen.exception.favorite_list_name_exist= Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties =================================================================== --- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-05-25 09:29:17 UTC (rev 3011) @@ -74,7 +74,12 @@ pollen.error.serviceUser.getUsers= pollen.error.serviceUser.updateFavoriteParticipant= pollen.error.serviceUser.updateUser= +pollen.error.serviceVote.canVote= +pollen.error.serviceVote.deleteVote= +pollen.error.serviceVote.getNewPollAccount= +pollen.error.serviceVote.getPollAccount= pollen.error.serviceVote.getVote= +pollen.error.serviceVote.getVotes= pollen.error.serviceVote.getVotesByPoll= pollen.error.serviceVote.hasAlreadyVoted= pollen.exception.favorite_list_name_exist=La liste %1$s existe d\u00E9j\u00E0 pour l'utilisateur %2$s Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/PollFormModel.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -4,6 +4,7 @@ import org.apache.tapestry5.ValueEncoder; import org.apache.tapestry5.ioc.Messages; import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.PollenException; import org.chorem.pollen.common.PollType; import org.chorem.pollen.entity.Choice; import org.chorem.pollen.entity.ParticipantList; @@ -99,7 +100,8 @@ * @param user Connected user as creator of a new poll (can be null * if no user is connected). */ - public void initPoll(ServicePoll servicePoll, String uid, UserAccount user) { + public void initPoll(ServicePoll servicePoll, String uid, UserAccount user) + throws PollenBusinessException { if (StringUtils.isNotEmpty(uid)) { if (logger.isDebugEnabled()) { logger.debug("Get existing poll with pollUID = " + uid); Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -0,0 +1,61 @@ +package org.chorem.pollen.ui.models; + +import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.service.ServiceVote; +import org.chorem.pollen.ui.data.PollUri; + +/** + * Created: 21 mai 2010 + * + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + */ +public class VoteModel { + + protected Poll poll; + + protected PollAccount account; + + protected ServicePoll servicePoll; + + protected ServiceVote serviceVote; + + public VoteModel(ServicePoll servicePoll, ServiceVote serviceVote) { + this.servicePoll = servicePoll; + } + + public void init(PollUri uri) + throws PollenBusinessException { + poll = servicePoll.getPoll(uri.getPollUid()); + account = serviceVote.getPollAccount(uri.getAccountUid()); + } + + public Poll getPoll() { + return poll; + } + + public boolean isCreatorUser(UserAccount user) { + return user.equals(poll.getCreator().getUserAccount()); + } + + public PollAccount getPollAccount() { + if (account == null) { + account = serviceVote.getNewPollAccount(); + } + return account; + } + + public boolean isAllowedToVote() { + if (poll.isFinished()) { + return false; + } + if (poll.getPollType().isRestrictedOrGroup() || poll.getAnonymous()) { + return serviceVote.canVote(poll, account); + } + return true; + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/models/VoteModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -173,7 +173,12 @@ logger.debug("-------- NEW POLL FORM MODEL --------"); } model = new PollFormModel(); - model.initPoll(servicePoll, pollUID, getUserConnected()); + try { + model.initPoll(servicePoll, pollUID, getUserConnected()); + } catch (PollenBusinessException eee) { + String message = manager.getErrorMessage(logger, messages, eee); + addFatal(message); + } } return model; } @@ -394,7 +399,7 @@ /** Flag if submit comes from lists edition */ private boolean editLists; - protected static final String EVENT_UPDATE_POLL_TYPE = "updateFromPollType"; + protected static final String EVENT_UPDATE_POLL_TYPE = "updatePollType"; /** DATA ** */ @@ -437,7 +442,7 @@ } @Log - Object onUpdateFromPollType(String value) { + Object onUpdatePollType(String value) { getModel().setPollType(servicePoll, manager, PollType.valueOf(value)); return refreshListZone(); } @@ -658,11 +663,18 @@ pollLinks.setPollUri(uri); // Send an email to the creator if (creator.getEmail() != null) { - if (!sendCreatorEmail(creator, uri)) { - return mainZone; + try { + sendCreatorEmail(creator, uri); + pollLinks.addInfo(messages.get( + "pollen.ui.poll.links.creatorEmail.success")); + } catch (PollenBusinessException eee) { + String message = + manager.getErrorMessage(logger, messages, eee); + pollLinks.addError(message); } } else { - pollLinks.addInfo("pollen.ui.poll.links.creatorEmail.notDefined"); + pollLinks.addInfo(messages.get( + "pollen.ui.poll.links.creatorEmail.notDefined")); } if (getPoll().getPollType().isRestrictedOrGroup()) { pollLinks.addInfo("Les votants ont reçu un mail !"); @@ -672,7 +684,8 @@ return mainZone; } - protected boolean sendCreatorEmail(PollAccount creator, PollUri uri) { + protected void sendCreatorEmail(PollAccount creator, PollUri uri) + throws PollenBusinessException { PollenEmail email = new PollenEmailImpl(); email.setTo(creator.getEmail()); email.setSubject(messages.format( @@ -684,15 +697,8 @@ servicePollUri.getVoteUrl(uri), servicePollUri.getModerateVoteUrl(uri), servicePollUri.getPollUpdateUrl(uri))); - try { - serviceEmail.sendEmail(email); - pollLinks.addInfo("pollen.ui.poll.links.creatorEmail.success"); - } catch (PollenBusinessException eee) { - String message = manager.getErrorMessage(logger, messages, eee); - addError(message); - return false; - } - return true; + + serviceEmail.sendEmail(email); } @Log Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollLinks.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -4,6 +4,7 @@ import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.PageRenderLinkSource; +import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.base.AbstractPollenPage; @@ -69,7 +70,7 @@ } } - public boolean isPollNull() { + public boolean isPollNull() throws PollenBusinessException { return getPoll() == null; } @@ -77,7 +78,7 @@ this.pollUri = pollUri; } - public Poll getPoll() { + public Poll getPoll() throws PollenBusinessException { if (pollUri != null) { poll = servicePoll.getPoll(pollUri.getPollUid()); } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -478,7 +478,7 @@ if (id != null && !"".equals(id)) { pollId = id.split(":", 2)[0]; - poll = servicePoll.getPollForResults(pollId); + //poll = servicePoll.getPollForResults(pollId); if (poll != null) { Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -50,12 +50,14 @@ import org.chorem.pollen.entity.Vote; import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.service.ServiceVote; import org.chorem.pollen.ui.base.AbstractUploadPage; import org.chorem.pollen.ui.components.Border; import org.chorem.pollen.ui.components.Pager; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.data.ChoiceField; import org.chorem.pollen.ui.data.PollUri; +import org.chorem.pollen.ui.models.VoteModel; import org.chorem.pollen.ui.services.PollenManager; import org.chorem.pollen.ui.services.ServiceImage; import org.nuiton.web.tapestry5.components.FeedBack; @@ -79,860 +81,9 @@ public Border getBorder() { return border; } -// -// @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") -// @Property -// private String title; -// -// /** Paramètres de la page */ -// private String param; -// -// /** Affichage des messages pour l'utilisateur */ -// @Component(id = "feedback") -// private FeedBack feedback; -// -// -// /** -// * Objet de session représentant l'url du site. -// */ -// @SessionState -// @Property -// private String siteURL; -// -// @Component -// private Form voteForm; -// -//// @Component(id = "pollAccountName") -//// private TextField nameField; -// -//// /** Composant DateTimeField pour les choix du sondage */ -//// @SuppressWarnings("unused") -//// @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) -//// private DateTimeField dateDTF; -// -// /** Locale courante */ -// @Inject -// private Locale currentLocale; -// -// @Inject -// private Logger logger; -// -// @Inject -// private Messages messages; -// -// /** -// * Vote courant de l'utilisateur -// */ -// @Property -// private Vote vote; -// -// /** Choix courant du sondage */ -// @Property -// private Choice choiceOfPoll; -// /** Choix courant du nouveau vote */ -// @Property -// private Choice choiceOfVote; -// -// /** Résultats du sondage */ -// @Persist -// private List<Result> results; -// -// /** -// * Modèle pour l'affichage de la liste des sondages -// */ -// @SuppressWarnings( { "unchecked", "unused" }) -// @Property -// @Retain -// private BeanModel voteModel; -// -// /*@InjectPage -// private ImageDisplay imageDisplay;*/ -// -//// @InjectComponent -//// private Zone pollZone; -// -// /** -// * Objet servant à changer la couleur à chaque ligne de la liste des -// * sondages -// */ -// @SuppressWarnings("unused") -// @Property -// private EvenOdd evenOdd = new EvenOdd(); -// -// /** Choix courant (type texte) */ -// private boolean addChoice; -// -// /** Le votant a déjà voté ? */ -// private boolean alreadyVoted; -// -// /** Le vote est anonyme */ -// @Property -// private boolean anonymousVote = false; -// -// /** Liste des choix */ -//// private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>(); -// -// /** Identifiant du compte correspondant à l'adresse forgée */ -//// private String pollAccountId; -// -// /** Compte du votant */ -//// @Property -//// private PollAccountDTO pollAccount; -// -//// /** Nouveau choix de type texte */ -//// @Property -//// @Persist -//// private ChoiceDTO newChoice; -// -// /** Nouveau choix de type date */ -// @Property -// @Persist -// private DateChoiceUIO newDateChoice; -// -// /** Nouveau choix de type image */ -// @Property -// @Persist -// private ImageChoiceUIO newImageChoice; -// -// /** Injection des services */ -// @Inject -// private ServicePoll servicePoll; -// @Inject -// private ServiceVote serviceVote; -// -// @Inject -// private ServicePollAccount servicePollAccount; -// @Inject -// private ServiceResults serviceResults; -// -// /** -// * Composant pour la gestion des flux RSS -// */ -// @InjectComponent -// private ContextLink feedContext; -// -// /** -// * Context to get feed of the current poll -// * @return a FeedContext defined in .tml file -// */ -// public ContextLink getFeedContext() { -// return feedContext; -// } -// -//// /** -//// * Composant pour la gestion des upload d'images -//// */ -//// @InjectComponent -//// private ImageContextLink imgContext; -//// -//// /** -//// * Context to get images for choices. -//// * @return an ImageContextLink defined in .tml file -//// */ -//// public ImageContextLink getImgContext() { -//// return imgContext; -//// } -// -// @InjectComponent -// private FeedBack voteFeedback; -// -// public String getVoteSizeMessage() throws PollenBusinessException { -// if (log.isDebugEnabled()) { -// log.debug("poll voteDTOs list size : " + getVotes().size()); -// log.debug("poll nbVotes : " + getPoll().getNbVotes()); -// } -// return messages.format("vote-size", getPoll().getNbVotes()); -// } -// -// /** Méthode appelée après la soumission du vote. */ -//// @Log -//// Object onSuccessFromVoteForm() throws PollenBusinessException { -//// if (initPollAccount()) { -//// List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>(); -//// if (getPoll().getVoteCounting() == VoteCountingType.NORMAL) { -//// int nbChoices = 0; -//// for (ChoiceDTO choice : getPoll().getChoices()) { -//// if (choice.getValue() == 1) { -//// nbChoices++; -//// } -//// choiceDTOs.add(choice); -//// } -//// if (nbChoices > getPoll().getMaxChoiceNb()) { -//// voteForm.recordError(messages.format(("tooManyChoices"), -//// getPoll().getMaxChoiceNb())); -//// return pollZone.getBody(); -//// } -//// -//// } else if (getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE) { -//// int total = 0; -//// for (ChoiceDTO choice : getPoll().getChoices()) { -//// total = total + choice.getValue(); -//// choiceDTOs.add(choice); -//// } -//// if (total != 100) { -//// voteForm.recordError(messages.get("not100percent")); -//// return pollZone.getBody(); -//// } -//// -//// } else if (getPoll().getVoteCounting() == VoteCountingType.CONDORCET) { -//// for (ChoiceDTO choice : getPoll().getChoices()) { -//// if (choice.getValue() == 0) { -//// choice.setValue(100); -//// } -//// choiceDTOs.add(choice); -//// } -//// -//// } else if (getPoll().getVoteCounting() == VoteCountingType.NUMBER) { -//// String votingId = pollAccount.getVotingId(); -//// if (anonymousVote) { -//// votingId = "anonymous" + UUID.randomUUID().toString().replaceAll("-", ""); -//// } -//// -//// for (ChoiceDTO choice : getPoll().getChoices()) { -//// if (!choice.isHidden()) { -//// choiceDTOs.add(choice); -//// -//// // creates a new hidden choice -////// ChoiceDTO hiddenChoice = new ChoiceDTO(); -////// hiddenChoice.setName(NumberMethod.HIDDEN_PREFIX + -////// choice.getName() + "#" + votingId); -////// hiddenChoice.setHidden(true); -////// hiddenChoice.setValue(choice.getValue()); -////// hiddenChoice.setPollId(choice.getPollId()); -////// hiddenChoice.setVoteId(choice.getVoteId()); -////// hiddenChoice.setValidate(false); -//// ChoiceDTO hiddenChoice = -//// servicePoll.getNewHiddenChoice(choice, votingId); -//// -//// String choiceId = -//// serviceChoice.createChoice(hiddenChoice); -//// hiddenChoice.setId(choiceId); -//// choiceDTOs.add(hiddenChoice); -//// } -//// } -//// } -//// -//// VoteDTO vote = new VoteDTO(null, getPoll().getId(), null); -//// vote.setChoiceDTOs(choiceDTOs); -//// vote.setWeight(pollAccount.getWeight()); -//// vote.setAnonymous(anonymousVote); -//// -//// // mise à jour du vote ou création d'un nouveau vote -//// if (alreadyVoted) { -//// for (VoteDTO v : getVotes()) { -//// PollAccountDTO voteAccount = servicePollAccount -//// .findPollAccountById(v.getPollAccountId()); -//// -//// if (voteAccount.getVotingId().equals(getPollAccount().getVotingId())) { -//// vote.setId(v.getId()); -//// deleteVote(vote.getId()); -//// serviceVote.createVote(vote, getPollAccount()); -//// } -//// } -//// } else { -//// serviceVote.createVote(vote, getPollAccount()); -//// } -//// -//// // Mise à jour du sondage et des résultats -//// //poll = servicePoll.findPollByPollId(getPoll().getPollId()); -//// poll = null; -//// countPoll(); -//// -//// addFeedEntry(PollAction.ADDVOTE, getPollAccount().getVotingId(), -//// getResultsAsString()); -//// sendMailNotification(); -//// voteFeedback.addInfo(messages.get("vote-success")); -//// page = pager.getLastPage(); -//// // Reset votes to reload them depends on page change. -//// votes = null; -//// return this; -//// } -////// voteChoices.clear(); -//// return pollZone.getBody(); -//// } -// -//// private void deleteVote(String voteId) throws PollenBusinessException { -//// for (VoteDTO vote : getVotes()) { -//// if (vote.getId().equals(voteId)) { -//// -//// List<ChoiceDTO> choiceDTOs = vote.getChoiceDTOs(); -//// for (ChoiceDTO choiceDTO : choiceDTOs) { -//// -//// if (choiceDTO.isHidden()) { -//// serviceChoice.deleteChoice(choiceDTO.getId()); -//// } -//// } -//// -//// break; -//// } -//// } -//// -//// serviceVote.deleteVote(voteId); -//// } -//// -//// /** Méthode appelée lors de la suppression d'un vote. */ -//// Object onActionFromDeleteVote(String voteId) throws PollenBusinessException { -//// deleteVote(voteId); -//// -//// // Mise à jour du sondage et des résultats -////// poll = servicePoll.findPollByPollId(poll.getPollId()); -//// poll = null; -//// countPoll(); -//// -//// return pollZone.getBody(); -//// } -// -// /** Initialisation du pollAccount et contrôle du nom. */ -//// private boolean initPollAccount() throws PollenBusinessException { -//// -//// //// Contrôle et définition du votingId -//// alreadyVoted = false; -//// boolean modifAllowed = false; -//// boolean restrictedListsForbidden = false; -//// -//// // Suppression des espaces pouvant provoquer un double vote -//// String votingId = getPollAccount().getVotingId().trim(); -//// getPollAccount().setVotingId(votingId); -//// -//// // Contrôle de la présence du votant dans les listes de votants -//// // du sondage (si le sondage n'est pas libre) -////// if (!isFreePoll()) { -////// restrictedListsForbidden = true; -////// for (VotingListDTO list : poll.getVotingListDTOs()) { -////// for (PollAccountDTO account : list.getPollAccountDTOs()) { -////// if (pollAccount.getVotingId().equals(account.getVotingId())) { -////// restrictedListsForbidden = false; -////// pollAccount = servicePollAccount -////// .findPollAccountById(account.getId()); -////// pollAccount.setVotingListId(list.getId()); -////// pollAccount.setWeight(account.getWeight()); -////// logger.debug("Compte \"" + account.getVotingId() -////// + "\" présent dans la liste \"" -////// + list.getName() + "\" (poids=" -////// + account.getWeight() + ")"); -////// } -////// } -////// } -////// } -//// -//// // The calcul of alreadyVoted will be needed for no double votingId -//// // Carefull, not correct for an anonymous vote -//// alreadyVoted = serviceVote.hasAlreadyVoted(votingId, getPoll()); -//// -//// // Check for restricted poll -//// if (!alreadyVoted && !isFreePoll()) { -//// if (uri.getAccountUid() != null) { -//// // The accountUid must be valid for the poll -//// PollAccountDTO restrictedAccount = -//// servicePoll.getRestrictedAccount(uri.getAccountUid(), getPoll()); -//// -//// if (restrictedAccount != null) { -//// // PollAccount is replaced by the good account from db -//// pollAccount = restrictedAccount; -//// // Refresh alreadyVoted value depends on getPollAccount() -//// alreadyVoted = getPollAccount().isHasVoted(); -//// // Existing account is null is forbidden for a restricted poll -//// } else { -//// restrictedListsForbidden = true; -//// } -//// // Not allowed to vote without an accountUid -//// } else { -//// restrictedListsForbidden = true; -//// } -//// -//// if (restrictedListsForbidden) { -////// voteForm.recordError(nameField, -////// messages.get("restrictedListsForbidden")); -//// } -//// } -//// -//// // Génération d'un identifiant de vote (si le sondage est libre et anonyme) -//// if (getPoll().isAnonymous()) { -//// anonymousVote = true; -//// if (isFreePoll()) { -//// getPollAccount().setVotingId("anonymous" -//// + UUID.randomUUID().toString().replaceAll("-", "")); -//// } -//// } -//// -//// //// Définition de l'userId -//// if (userExists) { -//// getPollAccount().setUserId(user.getId()); -//// } else { -//// getPollAccount().setUserId(""); -//// } -//// -//// modifAllowed = isModifAllowed(getPollAccount().getVotingId()); -//// if (alreadyVoted && !modifAllowed) { -////// voteForm.recordError(nameField, messages.format("alreadyVoted", -////// getPollAccount().getVotingId())); -//// } -//// -//// logger.debug("votingId: " + getPollAccount().getVotingId()); -//// logger.debug("alreadyVoted: " + alreadyVoted); -//// logger.debug("modifAllowed: " + modifAllowed); -//// logger.debug("restrictedListsForbidden: " + restrictedListsForbidden); -//// return ((!alreadyVoted || modifAllowed) && !restrictedListsForbidden); -//// } -// -// /** -// * Retourne vrai si la modification du vote est autorisée. C'est à dire si -// * l'utilisateur connecté est l'auteur du vote ou si le votant défini par -// * l'url est l'auteur du vote. -// * -// * @param votingId le votant a rechercher -// * @return vrai si la modification du vote est autorisée -// */ -//// public boolean isModifAllowed(String votingId) throws PollenBusinessException { -//// boolean modifAllowed = false; -//// int i = 0; -//// -//// // parcours des votes pour trouver celui correspondant au votingId -//// // et contrôle du droit de modification -//// while (i < getVotes().size() && !modifAllowed) { -//// -//// // account : compte associé au vote courant -//// //String id = getVotes().get(i).getPollAccountId(); -//// //PollAccountDTO account = servicePollAccount.findPollAccountById(id); -//// VoteDTO curr = getVotes().get(i); -//// -//// // si le votant du vote correspond au votingId -//// if (curr.getName().equals(votingId)) { -//// if (logger.isDebugEnabled()) { -//// logger.debug("vote name: " + curr.getName()); -//// logger.debug("vote account: " + curr.getPollAccountId()); -////// logger.debug("voting account: " + pollAccountId); -//// } -//// -//// // si le votant du vote correspond au votant actuel (pollAccountId) -////// if (pollAccountId != null -////// && pollAccountId.equals(curr.getPollAccountId())) { -////// modifAllowed = true; -////// } -//// -//// // si l'utilisateur du vote correspond à l'utilisateur actuel (user) -//// if (userExists && user.getId().length() > 0) { -//// modifAllowed = user.getId().equals(curr.getUserId()); -//// } -//// } -//// -//// i++; -//// } -//// -//// return modifAllowed; -//// } -// -// /** Ajout d'une entrée dans le flux de syndication */ -// private void addFeedEntry(PollAction pollAction, String titleStr, -// String contentStr) throws PollenBusinessException { -// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUid(); -// File feedFile = getFeedContext().getFile(getPoll().getPollUid()); -// String title = null; -// String content = null; -// -// switch (pollAction) { -// case ADDVOTE: -// if (isVoteAnonymous()) { -// titleStr = messages.get("anonymous"); -// } -// title = messages.format("pollFeed_voteTitle", titleStr); -// content = messages.format("pollFeed_voteContent", contentStr); -// break; -// case ADDCHOICE: -// title = messages.format("pollFeed_choiceTitle", titleStr); -// content = messages.format("pollFeed_choiceContent", contentStr); -// break; -// case ADDCOMMENT: -// title = messages.format("pollFeed_commentTitle", titleStr); -// content = messages.format("pollFeed_commentContent", contentStr); -// break; -// } -// -// if (!feedFile.exists()) { -// FeedUtil.createFeed(feedFile, "atom_1.0", messages.format( -// "pollFeed_title", getPoll().getTitle()), siteURL, messages -// .format("pollFeed_desc", getPoll().getDescription())); -// } -// FeedUtil.feedFeed(feedFile, title, voteURL, content); -// } -// -// /** Envoi du mail de notification */ -// private void sendMailNotification() throws PollenBusinessException { -// String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUid(); -// String modifURL = siteURL + "poll/Modification/" + getPoll().getPollUid() -// + ":" + MD5.encode(getPoll().getCreatorId()); -// Map<String, String> data = new HashMap<String, String>(); -// data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST)); -// data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT)); -// data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM)); -// -// // Mail au créateur -// data.put("to", getPoll().getCreatorEmail()); -// data.put("title", messages.format("voteEmail_subject", getPoll().getTitle())); -// data.put("msg", messages.format("voteEmail_msg", getPoll().getTitle(), getPoll() -// .getNbVotes(), voteURL, modifURL)); -// -// for (PreventRuleDTO rule : getPoll().getPreventRuleDTOs()) { -// PreventRuleManager manager = new PreventRuleManager(rule); -// manager.execute("vote", getVotes().size(), data); -// } -// } -// -// public boolean isAddChoice() { -// return addChoice; -// } -// -// public void setAddChoice(boolean addChoice) { -// choiceOfVote.setValue((addChoice) ? 1 : 0); -// } -// -// public void setAddNumberVote(Integer value) { -// if (value != null) { -// choiceOfVote.setValue(value); -// -// } else { -// choiceOfVote.setValue(-1); -// } -// } -// -// public Integer getAddNumberVote() { -// return null; -// } -// -// -// /** -// * Retourne si le choix fait partie du vote (s'il a été renseigné par le -// * votant). -// * -// * @param choice le choix concerné -// * @return true si le choix est dans le vote -// */ -// public Boolean isChoiceInVote(ChoiceDTO choice) throws PollenBusinessException { -// if (choice != null) { -// switch (getPoll().getVoteCounting()) { -// case NORMAL: -// return choice.getValue() > 0; -// case PERCENTAGE: -// return true; -// case CONDORCET: -// return choice.getValue() < 100; -// case NUMBER: -// return choice.getValue() >= 0; -// } -// } -// return null; -// } -// -// public boolean isChoiceHidden() { -// return choiceOfPoll.isHidden(); -// } -// -// /** -// * Retourne le choix de vote correspondant au choix de sondage courant. -// * -// * @return un choix de vote -// */ -// @Property(write = false) -// private ChoiceDTO currentVoteChoice; -// -// public char setCurrentVoteChoice() { -//// currentVoteChoice = null; -//// for (ChoiceDTO choice : vote.getChoiceDTOs()) { -//// if (choice.getId().equals(choiceOfPoll.getId())) { -//// currentVoteChoice = choice; -//// break; -//// } -//// } -// -// return 0; -// } -// -// /** -// * Retourne le résultat correspondant au choix de sondage courant. -// * -// * @return le résultat du choix -// */ -// public String getCurrentChoiceResult() { -// String val = ""; -// for (ResultDTO result : results) { -// if (result.getName().equals(choiceOfPoll.getName())) { -// val = removeTrailing0(result.getValue()); -// } -// } -// return val; -// } -// -// /** -// * Vérifie que le fichier de flux de syndication existe. -// * -// * @return vrai si le fichier existe -// */ -// @Log -// public boolean isFeedFileExisting() throws PollenBusinessException { -// File feedFile = getFeedContext().getFile(getPoll().getPollUid()); -// if (log.isDebugEnabled()) { -// log.debug("feed context path : " + getFeedContext().getContextPath()); -// log.debug("feed absolute path : " + feedFile.getAbsolutePath()); -// } -// return feedFile.exists() ? true : false; -// } -// -// /** -// * Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un -// * double : 1,0 -> 1 et 1,2 -> 1,2. -// * -// * @param val le nombre -// * @return le nombre sans 0 final -// */ -// private String removeTrailing0(String val) { -// if (val.endsWith(".0")) { -// val = val.substring(0, val.indexOf('.')); -// } -// return val; -// } -// -// /** -// * Retourne une chaîne contenant les résultats du sondage. -// * -// * @return les résultats -// */ -// public String getResultsAsString() throws PollenBusinessException { -// StringBuffer res = new StringBuffer(""); -// Iterator<ResultDTO> it = results.iterator(); -// while (it.hasNext()) { -// ResultDTO result = it.next(); -// if (isDateType()) { -// Date date = new Date(Long.parseLong(result.getName())); -// res.append(dateFormat.format(date)); -// } else { -// res.append(result.getName()); -// } -// res.append("=" + removeTrailing0(result.getValue())); -// if (it.hasNext()) { -// res.append(", "); -// } -// } -// return res.toString(); -// } -// -// /** -// * Retourne true si le sondage est anonyme ou si le vote soumis est anonyme. -// * Utilisé lors de la soumission d'un vote. -// * -// * @return true si le vote est anonyme -// */ -// public boolean isVoteAnonymous() throws PollenBusinessException { -// return getPoll().isAnonymous() || anonymousVote; -// } -// -// /** -// * Retourne true si le sondage est anonyme ou si le vote courant est -// * anonyme. Utilisé dans la boucle de parcours des votes. -// * -// * @return true si le vote est anonyme -// */ -// public boolean isCurrentVoteAnonymous() throws PollenBusinessException { -// return getPoll().isAnonymous() || vote.isAnonymous(); -// } -// -// /** Retourne vrai si la checkbox anonymousVote doit être affichée. */ -// public boolean isAnonymousVoteDisplayed() throws PollenBusinessException { -// return getPoll().isAnonymousVoteAllowed() && !getPoll().isAnonymous(); -// } -// -// /** Retourne l'identifiant du votant du vote courant */ -// public String getCurrentVotingId() { -// return vote.getName(); -// } -// -// /** Validation du champs de saisie du choix (texte). */ -// void onValidateFromTextName(String value) throws ValidationException, PollenBusinessException { -// validateNewChoice(value); -// } -// -// /** Validation du champs de saisie du choix (date). */ -// void onValidateFromDateDTF(Date value) throws ValidationException, PollenBusinessException { -// validateNewChoice(String.valueOf(value.getTime())); -// } -// -// /** Validation du champs de saisie du choix (image). */ -// void onValidateFromImgFile(UploadedFile value) throws ValidationException, PollenBusinessException { -// validateNewChoice(value.getFileName().replace(' ', '_')); -// } -// -// /** Validation du champs de saisie du choix. */ -// private void validateNewChoice(String value) throws ValidationException, PollenBusinessException { -// for (ChoiceDTO choice : getPoll().getChoices()) { -// if (value.equals(choice.getName())) { -// throw new ValidationException(messages.format("choiceExists", -// value)); -// } -// } -// } -// -// /** Méthode appelée lors de l'ajout d'un choix. */ -// Object onSuccessFromChoiceForm() throws PollenBusinessException { -// String choiceName = null; -// String choiceDesc = null; -// if (isTextType()) { -// if (newChoice.getName() != null) { -// newChoice.setValidate(true); -// newChoice.setPollUid(getPoll().getPollUid()); -// getPoll().getChoices().add(newChoice); -// choiceName = newChoice.getName(); -// choiceDesc = newChoice.getDescription(); -// } -// } else if (isDateType()) { -// if (newDateChoice.getDate() != null) { -// newDateChoice.setValidate(true); -// newDateChoice.setPollUid(getPoll().getPollUid()); -// newDateChoice.setName(String.valueOf(newDateChoice.getDate() -// .getTime())); -// getPoll().getChoices().add(newDateChoice); -// Date date = new Date(Long.parseLong(newDateChoice.getName())); -// choiceName = dateFormat.format(date); -// choiceDesc = newDateChoice.getDescription(); -// } -// } else if (isImageType()) { -// if (newImageChoice.getImg() != null) { -// newImageChoice.setValidate(true); -// newImageChoice.setPollUid(getPoll().getPollUid()); -// newImageChoice.setName(newImageChoice.getImg().getFileName() -// .replace(' ', '_')); -// getPoll().getChoices().add(newImageChoice); -// //File imgFile = getImgContext().getImageDir(); // dir set in getImgContext() -//// File imgFile = getImgContext().getImageDir(); // dir set in getImgContext() -//// ImageUtil.saveImage(newImageChoice, imgFile); -// choiceName = newImageChoice.getName(); -// choiceDesc = newImageChoice.getDescription(); -// } -// } -// -// servicePoll.updatePoll(getPoll()); -// poll = null; -// //poll = servicePoll.findPollByPollId(getPoll().getPollId()); -// addFeedEntry(PollAction.ADDCHOICE, choiceName, choiceDesc); -//// newChoice = new ChoiceDTO(); -//// newDateChoice = new DateChoiceUIO(); -//// newImageChoice = new ImageChoiceUIO(); -// return this; -// } -// -//// public boolean isPollNull() { -//// return poll == null; -//// } -// -// -// public boolean isPollChoiceOrVoteStarted() throws PollenBusinessException { -// return isPollChoiceStarted() || isPollStarted(); -// } -// -//// public boolean isDescNull() { -//// return choiceOfPoll.getDescription() == null -//// || "".equals(choiceOfPoll.getDescription()); -//// } -// -// -// public boolean isFreePoll() throws PollenBusinessException { -// return getPoll().getPollType() == PollType.FREE; -// } -// -// public boolean isRestrictedPoll() throws PollenBusinessException { -// return getPoll().getPollType() == PollType.RESTRICTED; -// } -// -// public boolean isGroupPoll() throws PollenBusinessException { -// return getPoll().getPollType() == PollType.GROUP; -// } -// -// public boolean isTextType() throws PollenBusinessException { -// return getPoll().getChoiceType() == ChoiceType.TEXT; -// } -// -// public boolean isDateType() throws PollenBusinessException { -// return getPoll().getChoiceType() == ChoiceType.DATE; -// } -// -// public boolean isImageType() throws PollenBusinessException { -// return getPoll().getChoiceType() == ChoiceType.IMAGE; -// } -// -// public boolean isNormalVoteCounting() throws PollenBusinessException { -// return getPoll().getVoteCounting() == VoteCountingType.NORMAL; -// } -// -// public boolean isPercentageVoteCounting() throws PollenBusinessException { -// return getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE; -// } -// -// public boolean isCondorcetVoteCounting() throws PollenBusinessException { -// return getPoll().getVoteCounting() == VoteCountingType.CONDORCET; -// } -// -// public boolean isNumberVoteCounting() throws PollenBusinessException { -// return getPoll().getVoteCounting() == VoteCountingType.NUMBER; -// } -// -// /** Retourne le message d'aide correspondant au type de sondage. */ -// public String getHelpMessage() throws PollenBusinessException { -// switch (getPoll().getVoteCounting()) { -// case NORMAL: -// return messages.get("normalVote-help"); -// case PERCENTAGE: -// return messages.get("percentageVote-help"); -// case CONDORCET: -// return messages.get("condorcetVote-help"); -// case NUMBER: -// return messages.get("numberVote-help"); -// default: -// return ""; -// } -// } -// -// /** -// * Retourne la date correspondant au choix courant -// * -// * @return date -// */ -// public Date getChoiceNameAsDate() { -// return new Date(Long.valueOf(choiceOfPoll.getName())); -// } -// -// /** Dépouillement du sondage. Mise à jour des résultats. */ -// private void countPoll() throws PollenBusinessException { -// ResultListDTO resultListDTO = null; -// if (getPoll().getContinuousResults()) { -// -// if (isGroupPoll()) { -// resultListDTO = serviceResults.getGroupResults(getPoll().getPollUid()); -// } else { -// resultListDTO = serviceResults.getNormalResults(getPoll().getPollUid()); -// } -// -// results = resultListDTO.getResultDTOs(); -// -// if (logger.isDebugEnabled()) { -// for (ResultDTO res : results) { -// logger.debug(res.getName() + ": " + res.getValue() -// + ", (voteCounting=" + res.getVoteCounting() -// + ", byGroup=" + res.isByGroup() + ")"); -// } -// } -// } -// } - - - - - - - - - ////////////////// NEW IMPLEMENTATION - @Inject - private Logger log; + private Logger logger; @Inject private Messages messages; @@ -944,8 +95,8 @@ private PollUri uri; /** TEMP : Affichage des messages pour l'utilisateur */ - @Component(id = "feedback") - private FeedBack feedback; +// @Component(id = "feedback") +// private FeedBack feedback; @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property @@ -960,15 +111,9 @@ @Inject private ServiceUser serviceUser; - - /** - * Sondage pour lequel l'utilisateur vote - */ - @Persist - private Poll poll; - @Property - private boolean pollNull; + @Inject + private ServiceVote serviceVote; /** Compte du votant */ private PollAccount pollAccount; @@ -976,11 +121,18 @@ /** Format des dates */ private DateFormat dateFormat; + @Persist + private VoteModel model; + /** - * Méthode appelée au moment de l'activation de la page + * Address bar of the page. Display in Border layout component. * - * @param id l'identifiant du sondage et du votant + * @return the address bar of the page. */ + public AddressBar getAddressBar() { + return AddressBar.newBar().appendCurrent(title); + } + void onActivate(EventContext ec) throws PollenBusinessException { uri = ec.get(PollUri.class, 0); if (ec.getCount() > 1) { @@ -988,49 +140,54 @@ } } - /** - * Méthode appelée au moment de la désactivation de la page - * - * @return l'identifiant du sondage et du votant - */ Object[] onPassivate() { return new Object[]{uri, page}; } - /** - * Initialisation de l'affichage - */ + @Log void setupRender() { - try { - poll = null; - getPoll(); - - if (getPoll().getClosed()) { - feedback.addInfo(messages.get("pollClosed")); - } else if (!isPollStarted()) { - feedback.addInfo(messages.get("pollNotStarted")); - } else if (isPollFinished()) { - feedback.addInfo(messages.get("pollFinished")); + if (uri == null) { + addFatal("Url null"); + } else { + model = null; + try { + getModel().init(uri); + } catch (PollenBusinessException eee) { + // Poll not found + String message = manager.getErrorMessage(logger, messages, eee); + addFatal(message); } - if (isPollChoiceRunning()) { - feedback.addInfo(messages.get("pollChoiceRunning")); - } - - //countPoll(); - } catch (PollenBusinessException eee) { - feedback.addError(messages.get(eee.getMessage())); - pollNull = true; } + + +// try { +// poll = null; +// getPoll(); +// +// if (getPoll().getClosed()) { +// addInfo(messages.get("pollClosed")); +// } else if (!isPollStarted()) { +// addInfo(messages.get("pollNotStarted")); +// } else if (isPollFinished()) { +// addInfo(messages.get("pollFinished")); +// } +// if (isPollChoiceRunning()) { +// addInfo(messages.get("pollChoiceRunning")); +// } +// +// //countPoll(); +// } catch (PollenBusinessException eee) { +// addError(messages.get(eee.getMessage())); +// pollNull = true; +// } } - /** - * Address bar of the page. Display in Border layout component. - * - * @return the address bar of the page. - */ - public AddressBar getAddress() { - return AddressBar.newBar().appendCurrent(title); + public VoteModel getModel() { + if (model != null) { + model = new VoteModel(servicePoll, serviceVote); + } + return model; } /** @@ -1046,40 +203,10 @@ return dateFormat; } - public Poll getPoll() throws PollenBusinessException { - if (poll == null) { - poll = servicePoll.getPollForVote(uri.getPollUid()); - - if (poll != null) { - - // Initialisations pour les formulaires -// newChoice = new ChoiceDTO(); -// newDateChoice = new DateChoiceUIO(); -// newImageChoice = new ImageChoiceUIO(); - } else { - throw new PollenBusinessException( - PollenExceptionType.POLL_NOT_EXIST); - } - } - return poll; + public Poll getPoll() { + return getModel().getPoll(); } - public boolean isPollStarted() throws PollenBusinessException { - Date now = new Date(); - return getPoll().getBeginDate() == null || - getPoll().getBeginDate().before(now); - } - - public boolean isPollFinished() throws PollenBusinessException { - Date now = new Date(); - return getPoll().getEndDate() != null && - getPoll().getEndDate().before(now); - } - - public boolean isPollRunning() throws PollenBusinessException { - return isPollStarted() && !isPollFinished() && !getPoll().getClosed(); - } - /** * Use a PollAccount to represent the current session user. * The existing account is used if accountUid is present in the uri. @@ -1089,34 +216,7 @@ * @return */ public PollAccount getPollAccount() throws PollenBusinessException { - if (pollAccount == null) { - // Identification du votant - if (uri.getAccountUid() != null) { - // pollAccount = serviceUser.getPerson(uri.getAccountUid()); - - -// pollAccountId = pollAccount.getId(); - } - - if (pollAccount == null) { - // pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO(); - - -// if (userExists) { -// if (user.getFirstName() != null && user.getLastName() != null) { -// pollAccount.setVotingId( -// user.getFirstName() + " " + user.getLastName()); -// -// } else if (user.getFirstName() != null) { -// pollAccount.setVotingId(user.getFirstName()); -// -// } else if (user.getLastName() != null) { -// pollAccount.setVotingId(user.getLastName()); -// } -// } - } - } - return pollAccount; + return getModel().getPollAccount(); } /** @@ -1126,8 +226,7 @@ * @throws PollenBusinessException */ public boolean isCreatorUser() throws PollenBusinessException { - return isUserConnected() && getUserConnected().equals( - getPoll().getCreator().getUserAccount()); + return isUserConnected() && getModel().isCreatorUser(getUserConnected()); } /************** PAGER *****************************************************/ @@ -1227,8 +326,8 @@ */ public List<ChoiceField> getChoices() throws PollenBusinessException { if (choices == null) { - if (log.isInfoEnabled()) { - log.info("Prepare choices for render"); + if (logger.isInfoEnabled()) { + logger.info("Prepare choices for render"); } choices = new ArrayList<ChoiceField>(); for (Choice curr : getPoll().getChoice()) { @@ -1236,8 +335,8 @@ choices.add(field); } } - if (log.isDebugEnabled()) { - log.debug("nb choices loaded : " + choices.size()); + if (logger.isDebugEnabled()) { + logger.debug("nb choices loaded : " + choices.size()); } return choices; } @@ -1457,8 +556,8 @@ // return getCurrentVote().getChoiceValue(choice.getId()); // } - public boolean getCanVote() throws PollenBusinessException { - return isPollRunning(); + public boolean getCanVote() { + return getModel().isAllowedToVote(); } public boolean canEditVote() throws PollenBusinessException { @@ -1486,68 +585,70 @@ /************** COMMENTS **************************************************/ - @InjectComponent - private Zone commentZone; + // TODO-fdesbois-2010-05-21 : create a component for comments - private List<Comment> comments; - - /** Commentaire courant pour l'affichage des commentaires */ - @SuppressWarnings("unused") - @Property - @Persist - private Comment comment; - - /** Nouveau commentaire posté */ - private Comment newComment; - - public List<Comment> getComments() throws PollenBusinessException { - if (comments == null) { - comments = servicePoll.getComments(poll, -1, -1); - } - return comments; - } - - /** - * Accessor for newComment property. Instantiate a new comment if needed. - * - * @return the current newComment. - */ - public Comment getNewComment() { - if (newComment == null) { - newComment = new CommentImpl(); - } - return newComment; - } - - /** - * ACTION EVENT :: delete a comment. - * - * @param commentId id of the comment to delete - * @return the commentZone - * @throws PollenBusinessException - */ - Object onActionFromDeleteComment(String commentId) throws PollenBusinessException { -// servicePoll.deleteComment(getPoll(), commentId); - return commentZone.getBody(); - } - - /** - * SUCCESS EVENT :: submit form for adding a new comment. - * - * @return the commentZone - * @throws PollenBusinessException - */ - @Log - Object onSuccessFromCommentForm() throws PollenBusinessException { - if (log.isDebugEnabled()) { - log.debug("newComment author : " + getNewComment().getAuthor()); - log.debug("newComment text : " + getNewComment().getText()); - } -// getNewComment().setPostDate(new Date()); -// servicePoll.createComment(getPoll(), getNewComment()); -// addFeedEntry(PollAction.ADDCOMMENT, -// getNewComment().getAuthor(), -// getNewComment().getText()); - return commentZone.getBody(); - } +// @InjectComponent +// private Zone commentZone; +// +// private List<Comment> comments; +// +// /** Commentaire courant pour l'affichage des commentaires */ +// @SuppressWarnings("unused") +// @Property +// @Persist +// private Comment comment; +// +// /** Nouveau commentaire posté */ +// private Comment newComment; +// +// public List<Comment> getComments() throws PollenBusinessException { +// if (comments == null) { +// comments = servicePoll.getComments(poll, -1, -1); +// } +// return comments; +// } +// +// /** +// * Accessor for newComment property. Instantiate a new comment if needed. +// * +// * @return the current newComment. +// */ +// public Comment getNewComment() { +// if (newComment == null) { +// newComment = new CommentImpl(); +// } +// return newComment; +// } +// +// /** +// * ACTION EVENT :: delete a comment. +// * +// * @param commentId id of the comment to delete +// * @return the commentZone +// * @throws PollenBusinessException +// */ +// Object onActionFromDeleteComment(String commentId) throws PollenBusinessException { +//// servicePoll.deleteComment(getPoll(), commentId); +// return commentZone.getBody(); +// } +// +// /** +// * SUCCESS EVENT :: submit form for adding a new comment. +// * +// * @return the commentZone +// * @throws PollenBusinessException +// */ +// @Log +// Object onSuccessFromCommentForm() throws PollenBusinessException { +// if (logger.isDebugEnabled()) { +// logger.debug("newComment author : " + getNewComment().getAuthor()); +// logger.debug("newComment text : " + getNewComment().getText()); +// } +//// getNewComment().setPostDate(new Date()); +//// servicePoll.createComment(getPoll(), getNewComment()); +//// addFeedEntry(PollAction.ADDCOMMENT, +//// getNewComment().getAuthor(), +//// getNewComment().getText()); +// return commentZone.getBody(); +// } } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-25 09:29:17 UTC (rev 3011) @@ -41,6 +41,8 @@ import org.chorem.pollen.service.ServicePollImpl; import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.service.ServiceUserImpl; +import org.chorem.pollen.service.ServiceVote; +import org.chorem.pollen.service.ServiceVoteImpl; import org.chorem.pollen.ui.data.PollUri; import org.nuiton.web.tapestry5.services.ServiceAuthentication; import org.slf4j.Logger; @@ -88,6 +90,12 @@ return service; } + public static ServiceVote buildServiceVote(PollenManager manager) { + ServiceVoteImpl service = new ServiceVoteImpl(); + service.setContext(manager.getContext()); + return service; + } + public static ServiceEmail buildServiceEmail(PollenManager manager) { ServiceEmailImpl service = new ServiceEmailImpl(); service.setContext(manager.getContext()); Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-21 11:59:50 UTC (rev 3010) +++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-05-25 09:29:17 UTC (rev 3011) @@ -1,12 +1,11 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html t:type="border" t:addressBar="addressBar" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUid" + xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> -<t:border t:address="address.items" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUid" - xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> - - <t:feedback t:id="feedback"/> - <t:unless test="pollNull"> + <t:if test="poll"> <h1 class="titleVote">${poll.title}</h1> - <!-- Informations sur le sondage --> <div id="pollTop"> ${poll.description} @@ -14,9 +13,9 @@ <legend>${message:about}</legend> <div style="float: right"> <t:if test="poll.publicResults"> - <t:PageLink t:page="poll/Results" t:context="poll.pollUid"> + <a t:type="pagelink" t:page="poll/Results" t:context="poll.pollUid"> <img src="${asset:context:img/count.png}" title="${message:results-help}" alt="${message:results}"/> - </t:PageLink> + </a> </t:if> <t:FeedContextLink t:id="feedContext" /> <t:if test="feedFileExisting"> @@ -40,277 +39,277 @@ </fieldset> </div> - <t:if test="pollChoiceOrVoteStarted"> + <!--<t:if test="pollChoiceOrVoteStarted">--> - <!-- Sondage --> + <!--<!– Sondage –>--> - <!--<t:zone t:id="pollZone" t:show="show" t:update="show">--> - <t:if t:test="poll.anonymous"> - <p>${voteSizeMessage}</p> - <t:feedback t:id="voteFeedback"/> - <p:else> - <t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes" - t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/> - </p:else> - </t:if> - <t:form t:id="voteForm" t:zone="pollZone"> - <table id="poll"> - <thead> - <tr> - <t:if test="${AccountFieldDisplayed}"> - <th style="width:200px;">${message:voterName}</th> - <p:else> - <th></th> - </p:else> - </t:if> - <th t:type="loop" t:source="choices" t:value="choice" t:volatile="true"> - <t:unless test="choice.hidden"> - <!-- Blocks for each choice type --> - <t:block t:id="choiceText"> - <span class="desc">${choice.text}</span> - </t:block> - <t:block t:id="choiceImage"> - <a rel="lightbox[pollChoiceImages]" href="${imageLink}"> - <img src="${imageThumb}" alt="${choice.description}"/> - </a> - </t:block> - <t:block t:id="choiceDate"> - <t:output value="choice.date" format="dateFormat"/> - </t:block> - <!-- Display choice with or whithout description --> - <t:if t:test="choice.description"> - <span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind"> - <t:delegate to="choiceBlock" /> - </span> - <p:else> - <t:delegate to="choiceBlock" /> - </p:else> - </t:if> - <t:if test="canDeleteChoice"> - <!-- Action to delete the choice --> - <t:actionlink t:id="deleteChoice" context="choice.id" - t:mixins="confirm" t:message="message:pollen.ui.choice.delete.confirm"> - <img src="${asset:context:img/delete.png}" title="message:pollen.ui.choice.delete.title" - alt="message:pollen.ui.choice.delete.title"/> - </t:actionlink> - </t:if> - </t:unless> - </th> - </tr> - </thead> - <t:if test="canVote"> - <tfoot> - <tr> - <t:if test="accountFieldDisplayed"> - <th id="voterName"> - <input t:type="textfield" t:id="pollAccountName" value="pollAccount.votingId" t:validate="required"/> - </th> - <p:else> - <th></th> - </p:else> - </t:if> - <t:loop t:source="choices" t:value="choice" volatile="true"> - <t:if test="!choice.hidden"> - <th> - <t:if test="poll.voteCounting.normal"> - <input t:type="checkbox" value="addChoice" /> - </t:if> - <t:if test="poll.voteCounting.percentage"> - <t:textField t:value="currentVote.getChoiceValues(choice.id)" size="3" t:validate="required, min=0, max=100"/>% - </t:if> - <t:if test="poll.voteCounting.condorcet"> - <t:textField t:id="condorcetInput" t:value="choiceOfVote.value" size="3" t:nulls="zero" t:validate="min=0, max=99"/> - </t:if> - <t:if test="poll.voteCounting.number"> - <t:textField t:value="addNumberVote" size="3" /> - </t:if> - </th> - </t:if> - </t:loop> - </tr> - </tfoot> - </t:if> - <tbody> - <t:unless t:test="poll.anonymous"> - <t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true"> - <tr> - <td class="${evenodd.next}"> - <t:if test="${AccountFieldDisplayed}"> - <t:unless test="${currentVoteAnonymous}"> - ${vote.name} - <p:else> - ? - </p:else> - </t:unless> - </t:if> - <t:unless test="${poll.anonymous}"> - <t:if test="canEditVote()"> - <t:actionlink t:id="editVote" context="voteIndex" t:zone="pollZone"> - <img src="${asset:context:img/editSmall.png}" title="${message:edit}" alt="${message:edit}"/> - </t:actionlink> - </t:if> - <t:if test="creatorUser"> - <t:actionlink t:id="deleteVote" context="vote.id" t:zone="pollZone"> - <img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/> - </t:actionlink> - </t:if> - </t:unless> - </td> - <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true"> - <t:unless t:test="choiceHidden"> - ${setCurrentVoteChoice()} - <t:if t:test="poll.anonymous"> - <td class="anonymous">?</td> - <p:else> - <t:if test="isNormalVoteCounting()"> - <t:if test="isChoiceInVote(currentVoteChoice)"> - <td class="voted">OK</td> - <p:else> - <td class="notVoted"></td> - </p:else> - </t:if> - </t:if> - <t:if test="isPercentageVoteCounting()"> - <t:if test="isChoiceInVote(currentVoteChoice)"> - <td class="voted">${currentVoteChoice.value} %</td> - <p:else> - <td class="notVoted"></td> - </p:else> - </t:if> - </t:if> - <t:if test="isCondorcetVoteCounting()"> - <t:if test="isChoiceInVote(currentVoteChoice)"> - <td class="voted">${currentVoteChoice.value}</td> - <p:else> - <td class="notVoted"></td> - </p:else> - </t:if> - </t:if> - <t:if test="isNumberVoteCounting()"> - <t:if test="isChoiceInVote(currentVoteChoice)"> - <td class="voted">${currentVoteChoice.value}</td> - <p:else> - <td class="notVoted"></td> - </p:else> - </t:if> - </t:if> - </p:else> - </t:if> - </t:unless> - </t:loop> - </tr> - </t:loop> - </t:unless> - <t:if test="poll.continuousResults"> - <tr> - <td> - <t:PageLink t:page="poll/results" t:context="${poll.pollUid}">${message:results}</t:PageLink> - </td> - <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true"> - <t:if test="!isChoiceHidden()"> - <td class="result">${currentChoiceResult}</td> - </t:if> - </t:loop> - </tr> - </t:if> - </tbody> - </table> - <div id="voteError"> - <t:errors/> - </div> - <t:if test="pollRunning"> - <div id="buttons"> - <t:if test="anonymousVoteDisplayed"> - <t:checkbox t:id="anonymousVote" t:value="anonymousVote" /> - <t:label for="anonymousVote" /> - <br/> - </t:if> - <input t:id="submitVote" t:type="Submit" t:value="${message:submitVote}" /> - </div> - </t:if> - </t:form> - <!--</t:zone>--> + <!--<!–<t:zone t:id="pollZone" t:show="show" t:update="show">–>--> + <!--<t:if t:test="poll.anonymous">--> + <!--<p>${voteSizeMessage}</p>--> + <!--<t:feedback t:id="voteFeedback"/>--> + <!--<p:else>--> + <!--<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"--> + <!--t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>--> + <!--</p:else>--> + <!--</t:if>--> + <!--<t:form t:id="voteForm" t:zone="pollZone">--> + <!--<table id="poll">--> + <!--<thead>--> + <!--<tr>--> + <!--<t:if test="${AccountFieldDisplayed}">--> + <!--<th style="width:200px;">${message:voterName}</th>--> + <!--<p:else>--> + <!--<th></th>--> + <!--</p:else>--> + <!--</t:if>--> + <!--<th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">--> + <!--<t:unless test="choice.hidden">--> + <!--<!– Blocks for each choice type –>--> + <!--<t:block t:id="choiceText">--> + <!--<span class="desc">${choice.text}</span>--> + <!--</t:block>--> + <!--<t:block t:id="choiceImage">--> + <!--<a rel="lightbox[pollChoiceImages]" href="${imageLink}">--> + <!--<img src="${imageThumb}" alt="${choice.description}"/>--> + <!--</a>--> + <!--</t:block>--> + <!--<t:block t:id="choiceDate">--> + <!--<t:output value="choice.date" format="dateFormat"/>--> + <!--</t:block>--> + <!--<!– Display choice with or whithout description –>--> + <!--<t:if t:test="choice.description">--> + <!--<span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">--> + <!--<t:delegate to="choiceBlock" />--> + <!--</span>--> + <!--<p:else>--> + <!--<t:delegate to="choiceBlock" />--> + <!--</p:else>--> + <!--</t:if>--> + <!--<t:if test="canDeleteChoice">--> + <!--<!– Action to delete the choice –>--> + <!--<t:actionlink t:id="deleteChoice" context="choice.id"--> + <!--t:mixins="confirm" t:message="message:pollen.ui.choice.delete.confirm">--> + <!--<img src="${asset:context:img/delete.png}" title="message:pollen.ui.choice.delete.title"--> + <!--alt="message:pollen.ui.choice.delete.title"/>--> + <!--</t:actionlink>--> + <!--</t:if>--> + <!--</t:unless>--> + <!--</th>--> + <!--</tr>--> + <!--</thead>--> + <!--<t:if test="canVote">--> + <!--<tfoot>--> + <!--<tr>--> + <!--<t:if test="accountFieldDisplayed">--> + <!--<th id="voterName">--> + <!--<input t:type="textfield" t:id="pollAccountName" value="pollAccount.votingId" t:validate="required"/>--> + <!--</th>--> + <!--<p:else>--> + <!--<th></th>--> + <!--</p:else>--> + <!--</t:if>--> + <!--<t:loop t:source="choices" t:value="choice" volatile="true">--> + <!--<t:if test="!choice.hidden">--> + <!--<th>--> + <!--<t:if test="poll.voteCounting.normal">--> + <!--<input t:type="checkbox" value="addChoice" />--> + <!--</t:if>--> + <!--<t:if test="poll.voteCounting.percentage">--> + <!--<t:textField t:value="currentVote.getChoiceValues(choice.id)" size="3" t:validate="required, min=0, max=100"/>%--> + <!--</t:if>--> + <!--<t:if test="poll.voteCounting.condorcet">--> + <!--<t:textField t:id="condorcetInput" t:value="choiceOfVote.value" size="3" t:nulls="zero" t:validate="min=0, max=99"/>--> + <!--</t:if>--> + <!--<t:if test="poll.voteCounting.number">--> + <!--<t:textField t:value="addNumberVote" size="3" />--> + <!--</t:if>--> + <!--</th>--> + <!--</t:if>--> + <!--</t:loop>--> + <!--</tr>--> + <!--</tfoot>--> + <!--</t:if>--> + <!--<tbody>--> + <!--<t:unless t:test="poll.anonymous">--> + <!--<t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true">--> + <!--<tr>--> + <!--<td class="${evenodd.next}">--> + <!--<t:if test="${AccountFieldDisplayed}">--> + <!--<t:unless test="${currentVoteAnonymous}">--> + <!--${vote.name}--> + <!--<p:else>--> + <!--?--> + <!--</p:else>--> + <!--</t:unless>--> + <!--</t:if>--> + <!--<t:unless test="${poll.anonymous}">--> + <!--<t:if test="canEditVote()">--> + <!--<t:actionlink t:id="editVote" context="voteIndex" t:zone="pollZone">--> + <!--<img src="${asset:context:img/editSmall.png}" title="${message:edit}" alt="${message:edit}"/>--> + <!--</t:actionlink>--> + <!--</t:if>--> + <!--<t:if test="creatorUser">--> + <!--<t:actionlink t:id="deleteVote" context="vote.id" t:zone="pollZone">--> + <!--<img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>--> + <!--</t:actionlink>--> + <!--</t:if>--> + <!--</t:unless>--> + <!--</td>--> + <!--<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">--> + <!--<t:unless t:test="choiceHidden">--> + <!--${setCurrentVoteChoice()}--> + <!--<t:if t:test="poll.anonymous">--> + <!--<td class="anonymous">?</td>--> + <!--<p:else>--> + <!--<t:if test="isNormalVoteCounting()">--> + <!--<t:if test="isChoiceInVote(currentVoteChoice)">--> + <!--<td class="voted">OK</td>--> + <!--<p:else>--> + <!--<td class="notVoted"></td>--> + <!--</p:else>--> + <!--</t:if>--> + <!--</t:if>--> + <!--<t:if test="isPercentageVoteCounting()">--> + <!--<t:if test="isChoiceInVote(currentVoteChoice)">--> + <!--<td class="voted">${currentVoteChoice.value} %</td>--> + <!--<p:else>--> + <!--<td class="notVoted"></td>--> + <!--</p:else>--> + <!--</t:if>--> + <!--</t:if>--> + <!--<t:if test="isCondorcetVoteCounting()">--> + <!--<t:if test="isChoiceInVote(currentVoteChoice)">--> + <!--<td class="voted">${currentVoteChoice.value}</td>--> + <!--<p:else>--> + <!--<td class="notVoted"></td>--> + <!--</p:else>--> + <!--</t:if>--> + <!--</t:if>--> + <!--<t:if test="isNumberVoteCounting()">--> + <!--<t:if test="isChoiceInVote(currentVoteChoice)">--> + <!--<td class="voted">${currentVoteChoice.value}</td>--> + <!--<p:else>--> + <!--<td class="notVoted"></td>--> + <!--</p:else>--> + <!--</t:if>--> + <!--</t:if>--> + <!--</p:else>--> + <!--</t:if>--> + <!--</t:unless>--> + <!--</t:loop>--> + <!--</tr>--> + <!--</t:loop>--> + <!--</t:unless>--> + <!--<t:if test="poll.continuousResults">--> + <!--<tr>--> + <!--<td>--> + <!--<t:PageLink t:page="poll/results" t:context="${poll.pollUid}">${message:results}</t:PageLink>--> + <!--</td>--> + <!--<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">--> + <!--<t:if test="!isChoiceHidden()">--> + <!--<td class="result">${currentChoiceResult}</td>--> + <!--</t:if>--> + <!--</t:loop>--> + <!--</tr>--> + <!--</t:if>--> + <!--</tbody>--> + <!--</table>--> + <!--<div id="voteError">--> + <!--<t:errors/>--> + <!--</div>--> + <!--<t:if test="poll.running">--> + <!--<div id="buttons">--> + <!--<t:if test="anonymousVoteDisplayed">--> + <!--<t:checkbox t:id="anonymousVote" t:value="anonymousVote" />--> + <!--<t:label for="anonymousVote" />--> + <!--<br/>--> + <!--</t:if>--> + <!--<input t:id="submitVote" t:type="Submit" t:value="${message:submitVote}" />--> + <!--</div>--> + <!--</t:if>--> + <!--</t:form>--> + <!--<!–</t:zone>–>--> - <!-- Ajout de choix --> - <!--<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUid"/>--> - <t:if test="canAddChoice"> - <h4>${message:pollen.ui.choice.add.title}</h4> - <div id="choiceFormDiv"> - <t:form t:id="addChoice"> - <t:if t:test="newChoice.type.date"> - <label t:type="label" for="choiceDate" />*<br /> - <input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date" - t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp" - t:datePattern="message:pollen.ui.choice.datePattern"/> - </t:if> - <t:if t:test="newChoice.type.image"> - <label t:type="label" for="choiceImage" />*<br /> - <input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" /> - </t:if> - <t:if t:test="newChoice.type.text"> - <label t:type="label" for="choiceText" />*<br /> - <input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/> - </t:if> -<!-- <t:delegate t:to="newChoiceBlock" /><br /> - <t:block t:id="newChoiceDate"> - <label t:type="label" for="choiceDate" />*<br /> - <input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date" - t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp" - t:datePattern="message:pollen.ui.choice.datePattern"/> - </t:block> - <t:block t:id="newChoiceImage"> - <label t:type="label" for="choiceImage" />*<br /> - <input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" /> - </t:block> - <t:block t:id="newChoiceText"> - <label t:type="label" for="choiceText" />*<br /> - <input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/> - </t:block>--> - <label t:type="label" for="choiceDescription" /><br /> - <input t:type="textfield" t:id="choiceDescription" value="newChoice.description" /> - <input t:type="submit" value="message:pollen.ui.choice.add.submit" /> - </t:form> - </div> - </t:if> + <!--<!– Ajout de choix –>--> + <!--<!–<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUid"/>–>--> + <!--<t:if test="canAddChoice">--> + <!--<h4>${message:pollen.ui.choice.add.title}</h4>--> + <!--<div id="choiceFormDiv">--> + <!--<t:form t:id="addChoice">--> + <!--<t:if t:test="newChoice.type.date">--> + <!--<label t:type="label" for="choiceDate" />*<br />--> + <!--<input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"--> + <!--t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"--> + <!--t:datePattern="message:pollen.ui.choice.datePattern"/>--> + <!--</t:if>--> + <!--<t:if t:test="newChoice.type.image">--> + <!--<label t:type="label" for="choiceImage" />*<br />--> + <!--<input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />--> + <!--</t:if>--> + <!--<t:if t:test="newChoice.type.text">--> + <!--<label t:type="label" for="choiceText" />*<br />--> + <!--<input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>--> + <!--</t:if>--> +<!--<!– <t:delegate t:to="newChoiceBlock" /><br />--> + <!--<t:block t:id="newChoiceDate">--> + <!--<label t:type="label" for="choiceDate" />*<br />--> + <!--<input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"--> + <!--t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"--> + <!--t:datePattern="message:pollen.ui.choice.datePattern"/>--> + <!--</t:block>--> + <!--<t:block t:id="newChoiceImage">--> + <!--<label t:type="label" for="choiceImage" />*<br />--> + <!--<input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />--> + <!--</t:block>--> + <!--<t:block t:id="newChoiceText">--> + <!--<label t:type="label" for="choiceText" />*<br />--> + <!--<input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>--> + <!--</t:block>–>--> + <!--<label t:type="label" for="choiceDescription" /><br />--> + <!--<input t:type="textfield" t:id="choiceDescription" value="newChoice.description" />--> + <!--<input t:type="submit" value="message:pollen.ui.choice.add.submit" />--> + <!--</t:form>--> + <!--</div>--> + <!--</t:if>--> <!-- Ajout de commentaires --> - <h3>${message:comments}</h3> - <t:zone t:id="commentZone" show="show" update="show"> - <div id="commentsDiv"> - <div t:type="loop" t:source="comments" t:value="comment" class="${evenodd.next}"> - <t:if test="creatorUser"> - <span class="cmd"> - <t:actionlink t:id="deleteComment" context="comment.id" t:zone="commentZone"> - <img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/> - </t:actionlink> - </span> - </t:if> - <span class="name">${comment.author}</span> : - <span class="date"> - <t:output value="comment.postDate" format="dateFormat"/> - </span> - <t:textOutput value="${comment.text}" /> - </div> - </div> - <div id="commentFormDiv"> - <t:form t:id="commentForm" t:zone="commentZone" t:volatile="true"> - <t:label for="commenterName" /> - <br/> - <t:textField t:value="newComment.author" t:id="commenterName" - t:validate="required" /> - <br/> - <t:label for="commentArea" /> - <br/> - <t:textArea t:value="newComment.text" t:id="commentArea" - t:validate="required" /> - <br/> - <t:Submit t:id="submitComment" t:value="${message:submitComment}" /> - </t:form> - </div> - </t:zone> + <!--<h3>${message:comments}</h3>--> + <!--<t:zone t:id="commentZone" show="show" update="show">--> + <!--<div id="commentsDiv">--> + <!--<div t:type="loop" t:source="comments" t:value="comment" class="${evenodd.next}">--> + <!--<t:if test="creatorUser">--> + <!--<span class="cmd">--> + <!--<t:actionlink t:id="deleteComment" context="comment.id" t:zone="commentZone">--> + <!--<img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>--> + <!--</t:actionlink>--> + <!--</span>--> + <!--</t:if>--> + <!--<span class="name">${comment.author}</span> :--> + <!--<span class="date">--> + <!--<t:output value="comment.postDate" format="dateFormat"/>--> + <!--</span>--> + <!--<t:textOutput value="${comment.text}" />--> + <!--</div>--> + <!--</div>--> + <!--<div id="commentFormDiv">--> + <!--<t:form t:id="commentForm" t:zone="commentZone" t:volatile="true">--> + <!--<t:label for="commenterName" />--> + <!--<br/>--> + <!--<t:textField t:value="newComment.author" t:id="commenterName"--> + <!--t:validate="required" />--> + <!--<br/>--> + <!--<t:label for="commentArea" />--> + <!--<br/>--> + <!--<t:textArea t:value="newComment.text" t:id="commentArea"--> + <!--t:validate="required" />--> + <!--<br/>--> + <!--<t:Submit t:id="submitComment" t:value="${message:submitComment}" />--> + <!--</t:form>--> + <!--</div>--> + <!--</t:zone>--> - </t:if> - </t:unless> -</t:border> \ No newline at end of file + <!--</t:if>--> + </t:if> +</html> \ No newline at end of file