Author: fdesbois Date: 2010-04-30 11:40:14 +0200 (Fri, 30 Apr 2010) New Revision: 2982 Url: http://chorem.org/repositories/revision/pollen/2982 Log: Repare pollForm from previous version 1.3 Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java trunk/pollen-business/src/main/xmi/pollen.zargo trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties trunk/pollen-ui/src/main/webapp/js/pollForm.js trunk/pollen-ui/src/main/webapp/poll/PollForm.tml Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-30 09:40:14 UTC (rev 2982) @@ -10,6 +10,7 @@ import org.chorem.pollen.entity.Comment; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.PollAccountImpl; import org.chorem.pollen.entity.PollImpl; import org.chorem.pollen.entity.UserAccount; import org.nuiton.topia.TopiaContext; @@ -51,8 +52,19 @@ } @Override - protected Poll executeGetNewPoll() { - return new PollImpl(); + protected Poll executeGetNewPoll(UserAccount user) { + Poll poll = new PollImpl(); + // 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); + } + poll.setCreator(creator); + return poll; } @Override @@ -69,6 +81,9 @@ PollenDAOHelper.getPollDAO(transaction).create(poll); + // need to create uid for both poll and creator + // need to create creator (name, email, user, admin) + transaction.commitTransaction(); } Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-30 09:40:14 UTC (rev 2982) @@ -59,7 +59,10 @@ */ @Override public UserAccount getUserConnected() { - return user; + if (isUserConnected()) { + return user; + } + return null; } /** Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-30 09:40:14 UTC (rev 2982) @@ -312,6 +312,7 @@ */ Object onActionFromLogout() { user = null; + request.getSession(false).invalidate(); return Index.class; } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-04-30 09:40:14 UTC (rev 2982) @@ -7,6 +7,7 @@ import org.apache.tapestry5.upload.services.UploadedFile; import org.chorem.pollen.common.ChoiceType; import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.ChoiceImpl; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.ui.services.ServiceImage; import org.slf4j.Logger; @@ -231,28 +232,35 @@ setName(name); } + protected Choice getChoice() { + if (choice == null) { + choice = new ChoiceImpl(); + } + return choice; + } + public void setName(String name) { - choice.setName(name); + getChoice().setName(name); } public String getName() { - return choice.getName(); + return getChoice().getName(); } public void setDescription(String description) { - choice.setDescription(description); + getChoice().setDescription(description); } public String getDescription() { - return choice.getDescription(); + return getChoice().getDescription(); } public void setChoiceType(ChoiceType choiceType) { - choice.setChoiceType(choiceType); + getChoice().setChoiceType(choiceType); } public ChoiceType getChoiceType() { - return choice.getChoiceType(); + return getChoice().getChoiceType(); } 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-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-04-30 09:40:14 UTC (rev 2982) @@ -26,6 +26,8 @@ import org.chorem.pollen.entity.Choice; import org.chorem.pollen.entity.Poll; import org.chorem.pollen.entity.PreventRule; +import org.chorem.pollen.entity.PreventRuleImpl; +import org.chorem.pollen.mail.PreventRuleManager; import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.base.AbstractPollenPage; import org.chorem.pollen.ui.components.Border; @@ -103,6 +105,7 @@ * the pollUID exist. * * @return poll existing or a new one + * @throws PollenBusinessException */ public Poll getPoll() throws PollenBusinessException { if (poll == null) { @@ -116,17 +119,7 @@ if (log.isDebugEnabled()) { log.debug("Init new poll"); } - poll = servicePoll.getNewPoll(); - - // FIXME : manage PollAccount creator - -// if (userExists) { -// String creatorName = -// user.getFirstName() + " " + user.getLastName(); -// poll.setCreatorName(creatorName); -// poll.setCreatorEmail(user.getEmail()); -// poll.setUserId(user.getId()); -// } + poll = servicePoll.getNewPoll(getUserConnected()); } } return poll; @@ -136,6 +129,7 @@ * Test if the form mode is for creation : new poll. * * @return true if it's the create mode, false otherwise + * @throws PollenBusinessException */ public boolean isCreateMode() throws PollenBusinessException { return StringUtils.isEmpty(getPoll().getTopiaId()); @@ -145,6 +139,7 @@ * Page title for border component. * * @return the page title depends on create or update mode. + * @throws PollenBusinessException */ public String getPageTitle() throws PollenBusinessException { String title = ""; @@ -337,9 +332,12 @@ */ public PreventRule getNotification() { if (notification == null) { -// notification = new PreventRuleImpl("vote", 0, true, -// PreventRuleManager.EMAIL_ACTION); -// notification.set + // FIXME-FD20100430 : move this in business module + notification = new PreventRuleImpl(); + notification.setScope("vote"); + notification.setSensibility(0); + notification.setRepeated(true); + notification.setMethod(PreventRuleManager.EMAIL_ACTION); } return notification; } @@ -364,8 +362,12 @@ */ public PreventRule getReminder() { if (reminder == null) { -// reminder = new PreventRuleDTO("rappel", 0, false, -// PreventRuleManager.EMAIL_ACTION); + // FIXME-FD20100430 : move this in business module + reminder = new PreventRuleImpl(); + reminder.setScope("rappel"); + reminder.setSensibility(0); + reminder.setRepeated(false); + reminder.setMethod(PreventRuleManager.EMAIL_ACTION); } return reminder; } Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-04-30 09:40:14 UTC (rev 2982) @@ -25,8 +25,8 @@ endDate-validate=La date de fin doit-\u00EAtre post\u00E9rieure \u00E0 la date de d\u00E9but. pollType-label=Restriction des votants pollType-help=<strong>Aucune</strong> : accessible \u00E0 tout le monde<br/><strong>Liste simple</strong> : accessible uniquement \u00E0 une liste de votants<br/><strong>Par groupes</strong> : accessible \u00E0 plusieurs listes de votants -voteCounting-label=D\u00E9pouillement -voteCounting-help=<strong>Normal</strong> : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/><strong>Pourcentage</strong> : attribution d\'un pourcentage \u00E0 chaque choix<br/><strong>Condorcet</strong> : classement des choix par ordre de pr\u00E9f\u00E9rence<br/><strong>Nombre</strong> : R\u00E9ponse libre. Fait la somme et la moyenne des nombres. +VoteCountingType-label=D\u00E9pouillement +VoteCountingType-help=<strong>Normal</strong> : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/><strong>Pourcentage</strong> : attribution d\'un pourcentage \u00E0 chaque choix<br/><strong>Condorcet</strong> : classement des choix par ordre de pr\u00E9f\u00E9rence<br/><strong>Nombre</strong> : R\u00E9ponse libre. Fait la somme et la moyenne des nombres. # Labels for enums PollType.FREE=Aucune Modified: trunk/pollen-ui/src/main/webapp/js/pollForm.js =================================================================== --- trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-04-30 09:40:14 UTC (rev 2982) @@ -16,7 +16,7 @@ this.notificationFragmentId = 'notificationHidden'; // Attributes for voteCounting and choiceNb synchronization - this.voteCounting = this.form.voteCounting; + this.voteCounting = this.form.voteCountingType; this.voteCountingNormal = voteCountingNormal; this.choiceNbFragmentId = 'choiceNbHidden'; this.choiceNb = this.form.choiceNb; Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-04-30 08:47:02 UTC (rev 2981) +++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-04-30 09:40:14 UTC (rev 2982) @@ -1,13 +1,14 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <t:border t:addressBar="addressBar" t:pageLogo="literal:Creation" t:pageBodyId="p-pollForm" t:pageTitle="prop:pageTitle" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> -<t:feedback t:id="feedback"/> + <h1 class="titlePoll"> <t:if t:test="createMode"> ${message:mainTitle-create} <p:else>${poll.title}</p:else> </t:if> </h1> + <t:zone t:id="mainZone" t:update="show"> <form t:type="form" t:id="mainForm" t:zone="mainZone" action="post"> <t:errors/>