Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
Author: fdesbois
Date: 2010-03-05 10:29:40 +0100 (Fri, 05 Mar 2010)
New Revision: 2895
Log:
Create branch to test and add features for massive vote : 3000
Added:
branches/pollen-1.2.3-1.2.x/
Property changes on: branches/pollen-1.2.3-1.2.x
___________________________________________________________________
Added: svn:ignore
+ target
nbactions.xml
.settings
.classpath
.project
*.ipr
*.iws
*.iml
Added: svn:mergeinfo
+
1
0
r2894 - trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils
by bpoussin@users.chorem.org 04 Mar '10
by bpoussin@users.chorem.org 04 Mar '10
04 Mar '10
Author: bpoussin
Date: 2010-03-04 18:45:39 +0100 (Thu, 04 Mar 2010)
New Revision: 2894
Log:
ajout d'une ligne en commentaire qui doit manquer pour que l'import CSV fonctionne (a verfier)
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java 2010-03-02 20:14:34 UTC (rev 2893)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java 2010-03-04 17:45:39 UTC (rev 2894)
@@ -53,6 +53,7 @@
ColumnPositionMappingStrategy<PollAccountDTO> strat =
new ColumnPositionMappingStrategy<PollAccountDTO>();
String[] columns = new String[] { "votingId", "email", "weight" };
+// strat.setType(PollAccountDTO.class); // <---- cette ligne doit etre manquante a verifier par un Test unitaire
strat.setColumnMapping(columns);
// Parsing du fichier CSV
1
0
Author: fdesbois
Date: 2010-03-02 21:14:34 +0100 (Tue, 02 Mar 2010)
New Revision: 2893
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBar.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBarItem.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.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.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties
trunk/pollen-ui/src/main/webapp/css/poll.css
trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/Lien.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.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/pages/user/Account.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml
trunk/pollen-ui/src/main/webapp/css/main.css
trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
Log:
- Evo #122 : Begin creation of new page for pollForm
- Refactor Lien class in AddressBarItem + add AddressBar smoother managment
- Use ZoneUpdater mixin for pollForm interactions
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -21,6 +21,7 @@
import org.chorem.pollen.business.dto.CommentDTO;
import org.chorem.pollen.business.dto.PollDTO;
+import org.chorem.pollen.business.dto.UserDTO;
/**
* Interface du service de gestion des sondages.
@@ -55,6 +56,21 @@
public boolean deletePoll(String pollId);
/**
+ * Get a new poll for creation form.
+ *
+ * @return a new PollDTO with params initialized
+ */
+ public PollDTO getNewPoll();
+
+ /**
+ * Get a new poll which is a copy from the {@code poll}.
+ *
+ * @param poll to copy
+ * @return a new poll which is a copy from the one in argument
+ */
+ public PollDTO getNewPoll(PollDTO poll);
+
+ /**
* Récupération d'un sondage à partir de son identifiant.
*
* @param pollId identifiant du sondage (différent du topiaId)
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -55,6 +55,9 @@
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.dto.UserDTO;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.common.VoteCountingType;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -284,6 +287,20 @@
}
@Override
+ public PollDTO getNewPoll() {
+ PollDTO newPoll = new PollDTO();
+ newPoll.setVoteCounting(VoteCountingType.NORMAL);
+ newPoll.setPollType(PollType.FREE);
+ return newPoll;
+ }
+
+ @Override
+ public PollDTO getNewPoll(PollDTO poll) {
+ PollDTO newPoll = new PollDTO();
+ return newPoll;
+ }
+
+ @Override
public boolean deletePoll(String pollId) {
TopiaContext transaction = null;
try {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -41,7 +41,7 @@
import org.chorem.pollen.business.services.ServicePollAccount;
import org.chorem.pollen.business.services.ServiceResults;
import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.data.PollAction;
import org.chorem.pollen.ui.pages.admin.PollsAdmin;
import org.chorem.pollen.ui.pages.poll.ConfirmPoll;
@@ -93,7 +93,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/**
* Sert à créer pollsModel
@@ -208,8 +208,8 @@
* Initialisation de l'affichage
*/
public void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
pollsModel = beanModelSource.createDisplayModel(PollDTO.class,
componentResources.getMessages());
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-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -24,6 +24,7 @@
import java.util.Locale;
import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
@@ -40,7 +41,7 @@
import org.chorem.pollen.business.services.ServiceAuth;
import org.chorem.pollen.business.utils.MD5;
import org.chorem.pollen.ui.base.ContextLink;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe du Layout Component Border.
@@ -79,7 +80,7 @@
@SuppressWarnings("unused")
@Parameter(required = false)
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/**
* Chaine définissant le style de la page
@@ -88,6 +89,11 @@
@Property
private String pageLogo;
+ /** Title of the page **/
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ @Property
+ private String pageTitle;
+
/**
* Chaine definissant le logo de la page
*/
@@ -100,7 +106,7 @@
*/
@SuppressWarnings("unused")
@Property
- private Lien lien;
+ private AddressBarItem lien;
/**
* Champ login du formulaire d'identification
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBar.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBar.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBar.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,53 @@
+
+package org.chorem.pollen.ui.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AddressBar
+ *
+ * Created: 2 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class AddressBar {
+
+ public List<AddressBarItem> items;
+
+ public AddressBar() {
+ appendHome();
+ }
+
+ protected List<AddressBarItem> getListItems() {
+ if (items == null) {
+ items = new ArrayList<AddressBarItem>();
+ }
+ return items;
+ }
+
+ protected AddressBar appendHome() {
+ append("Pollen", "index");
+ return this;
+ }
+
+ public AddressBar appendCurrent(String name) {
+ append(name, null);
+ return this;
+ }
+
+ public AddressBar append(String name, String page) {
+ getListItems().add(new AddressBarItem(name, page));
+ return this;
+ }
+
+ public AddressBarItem[] getItems() {
+ return getListItems().toArray(
+ new AddressBarItem[getListItems().size()]);
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBar.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Copied: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBarItem.java (from rev 2891, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/Lien.java)
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBarItem.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBarItem.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,92 @@
+/* *##% Pollen
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
+
+package org.chorem.pollen.ui.data;
+
+/**
+ * Classe représentant un item de l'adresse dans la classe Border.
+ *
+ * @author kmorin
+ * @version $Id$
+ */
+public class AddressBarItem {
+
+ /**
+ * nom sous lequel apparait le lien dans la barre d'adresse.
+ */
+ private String name;
+
+ /**
+ * adresse où mène le lien
+ */
+ private String address;
+
+ /**
+ * Constructeur
+ *
+ * @param name nom du lien
+ * @param address adresse du lien
+ */
+ public AddressBarItem(String name, String address) {
+ this.name = name;
+ this.address = address;
+ }
+
+ /**
+ * Retourn le nom du lien
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Modifie la valeur de name
+ *
+ * @param name la nouvelle valeur de name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Retourne l'adresse du lien
+ *
+ * @return address
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Modifie l'adresse du lien
+ *
+ * @param address la nouvelle valeur du lien
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ /**
+ * Renvoie si l'adresse du lien est nulle.
+ *
+ * @return vrai si l'adresse est nulle
+ */
+ public boolean isLienNull() {
+ return address == null;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AddressBarItem.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Revision Rev Id
Added: svn:mergeinfo
+
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/Lien.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/Lien.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/Lien.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -1,92 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.ui.data;
-
-/**
- * Classe représentant un item de l'adresse dans la classe Border.
- *
- * @author kmorin
- * @version $Id$
- */
-public class Lien {
-
- /**
- * nom sous lequel apparait le lien dans la barre d'adresse.
- */
- private String name;
-
- /**
- * adresse où mène le lien
- */
- private String address;
-
- /**
- * Constructeur
- *
- * @param name nom du lien
- * @param address adresse du lien
- */
- public Lien(String name, String address) {
- this.name = name;
- this.address = address;
- }
-
- /**
- * Retourn le nom du lien
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Modifie la valeur de name
- *
- * @param name la nouvelle valeur de name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Retourne l'adresse du lien
- *
- * @return address
- */
- public String getAddress() {
- return address;
- }
-
- /**
- * Modifie l'adresse du lien
- *
- * @param address la nouvelle valeur du lien
- */
- public void setAddress(String address) {
- this.address = address;
- }
-
- /**
- * Renvoie si l'adresse du lien est nulle.
- *
- * @return vrai si l'adresse est nulle
- */
- public boolean isLienNull() {
- return address == null;
- }
-}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,101 @@
+/**
+ * *##%
+ * Wao :: Web Interface
+ * Copyright (C) 2009 - 2010 Ifremer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * ##%*
+ */
+package org.chorem.pollen.ui.mixins;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * ZoneUpdater.java
+ *
+ * From http://tinybits.blogspot.com/2009/05/update-zone-on-any-client-side-event.h… by ingesol
+ *
+ * @author ingesol
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author: fdesbois $
+ */
+@IncludeJavaScriptLibrary("context:js/ZoneUpdater.js")
+public class ZoneUpdater {
+
+ public static final String PLACEHOLDER = "XXX";
+
+ @Inject
+ private ComponentResources resources;
+
+ @Environmental
+ private RenderSupport renderSupport;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String clientEvent;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
+ private String event;
+
+ @InjectContainer
+ private ClientElement element;
+
+ @Parameter
+ private Object[] context;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ // To enable popups to fire events on this document, enter "document" here.
+ private String listeningElement;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
+ private String zone;
+
+ protected Link createLink(Object[] context) {
+
+ if (context == null) {
+ context = new Object[]{PLACEHOLDER};
+ } else {
+ context = ArrayUtils.add(context, PLACEHOLDER); // To be replaced by javascript
+ }
+
+ return resources.createEventLink(event, context);
+
+ }
+
+ void afterRender() {
+ String link = createLink(context).toAbsoluteURI();
+ String elementId = element.getClientId();
+ if (clientEvent == null) {
+ clientEvent = event;
+ }
+
+ if (listeningElement == null) {
+ listeningElement = "$('" + elementId + "')";
+ }
+ renderSupport.addScript("new ZoneUpdater('%s', %s, '%s', '%s', '%s', '%s')", elementId, listeningElement, clientEvent, link, zone, PLACEHOLDER);
+
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Index.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -17,7 +17,7 @@
package org.chorem.pollen.ui.pages;
import org.apache.tapestry5.annotations.Property;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Page de départ de l'application.
@@ -30,5 +30,5 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address = new Lien[] { new Lien("Pollen", null) };
+ private AddressBarItem[] address = new AddressBarItem[] { new AddressBarItem("Pollen", null) };
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -39,7 +39,7 @@
import org.chorem.pollen.business.services.ServiceUser;
import org.chorem.pollen.business.utils.MD5;
import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.utils.PasswordGenerator;
/**
@@ -83,7 +83,7 @@
*/
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/**
* Liste des utilisateurs.
@@ -242,7 +242,7 @@
public void setupRender() {
accounts = serviceUser.selectUsers(null);
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.services.ServicePollAccount;
import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe de la page de confirmation de la cloture d'un sondage.
@@ -69,7 +69,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Localisation */
@Inject
@@ -115,8 +115,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.services.ServicePoll;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.data.PollAction;
/**
@@ -49,7 +49,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Page précédente */
@Persist
@@ -152,7 +152,7 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.services.ServicePollAccount;
import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe de la page de confirmation de la création d'un sondage.
@@ -69,7 +69,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Localisation */
@Inject
@@ -115,8 +115,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.ui.components.ImageContextLink;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe de la page de visualisation d'une image.
@@ -46,7 +46,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
@Inject
private Messages messages;
@@ -117,8 +117,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null), new Lien(messages.get("title2"), null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null), new AddressBarItem(messages.get("title2"), null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.services.ServicePollAccount;
import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe de la page de confirmation de la modification d'un sondage.
@@ -69,7 +69,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Localisation */
@Inject
@@ -115,8 +115,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -67,7 +67,7 @@
import org.chorem.pollen.ui.components.FeedBack;
import org.chorem.pollen.ui.components.ImageContextLink;
import org.chorem.pollen.ui.data.GenericSelectModel;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.data.PollHelper;
import org.chorem.pollen.ui.data.PollStep;
import org.chorem.pollen.ui.data.uio.DateChoiceUIO;
@@ -312,7 +312,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
@Inject
private PropertyAccess _propertyAccess;
@@ -1154,8 +1154,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
if (!addChoiceSelected && !uploadExceptionCatched
&& !choicesCreationForm.getHasErrors()) {
Added: 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 (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,577 @@
+
+package org.chorem.pollen.ui.pages.poll;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.ValidationException;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.business.business.PreventRuleManager;
+import org.chorem.pollen.business.dto.PollDTO;
+import org.chorem.pollen.business.dto.PreventRuleDTO;
+import org.chorem.pollen.business.dto.UserDTO;
+import org.chorem.pollen.business.services.ServicePoll;
+import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.ui.data.AddressBar;
+import org.slf4j.Logger;
+
+/**
+ * PollForm : Creation and Modification.
+ *
+ * For modification, the poll is getting from using pollUID set in url
+ * (activate/passivate context).
+ *
+ * This page is mostly dynamic, so all fields in the form used zoneUpdate mixin
+ * to refresh the form zone if necessary (for selects or some checkbox options).
+ *
+ * This page is composed of three parts :
+ * <pre>
+ * - Main informations : title, creator, begin and end dates, types, ...
+ * - Options : anonymous, addchoice, reminder, notification, ...
+ * - Choices of the poll (depends on type : DATE, IMAGE, TEXT).
+ * - Lists/Groups for pollType different from FREE.
+ * </pre>
+ *
+ * Created: 2 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+@IncludeStylesheet("context:css/poll.css")
+public class PollForm {
+
+ @Inject
+ private Logger log;
+
+ @SessionState
+ private UserDTO user;
+
+ @Property
+ private boolean userExists;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private ServicePoll servicePoll;
+
+ private String pollUID;
+
+ @Persist
+ private PollDTO poll;
+
+ void onActivate(String id) {
+ pollUID = id;
+ }
+
+ String onPassivate() {
+ return pollUID;
+ }
+
+ void setupRender() {
+ poll = null;
+ initMainInfos();
+ initOptions();
+ }
+
+ /**
+ * Get the main poll used in the form. The existing poll is loaded if
+ * the pollUID exist.
+ *
+ * @return poll existing or a new one
+ */
+ public PollDTO getPoll() {
+ if (poll == null) {
+ if (StringUtils.isNotEmpty(pollUID)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Get existing poll with pollUID = " + pollUID);
+ }
+ poll = servicePoll.findPollByPollId(pollUID);
+ // TODO : init advancedOptions
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Init new poll");
+ }
+ poll = servicePoll.getNewPoll();
+ if (userExists) {
+ String creatorName =
+ user.getFirstName() + " " + user.getLastName();
+ poll.setCreatorName(creatorName);
+ poll.setCreatorEmail(user.getEmail());
+ poll.setUserId(user.getId());
+ }
+ }
+ }
+ return poll;
+ }
+
+ /**
+ * Test if the form mode is for creation : new poll.
+ *
+ * @return true if it's the create mode, false otherwise
+ */
+ public boolean isCreateMode() {
+ return StringUtils.isEmpty(getPoll().getId());
+ }
+
+ /**
+ * Page title for border component.
+ *
+ * @return the page title depends on create or update mode.
+ */
+ public String getPageTitle() {
+ String title = "";
+ if (isCreateMode()) {
+ title = messages.get("pageTitle-create");
+ } else {
+ title = messages.format("pageTitle-update", getPoll().getTitle());
+ }
+ return title;
+ }
+
+ /**
+ * AddressBar for border component.
+ *
+ * @return the address bar.
+ */
+ public AddressBar getAddressBar() {
+ return new AddressBar().appendCurrent(getPageTitle());
+ }
+
+ public void setPollCopyFromPoll(PollDTO poll) {
+ this.poll = servicePoll.getNewPoll(poll);
+ }
+
+ public Date getCurrentDate() {
+ return new Date();
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat(messages.get("date-pattern"));
+ }
+
+ /**************************** MAIN INFOS **********************************/
+
+ @InjectComponent
+ private Form mainForm;
+
+ private Date beginDateValidation;
+
+ @Persist
+ @Property
+ private boolean advancedOptions;
+
+ protected void initMainInfos() {
+ advancedOptions = false;
+ }
+
+ void onChangeFromCreatorName(String value) {
+ getPoll().setCreatorName(value);
+ }
+
+ /**
+ * Action on creatorEmail textfield. This action refresh the form to
+ * actualize options, only if needed {@link #isNotificationDisabled()}
+ *
+ * @param value of the email
+ * @return the form to refresh
+ */
+ Object onChangeFromEmail(String value) {
+ boolean notificationDisabled = isNotificationDisabled();
+ getPoll().setCreatorEmail(value);
+ // The notification option depends on email change
+ // If it must be disabled and sendNotification checkbox is activated,
+ // execute change on notification fields
+ if (isNotificationDisabled() && hasNotification) {
+ return onChangeFromSendNotification("");
+ }
+ return null;
+ }
+
+ void onChangeFromTitle(String value) {
+ getPoll().setTitle(value);
+ }
+
+ void onChangeFromDescription(String value) {
+ getPoll().setDescription(value);
+ }
+
+ void onChangeFromBeginDate(String value) {
+ getPoll().setBeginDate(getDateFromChangeValue(value));
+ }
+
+ void onChangeFromEndDate(String value) {
+ getPoll().setEndDate(getDateFromChangeValue(value));
+ }
+
+ /**
+ * Util method to simplify date change.
+ *
+ * @param value of the date to parse
+ * @return the date resulted from the value
+ */
+ protected Date getDateFromChangeValue(String value) {
+ Date result = null;
+ if (StringUtils.isNotEmpty(value)) {
+ try {
+ result = getDateFormat().parse(value);
+ } catch (ParseException eee) {
+ log.warn("Syntax error for poll date : " + value, eee);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Action on voteCounting select. This action refresh the form to actualize
+ * options.
+ *
+ * @param value of the selected PollType
+ * @return the form to refresh
+ */
+ Object onChangeFromVoteCounting(String value) {
+ if (log.isDebugEnabled()) {
+ log.debug("voteCounting change to value : " + value);
+ }
+ getPoll().setVoteCounting(VoteCountingType.valueOf(value));
+ // The choiceNb option depends on VoteCounting type
+ // If it must be disabled and choiceNb checkbox is activated,
+ // execute change on choiceNb fields
+ if (isChoiceNbDisabled() && hasChoiceNb) {
+ return onChangeFromChoiceNb("");
+ }
+ return mainForm;
+ }
+
+ /**
+ * Action on pollType select. This action refresh the form to actualize
+ * options.
+ *
+ * @param value of the selected PollType
+ * @return the form to refresh
+ */
+ Object onChangeFromPollType(String value) {
+ if (log.isDebugEnabled()) {
+ log.debug("pollType change to value : " + value);
+ }
+ getPoll().setPollType(PollType.valueOf(value));
+ // The reminder option depends on PollType
+ // If it must be disabled and reminder checkbox is activated, execute
+ // change on reminder fields
+ if (isReminderDisabled() && hasReminder) {
+ return onChangeFromSendReminder("");
+ }
+ return mainForm;
+ }
+
+ void onChangeFromAdvancedOptions(String value) {
+ advancedOptions = !advancedOptions;
+ }
+
+ /************************** OPTIONS ***************************************/
+
+ /** Synchronization with anonymous and anonymousVoteAllowed options **/
+ @Property
+ @Persist
+ private boolean anonymousVoteAllowedDisabled;
+
+ /** Synchronization with continuousResults and publicResults options **/
+ @Property
+ @Persist
+ private boolean publicResultsDisabled;
+
+ /** ChoiceNb option **/
+ @Property
+ @Persist
+ private boolean hasChoiceNb;
+
+ /** Notification option **/
+ @Property
+ @Persist
+ private boolean hasNotification;
+
+ @Persist
+ private PreventRuleDTO notification;
+
+ /** Reminder option **/
+ @Property
+ @Persist
+ private boolean hasReminder;
+
+ @Persist
+ private PreventRuleDTO reminder;
+
+ protected void initOptions() {
+ anonymousVoteAllowedDisabled = false;
+ publicResultsDisabled = false;
+ hasChoiceNb = false;
+ hasNotification = false;
+ hasReminder = false;
+ }
+
+ //~~~~~~~~ OPTIONS ANONYMOUS ~~~~~~//
+
+ /**
+ * Action on anonymous checkbox. The anonymousVoteAllowed is synchronized
+ * with this option.
+ *
+ * @param value not used in this case
+ * @return the form to refresh
+ */
+ Object onChangeFromAnonymous(String value) {
+ boolean anonymous = !getPoll().getAnonymous();
+ getPoll().setAnonymous(anonymous);
+ // Synchro with anonymousVoteAllowed option
+ // Will be disabled and set to true if anonymous option is set
+ getPoll().setAnonymousVoteAllowed(anonymous);
+ anonymousVoteAllowedDisabled = anonymous;
+ return mainForm;
+ }
+
+ void onChangeFromAnonymousVoteAllowed(String value) {
+ getPoll().setAnonymousVoteAllowed(!getPoll().getAnonymousVoteAllowed());
+ }
+
+ //~~~~~~~~ OPTIONS SHOW RESULTS ~~~~~~//
+
+ /**
+ * Action on continuousResults checkbox. The publicResults is synchronized
+ * with this option.
+ *
+ * @param value not used in this case
+ * @return the form to refresh
+ */
+ Object onChangeFromContinuousResults(String value) {
+ boolean continuous = !getPoll().getContinuousResults();
+ getPoll().setContinuousResults(continuous);
+ // Synchro with publicResults option
+ // Will be disabled and set to true if continousResults option is set
+ getPoll().setPublicResults(continuous);
+ publicResultsDisabled = continuous;
+ return mainForm;
+ }
+
+ void onChangeFromPublicResults(String value) {
+ getPoll().setPublicResults(!getPoll().getPublicResults());
+ }
+
+ //~~~~~~~~ OPTION ADD_CHOICE_ALLOWED ~~~~~~//
+
+ /**
+ * Action on choiceAddAllowed checkbox. The beginChoiceDate and
+ * endChoiceDate of the poll depends on this value.
+ * If the value becomes to false, the dates will be reinitialized.
+ *
+ * @param value not used in this case
+ * @return the form to refresh
+ */
+ Object onChangeFromChoiceAddAllowed(String value) {
+ boolean choiceAddAllowed = !getPoll().getChoiceAddAllowed();
+ getPoll().setChoiceAddAllowed(choiceAddAllowed);
+ if (!choiceAddAllowed) {
+ getPoll().setBeginChoiceDate(null);
+ getPoll().setEndChoiceDate(null);
+ }
+ return mainForm;
+ }
+
+ public String getChoiceDateStyle() {
+ return getPoll().getChoiceAddAllowed() ? "display" : "hidden";
+ }
+
+ void onChangeFromBeginChoiceDate(String value) {
+ getPoll().setBeginChoiceDate(getDateFromChangeValue(value));
+ }
+
+ void onChangeFromEndChoiceDate(String value) {
+ getPoll().setEndChoiceDate(getDateFromChangeValue(value));
+ }
+
+ //~~~~~~~~ OPTION NB_CHOICES ~~~~~~~~~~~~~~//
+
+ /**
+ * Action on choiceNb checkbox to activate the maxChoiceNb for the poll.
+ * If the value becomes to false, the maxChoiceNb will be reinitialized
+ *
+ * @param value not used in this case
+ * @return the form to refresh
+ */
+ Object onChangeFromChoiceNb(String value) {
+ hasChoiceNb = !hasChoiceNb;
+ if (!hasChoiceNb) {
+ getPoll().setMaxChoiceNb(null);
+ }
+ return mainForm;
+ }
+
+ public boolean isChoiceNbDisabled() {
+ // voteCounting not set to NORMAL
+ return getPoll().getVoteCounting() != VoteCountingType.NORMAL;
+ }
+
+ public String getChoiceNbLabelStyle() {
+ return isChoiceNbDisabled() ? "disabled" : "";
+ }
+
+ void onChangeFromMaxChoiceNb(String value) {
+ getPoll().setMaxChoiceNb(Integer.parseInt(value));
+ }
+
+ //~~~~~~~~ OPTION NOTIFICATION ~~~~~~~~~~~~//
+
+ /**
+ * Action on sendNotification checkbox to activate the notification.
+ * If the value becomes to false, the notification will be reinitialized
+ *
+ * @param value not used in this case
+ * @return the form to refresh
+ */
+ Object onChangeFromSendNotification(String value) {
+ hasNotification = !hasNotification;
+ if (!hasNotification) {
+ notification = null;
+ }
+ return mainForm;
+ }
+
+ /**
+ * Get the current notification or init a new one based on PreventRule.
+ *
+ * @return the notification
+ */
+ public PreventRuleDTO getNotification() {
+ if (notification == null) {
+ notification = new PreventRuleDTO("vote", 0, true,
+ PreventRuleManager.EMAIL_ACTION);
+ }
+ return notification;
+ }
+
+ /**
+ * Condition to enable or not the notification option.
+ *
+ * @return true if the mail is not defined
+ */
+ public boolean isNotificationDisabled() {
+ // no email defined
+ return StringUtils.isEmpty(getPoll().getCreatorEmail());
+ }
+
+ public String getNotificationLabelStyle() {
+ return isNotificationDisabled() ? "disabled" : "";
+ }
+
+ public void onChangeFromNotification(String value) {
+ getNotification().setSensibility(Integer.parseInt(value));
+ }
+
+ //~~~~~~~~ OPTION REMINDER ~~~~~~~~~~~~~~~~//
+
+ /**
+ * Action on sendReminder checkbox to activate the reminder.
+ * If the value becomes to false, the reminder will be reinitialized
+ *
+ * @param value not used in this case
+ * @return the form to refresh
+ */
+ Object onChangeFromSendReminder(String value) {
+ hasReminder = !hasReminder;
+ if (!hasReminder) {
+ reminder = null;
+ }
+ return mainForm;
+ }
+
+ /**
+ * Get the current reminder or init a new one based on PreventRule.
+ *
+ * @return the reminder
+ */
+ public PreventRuleDTO getReminder() {
+ if (reminder == null) {
+ reminder = new PreventRuleDTO("rappel", 0, false,
+ PreventRuleManager.EMAIL_ACTION);
+ }
+ return reminder;
+ }
+
+ /**
+ * Condition to enable or not the reminder option.
+ *
+ * @return true if the poll has a FREE pollType
+ */
+ public boolean isReminderDisabled() {
+ // pollType is FREE
+ return getPoll().getPollType() == PollType.FREE;
+ }
+
+ public String getReminderLabelStyle() {
+ return isReminderDisabled() ? "disabled" : "";
+ }
+
+ public void onChangeFromReminder(String value) {
+ getReminder().setSensibility(Integer.parseInt(value));
+ }
+
+// /**
+// * Ajax validation from beginChoiceDate input. The date must be before the
+// * beginDate.
+// *
+// * @throws ValidationException
+// */
+// void onValidateFromBeginChoiceDate(Date value) throws ValidationException {
+// if (beginDateValidation == null) {
+// beginDateValidation = getCurrentDate();
+// }
+// beginChoiceDateValidation = value;
+// if (value != null && value.after(beginDateValidation)) {
+// throw new ValidationException(
+// messages.get("beginChoiceDate-validate"));
+// }
+// }
+//
+// /**
+// * Ajax validation from endChoiceDate input. The date must be after the
+// * beginChoiceDate.
+// *
+// * @throws ValidationException
+// */
+// void onValidateFromEndChoiceDate(Date value) throws ValidationException {
+// if (beginChoiceDateValidation == null) {
+// beginChoiceDateValidation = getCurrentDate();
+// }
+//
+// if (value != null && value.before(beginChoiceDateValidation)) {
+// throw new ValidationException(
+// messages.get("endChoiceDate-validate"));
+// }
+// }
+
+// private void initNotificationRule() {
+// notificationCheckBox = false;
+// newRule = new PreventRuleDTO("vote", 0, true,
+// PreventRuleManager.EMAIL_ACTION);
+// newRule.setPollId(poll.getId());
+// for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) {
+// if ("vote".equals(rule.getScope())) {
+// notificationCheckBox = true;
+// newRule = rule;
+// }
+// }
+// }
+
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -54,7 +54,7 @@
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.data.PollAction;
import org.chorem.pollen.ui.data.PollStep;
@@ -74,7 +74,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Paramètres de la page */
private String param;
@@ -635,8 +635,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, currentLocale);
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-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -54,7 +54,7 @@
import org.chorem.pollen.ui.components.Chart;
import org.chorem.pollen.ui.components.FeedBack;
import org.chorem.pollen.ui.components.ImageContextLink;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.votecounting.business.NumberMethod;
import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO;
import org.slf4j.Logger;
@@ -74,7 +74,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Paramètres de la page */
private String param;
@@ -512,8 +512,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, currentLocale);
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-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -73,7 +73,7 @@
import org.chorem.pollen.ui.components.FeedBack;
import org.chorem.pollen.ui.components.ImageContextLink;
import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.data.PollAction;
import org.chorem.pollen.ui.data.uio.DateChoiceUIO;
import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
@@ -102,7 +102,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Paramètres de la page */
private String param;
@@ -1139,8 +1139,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, currentLocale);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -33,7 +33,7 @@
import org.chorem.pollen.business.services.ServiceAuth;
import org.chorem.pollen.business.services.ServiceUser;
import org.chorem.pollen.business.utils.MD5;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe de la page d'un utilisateur.
@@ -107,7 +107,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/**
* Vrai lorsque l'utilisateur modifie son compte.
@@ -180,8 +180,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
if (userExists) {
newUser = user;
oldEmail = user.getEmail();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -37,7 +37,7 @@
import org.chorem.pollen.business.services.ServiceAuth;
import org.chorem.pollen.business.services.ServiceUser;
import org.chorem.pollen.business.utils.MD5;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
/**
* Classe de la page d'enregistrement d'un utilisateur.
@@ -103,7 +103,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/** Injection des services */
@Inject
@@ -170,7 +170,7 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-03-02 20:14:34 UTC (rev 2893)
@@ -44,7 +44,7 @@
import org.chorem.pollen.business.services.ServicePollAccount;
import org.chorem.pollen.ui.components.FeedBack;
import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.data.Lien;
+import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.utils.CSVAccountUtil;
import org.chorem.pollen.ui.utils.LDAPAccountUtil;
@@ -152,7 +152,7 @@
@SuppressWarnings("unused")
@Property
- private Lien[] address;
+ private AddressBarItem[] address;
/**
* Sert à créer listModel.
@@ -333,8 +333,8 @@
* Initialisation de l'affichage
*/
void setupRender() {
- address = new Lien[] { new Lien("Pollen", "Index"),
- new Lien(title, null) };
+ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+ new AddressBarItem(title, null) };
listModel = beanModelSource.createDisplayModel(PollAccountDTO.class,
componentResources.getMessages());
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-03-02 20:14:34 UTC (rev 2893)
@@ -2,7 +2,7 @@
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<head>
- <title>Pollen</title>
+ <title>Pollen<t:if t:test="pageTitle"> :: ${pageTitle}</t:if></title>
<link rel="icon" type="image/png" href="${asset:context:favicon.png}" />
<t:FeedContextLink t:id="feedContext" />
<t:if test="${feedFileExisting}">
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm.properties (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm.properties 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1 @@
+
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_en.properties (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_en.properties 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1 @@
+
Added: 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 (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,76 @@
+pageTitle-create=Cr\u00E9ation d'un nouveau sondage
+mainTitle-create=Nouveau sondage
+
+pageTitle-update=Modification du sondage %s
+
+date-pattern=dd/MM/yyyy HH:mm
+
+# Main Infos
+legend-mainInfos=Informations du sondage
+creatorName-label=Votre nom *
+creatorName-required-message=Vous devez fournir un nom.
+email-label=Votre em@il
+email-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
+email-regexp-message=Email invalide.
+title-label=Titre *
+title-required-message=Vous devez fournir un titre pour le sondage.
+description-label=Description
+beginDate-label=Date de d\u00E9but
+beginDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+beginDate-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59.
+beginDate-validate=La date de d\u00E9but doit-\u00EAtre post\u00E9rieure \u00E0 la date actuelle.
+endDate-label=Date de fin
+endDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+endDate-regexp-message=La date de fin doit-\u00EAtre au format 31/12/2000 23:59.
+endDate-validate=La date de fin doit-\u00EAtre post\u00E9rieure \u00E0 la date de d\u00E9but.
+pollType-label=Type de sondage
+pollType-help=Libre : accessible \u00E0 tout le monde<br/>Liste restreinte : accessible uniquement \u00E0 une liste de votants<br/>Par groupes : accessible \u00E0 plusieurs listes de votants
+voteCounting-label=Type de d\u00E9pouillement
+voteCounting-help=Simple : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/>Pourcentage : attribution d\'un pourcentage \u00E0 chaque choix<br/>Condorcet : classement des choix par ordre de pr\u00E9f\u00E9rence<br/>Nombre : R\u00E9ponse libre. Fait la somme et la moyenne des nombres.
+advancedOptions-label=Options avanc\u00E9es ?
+
+# Labels for enums
+PollType.FREE=Libre
+PollType.RESTRICTED=Liste restreinte
+PollType.GROUP=Par groupes
+VoteCountingType.NORMAL=Simple
+VoteCountingType.PERCENTAGE=Pourcentage
+VoteCountingType.CONDORCET=Condorcet
+VoteCountingType.NUMBER=Nombre
+ChoiceType.TEXT=Texte
+ChoiceType.DATE=Date
+ChoiceType.IMAGE=Image
+
+# Options
+legend-options=Options avanc\u00E9es
+anonymous-label=Sondage anonyme
+anonymous-help=Les votants ainsi que leurs votes sont anonymes
+anonymousVoteAllowed-label=Autoriser le vote anonyme
+anonymousVoteAllowed-help=Les votants peuvent \u00EAtre anonymes
+continuousResults-label=R\u00E9sultats continus
+continuousResults-help=Les r\u00E9sultats du sondage sont affich\u00E9s en continu au moment du vote
+publicResults-label=R\u00E9sultats publics
+publicResults-help=Les r\u00E9sultats du sondage sont consultables par tout le monde
+choiceAddAllowed-label=Autoriser l'ajout de choix
+choiceAddAllowed-help=Il est possible d\'ajouter des choix au sondage.
+beginChoiceDate-label=Date de d\u00E9but
+beginChoiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+beginChoiceDate-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59.
+beginChoiceDate-validate=La date d'ajout de choix doit-\u00EAtre ant\u00E9rieure \u00E0 la date de d\u00E9but du sondage.
+endChoiceDate-label=Date de fin
+endChoiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+endChoiceDate-regexp-message=La date de fin doit-\u00EAtre au format 31/12/2000 23:59.
+endChoiceDate-validate=La date de fin d'ajout de choix doit-\u00EAtre post\u00E9rieure \u00E0 la date de d\u00E9but.
+choiceNb-label=Limiter le nombre de choix par vote
+choiceNb-help=Le nombre de choix que l\'utilisateur peut s\u00E9lectionner est limit\u00E9. Option disponible uniquement pour un d\u00E9pouillement simple.
+maxChoiceNb-label=Limite
+maxChoiceNb-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0.
+sendNotification-label=Recevoir des emails de notification
+sendNotification-help=Un email vous est envoy\u00E9 tous les N votes pour vous permettre de suivre l'avanc\u00E9e du sondage. Vous devez pr\u00E9ciser votre email pour acc\u00E9der \u00E0 cette option.
+notification-label=Tous les
+notification-label2=votes
+notification-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0.
+sendReminder-label=Envoyer des emails de rappel
+sendReminder-help=Un email de rappel est envoy\u00E9 aux votants qui n\'ont pas encore vot\u00E9 N heures avant la fin du sondage. Option disponible uniquement pour un sondage restreint ou par groupes.
+reminder-label=heures avant la fin
+reminder-min-message=La valeur doit-\u00EAtre sup\u00E9rieure \u00E0 0.
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/css/main.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/main.css 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/webapp/css/main.css 2010-03-02 20:14:34 UTC (rev 2893)
@@ -18,10 +18,30 @@
float: right;
}
+.clearfix {
+ display:block;
+}
+
+.clearfix:after {
+ content:".";
+ display:block;
+ height:0;
+ clear:both;
+ visibility:hidden;
+}
+
.clr {
clear: both;
}
+.hidden {
+ display: none;
+}
+
+.display {
+ display: block;
+}
+
#CreationBody {
background-image: url("../img/bigCreation.png");
}
@@ -344,6 +364,8 @@
font-weight: bold;
}
+/* TODO : refactor titleCreation usage by titlePoll */
+#corps .titlePoll,
#corps .titleCreation {
color: #32b5c9;
font-weight: bold;
Added: trunk/pollen-ui/src/main/webapp/css/poll.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/poll.css (rev 0)
+++ trunk/pollen-ui/src/main/webapp/css/poll.css 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,54 @@
+/*
+ Document : poll
+ Created on : 2 mars 2010, 14:10:25
+ Author : fdesbois
+ Description:
+ Stylesheet for poll pages.
+*/
+
+legend {
+ color: #727a7e;
+ font-weight: bold;
+}
+
+.disabled {
+ color: #555;
+}
+
+#pollForm-mainInfos fieldset {
+ border: 1px solid #aab;
+ padding: 15px;
+ width: 410px;
+ margin-left: 30px;
+ vertical-align: top;
+ text-align: left;
+}
+
+#pollForm-mainInfos label {
+ display: block;
+ width: 150px;
+ float: left;
+}
+
+#pollForm-mainInfos div,
+#pollForm-options div,
+#listsCreationFormDiv div {
+ margin-bottom: 10px;
+}
+
+#pollForm-options fieldset {
+ border: 1px solid #aab;
+ padding: 15px;
+ width: 410px;
+ margin-left: 20px;
+ vertical-align: top;
+ text-align: left;
+}
+
+/*#choiceDateDiv,
+#choiceNbDiv,
+#notificationDiv,
+#reminderDiv {
+ color: #555;
+}*/
+
Added: trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js (rev 0)
+++ trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,103 @@
+var ZoneUpdater = Class.create();
+
+ZoneUpdater.prototype = {
+
+ initialize: function(zoneElementId, listeningElement, event, link, zone, placeholder) {
+
+ this.zoneElement = $(zoneElementId);
+
+ this.event = event;
+
+ this.link = link;
+
+ this.placeholder = placeholder;
+
+ $T(this.zoneElement).zoneId = zone;
+
+ listeningElement.observe(this.event, this.updateZone.bindAsEventListener(this));
+
+ },
+
+ updateZone: function(event) {
+
+ var zoneObject = Tapestry.findZoneManager(this.zoneElement);
+
+ if ( !zoneObject ) return;
+
+ var param;
+
+ if (this.zoneElement.value) {
+
+ param = this.zoneElement.value;
+
+ }
+
+ if (!param) param = ' ';
+
+ param = this.encodeForUrl(param);
+
+ var updatedLink = this.link.gsub(this.placeholder, param);
+
+ zoneObject.updateFromURL(updatedLink);
+
+ },
+
+ encodeForUrl: function(string) {
+
+ /**
+
+ * See equanda.js for updated version of this
+
+ */
+
+ string = string.replace(/\r\n/g,"\n");
+
+ var res = "";
+
+ for (var n = 0; n < string.length; n++)
+
+ {
+
+ var c = string.charCodeAt( n );
+
+ if ( '$' == string.charAt( n ) )
+
+ {
+
+ res += '$$';
+
+ }
+
+ else if ( this.inRange( c, "AZ" ) || this.inRange( c, "az" ) || this.inRange( c, "09" ) || this.inRange( c, ".." ) )
+
+ {
+
+ res += string.charAt( n )
+
+ }
+
+ else
+
+ {
+
+ var tmp = c.toString(16);
+
+ while ( tmp.length < 4 ) tmp = "0" + tmp;
+
+ res += '$' + tmp;
+
+ }
+
+ }
+
+ return res;
+
+ },
+
+ inRange: function(code, range) {
+
+ return code >= range.charCodeAt( 0 ) && code <= range.charCodeAt( 1 );
+
+ }
+
+}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-26 18:01:14 UTC (rev 2892)
+++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-03-02 20:14:34 UTC (rev 2893)
@@ -1,12 +1,12 @@
<t:border t:address="address" t:pageLogo="literal:Creation"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-
+
<t:feedback t:id="feedback"/>
<h1 class="titleCreation">${message:title-new}</h1>
<t:zone t:id="pollCreationZone" show="show" update="show">
<t:form t:id="pollCreationForm" t:zone="pollCreationZone">
-
+
<!-- Étape POLL -->
<t:formfragment visible="inPoll">
<div id="pollCreationFormDiv">
@@ -60,7 +60,7 @@
</div>
</div>
</t:formfragment>
-
+
<!-- Étape OPTIONS -->
<t:formfragment visible="inOptions">
<div id="optionsCreationFormDiv">
@@ -164,7 +164,7 @@
</div>
</div>
</t:formfragment>
-
+
<!-- Étape LISTS -->
<t:formfragment visible="inLists">
<div id="listsCreationFormDiv">
@@ -222,8 +222,8 @@
</t:formfragment>
</t:form>
-
+
<!-- Étape CHOICES - Formulaire différent car t:upload ne fonctionne pas en ajax -->
<t:if test="inChoices">
<t:FeedContextLink t:id="feedContext" />
@@ -232,7 +232,7 @@
<t:if test="!isNumberVoteCounting()">
<div>
<t:label for="choiceType" />:
- <t:select t:id="choiceType" t:value="poll.choiceType" t:validate="required"
+ <t:select t:id="choiceType" t:value="poll.choiceType" t:validate="required"
t:mixins="ck/OnEvent" event="change" onCompleteCallback="onCompleteZoneUpdate">
</t:select>
</div>
@@ -295,7 +295,7 @@
</div>
</t:form>
</t:if>
-
-
+
+
</t:zone>
</t:border>
\ No newline at end of file
Added: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml (rev 0)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-03-02 20:14:34 UTC (rev 2893)
@@ -0,0 +1,205 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<t:border t:address="addressBar.items" t:pageLogo="literal:Creation" 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/>
+ <div class="clearfix">
+ <!-- MAIN INFOS -->
+ <div id="pollForm-mainInfos" class="fleft">
+ <fieldset>
+ <legend>${message:legend-mainInfos}</legend>
+ <div>
+ <label t:type="label" for="creatorName" />
+ <input type="text" t:type="textfield" t:id="creatorName" value="poll.creatorName" t:validate="required,minlength=2"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="keyup" t:zone="mainZone"/>
+ </div>
+ <div>
+ <label t:type="label" for="email" />
+ <input type="text" t:type="textfield" t:id="email" value="poll.creatorEmail" t:validate="regexp"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="keyup" t:zone="mainZone"/>
+ </div>
+ <br />
+ <div>
+ <label t:type="label" for="title" />
+ <input type="text" t:type="textfield" t:id="title" value="poll.title" t:validate="required"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="keyup" t:zone="mainZone" />
+ </div>
+ <div>
+ <label t:type="label" for="description" />
+ <textarea t:type="textarea" cols="23" rows="1" t:id="description" t:value="poll.description"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="keyup" t:zone="mainZone" >${poll.description}</textarea>
+ </div>
+ <div>
+ <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
+ <label t:type="label" for="beginDate" />
+ <input t:type="ck/dateTimeField" t:id="beginDate" value="poll.beginDate" t:validate="regexp"
+ t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="blur" t:zone="mainZone" />
+ </div>
+ <div>
+ <!-- FIXME : validate by regexp doesn't work : seems to be caused by dateTimeField component -->
+ <label t:type="label" for="endDate" />
+ <input t:type="ck/dateTimeField" t:id="endDate" value="poll.endDate" t:validate="regexp"
+ t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="blur" t:zone="mainZone"/>
+ </div>
+ <div>
+ <label t:type="label" for="pollType" />
+ <select t:type="select" t:id="pollType" t:value="poll.pollType" t:validate="required"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone">
+ <option></option>
+ </select>
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:pollType-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ </div>
+ <div>
+ <label t:type="label" for="voteCounting" />
+ <select t:type="select" t:id="voteCounting" t:value="poll.voteCounting" t:validate="required"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone">
+ <option></option>
+ </select>
+ <span t:type="ck/Tooltip" title="${message:help}" t:value="${message:voteCounting-help}" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:help}"/>
+ </span>
+ </div>
+ <div>
+ <label t:type="label" for="advancedOptions" />
+ <input t:type="checkbox" t:id="advancedOptions" t:mixins="triggerfragment,zoneUpdater" t:fragment="optionsFragment"
+ t:event="change" t:zone="mainZone"/>
+ </div>
+ </fieldset>
+ <!-- <div class="buttons">
+ <input t:type="submit" value="${message:next-button}" />
+ </div>-->
+ </div>
+ <!-- OPTIONS -->
+ <t:formfragment t:id="optionsFragment" visible="advancedOptions">
+ <div id="pollForm-options" class="fleft">
+ <fieldset>
+ <legend>${message:legend-options}</legend>
+ <div>
+ <input t:type="checkbox" t:id="anonymous" value="poll.anonymous" t:mixins="zoneUpdater" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="anonymous" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymous-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ </div>
+ <div>
+ <input t:type="checkbox" t:id="anonymousVoteAllowed" value="poll.anonymousVoteAllowed" disabled="anonymousVoteAllowedDisabled"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="anonymousVoteAllowed" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:anonymousVoteAllowed-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ </div>
+ <div>
+ <input t:type="checkbox" t:id="continuousResults" value="poll.continuousResults"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone" />
+ <label t:type="label" for="continuousResults" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:continuousResults-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ </div>
+ <div>
+ <input t:type="checkbox" t:id="publicResults" value="poll.publicResults" disabled="publicResultsDisabled"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="publicResults" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:publicResults-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ </div>
+ <div>
+ <input t:type="checkbox" t:id="choiceAddAllowed" value="poll.choiceAddAllowed"
+ t:mixins="triggerfragment,zoneUpdater" t:fragment="choiceDateFragment" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="choiceAddAllowed" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceAddAllowed-help}" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ <br/>
+ <t:formFragment t:id="choiceDateFragment" t:visible="poll.choiceAddAllowed">
+ <label t:type="label" for="beginChoiceDate" />
+ <input t:type="ck/dateTimeField" t:id="beginChoiceDate" value="poll.beginChoiceDate" t:validate="regexp"
+ t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="blur" t:zone="mainZone"/>
+ <br />
+ <label t:type="label" for="endChoiceDate" />
+ <input t:type="ck/dateTimeField" t:id="endChoiceDate" value="poll.endChoiceDate" t:validate="regexp"
+ t:datePattern="message:date-pattern" t:timePicker="true" t:timePickerAdjacent="true"
+ t:mixins="zoneUpdater" t:event="change" t:clientEvent="blur" t:zone="mainZone"/>
+ </t:formFragment>
+<!-- <span id="choiceDateDiv" style="display: none;">
+
+ </span>-->
+ </div>
+ <!--<t:if test="normalVoteCounting">-->
+ <div>
+ <input t:type="checkbox" t:id="choiceNb" value="hasChoiceNb" disabled="choiceNbDisabled"
+ t:mixins="triggerfragment,zoneUpdater" t:fragment="choiceNbFragment" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="choiceNb" class="${choiceNbLabelStyle}" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:choiceNb-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ <br/>
+ <t:formFragment t:id="choiceNbFragment" t:visible="hasChoiceNb">
+ <label t:type="label" for="maxChoiceNb" />
+ <input t:type="textfield" t:id="maxChoiceNb" t:value="poll.maxChoiceNb" t:size="1" t:validate="min=0"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone"/>
+ </t:formFragment>
+ </div>
+ <!--</t:if>-->
+ <!--<t:if test="poll.creatorEmail">-->
+ <div>
+ <input t:type="checkbox" t:id="sendNotification" value="hasNotification" disabled="notificationDisabled"
+ t:mixins="triggerfragment,zoneUpdater" t:fragment="notificationFragment" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="sendNotification" class="${notificationLabelStyle}" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:sendNotification-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ <br/>
+ <t:formFragment t:id="notificationFragment" t:visible="hasNotification">
+ <label t:type="label" for="notification" />
+ <input t:type="textfield" t:id="notification" value="notification.sensibility" t:size="3" t:validate="min=0"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone"/>
+ ${message:notification-label2}
+ </t:formFragment>
+ </div>
+ <!--</t:if>-->
+ <!--<t:unless test="freePoll">-->
+ <div>
+ <input t:type="checkbox" t:id="sendReminder" t:value="hasReminder" disabled="reminderDisabled"
+ t:mixins="triggerfragment,zoneUpdater" t:fragment="reminderFragment" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="sendReminder" class="${reminderLabelStyle}" />
+ <span t:type="ck/Tooltip" title="message:help" t:value="message:sendReminder-help" t:effect="appear">
+ <img src="${asset:context:img/help.png}" alt="message:help"/>
+ </span>
+ <br/>
+ <t:formFragment t:id="reminderFragment" t:visible="hasReminder">
+ <input t:type="textfield" t:id="reminder" t:value="reminder.sensibility" t:size="1" t:validate="min=0"
+ t:mixins="zoneUpdater" t:event="change" t:zone="mainZone"/>
+ <label t:type="label" for="reminder" />
+ </t:formFragment>
+ </div>
+ <!--</t:unless>-->
+ </fieldset>
+ <!-- <div class="buttons">
+ <t:eventLink t:event="previous" t:zone="pollCreationZone" style="text-decoration: none;">
+ <input type="button" value="${message:prev-button}" />
+ </t:eventLink>
+ <t:submit t:value="${message:next-button}" t:zone="pollCreationZone" />
+ </div>-->
+ </div>
+ </t:formfragment>
+
+ </div>
+ </form>
+ </t:zone>
+</t:border>
1
0
r2892 - in trunk/pollen-business/src: main/java/org/chorem/pollen/business/services test/java/org/chorem/pollen/business/services
by fdesbois@users.chorem.org 26 Feb '10
by fdesbois@users.chorem.org 26 Feb '10
26 Feb '10
Author: fdesbois
Date: 2010-02-26 19:01:14 +0100 (Fri, 26 Feb 2010)
New Revision: 2892
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
Log:
delete useless methods (used nowhere)
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 17:37:14 UTC (rev 2891)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 18:01:14 UTC (rev 2892)
@@ -45,19 +45,6 @@
public String createVotingList(VotingListDTO votingList);
/**
- * Création des groupes de votant du sondage
- *
- * @param votingLists les dtos listes
- * @param pollId l'identifiant du sondage
- * @param transaction la transaction du sondage
- * @return les groupes créés
- * @deprecated useless method : used nowhere
- */
- @Deprecated
- public List<VotingList> createVotingLists(List<VotingListDTO> votingLists,
- String pollId, TopiaContext transaction);
-
- /**
* Mise à jour d'une liste de votant
*
* @param votingList la liste
@@ -66,46 +53,6 @@
public boolean updateVotingList(VotingListDTO votingList);
/**
- * Suppression d'une liste de votant
- *
- * @param votingListId l'identifiant de la liste
- * @return true si la liste a été mise à jours
- * @deprecated useless method : used only in tests
- */
- @Deprecated
- public boolean deleteVotingList(String votingListId);
-
- /**
- * Recherche d'une liste par son identifiant
- *
- * @param votingListId l'identifiant de la liste
- * @return la liste
- * @deprecated useless method : used only in tests
- */
- @Deprecated
- public VotingListDTO findVotingListById(String votingListId);
-
- /**
- * Recherche d une liste de votant à partir du nom
- *
- * @param name le nom de la liste
- * @return les listes
- * @deprecated useless method : used only in tests
- */
- @Deprecated
- public List<VotingListDTO> findVotingListByName(String name);
-
- /**
- * Recherche des listes à partir d'un filtre
- *
- * @param properties filtre sur les champs de la table VotingList
- * @return les listes de votants
- * @deprecated useless method : used only in tests
- */
- @Deprecated
- public List<VotingListDTO> selectVotingList(Map<String, Object> properties);
-
- /**
* Création d'une liste de favoris
*
* @param personList la liste
@@ -114,19 +61,6 @@
public String createPersonList(PersonListDTO personList);
/**
- * Création d'une liste de favoris pour un user
- *
- * @param lists les dtos personList
- * @param userId l'identifiant de l'utilisateur
- * @param transaction la transaction du sondage
- * @return true si toutes les listes ont été créés
- * @deprecated useless method : used nowhere
- */
- @Deprecated
- public boolean createPersonLists(List<PersonListDTO> lists, String userId,
- TopiaContext transaction);
-
- /**
* Create an {@code account} in a {@code personList}.
*
* @param personList where the account will be added
@@ -168,30 +102,10 @@
public PersonListDTO findPersonListById(String personListId);
/**
- * Recherche des listes de favoris à partir du nom
- *
- * @param name le nom de la liste
- * @return les listes
- * @deprecated useless method : used only in tests
- */
- @Deprecated
- public List<PersonListDTO> findPersonListByName(String name);
-
- /**
* Recherche des listes de favoris d'un utilisateur.
*
* @param userId Le créateur de la liste
* @return les listes
*/
public List<PersonListDTO> findPersonListByUser(String userId);
-
- /**
- * Recherche des listes à partir d'un filtre
- *
- * @param properties filtre sur les champs de la table personList
- * @return les listes de votants
- * @deprecated useless method : used only in tests
- */
- @Deprecated
- public List<PersonListDTO> selectPersonList(Map<String, Object> properties);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 17:37:14 UTC (rev 2891)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 18:01:14 UTC (rev 2892)
@@ -114,49 +114,6 @@
}
@Override
- public List<VotingList> createVotingLists(List<VotingListDTO> votingLists,
- String pollId, TopiaContext transaction) {
- if (votingLists.isEmpty() || pollId.length() == 0) {
- return null;
- }
-
- List<VotingList> result = null;
- try {
- votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
-
- votingListConverter.setTransaction(transaction);
-
- result = new ArrayList<VotingList>();
- for (VotingListDTO votingList : votingLists) {
- VotingList votingListEntity = votingListDAO.create();
- votingList.setPollId(pollId);
- votingListConverter.populateVotingListEntity(votingList,
- votingListEntity);
-
- // Création des pollAccount de la liste si nécessaire
- // FIXME do not call a Service from an other one
- ServicePollAccount spa = new ServicePollAccountImpl();
- //spa.createPollAccounts(votingList.getPollAccountDTOs(), trans);
- for (PollAccountDTO account : votingList.getPollAccountDTOs()) {
- if (spa.findPollAccountById(account.getId()) == null) {
- account.setId(spa.createPollAccount(account));
- }
- }
-
- // Création des PersonToList
- votingListConverter.populatePersonVotingList(votingList,
- votingListEntity);
- result.add(votingListEntity);
- }
-
- return result;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- }
- }
-
- @Override
public boolean updateVotingList(VotingListDTO votingList) {
TopiaContext transaction = null;
try {
@@ -186,138 +143,6 @@
}
@Override
- public boolean deleteVotingList(String votingListId) {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
-
- VotingList entity = votingListDAO.findByTopiaId(votingListId);
-
- votingListDAO.delete(entity);
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entity deleted: " + votingListId);
- }
-
- return true;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return false;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
- public VotingListDTO findVotingListById(String votingListId) {
- TopiaContext transaction = null;
- VotingListDTO result = null;
- try {
- transaction = rootContext.beginTransaction();
-
- votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
-
- VotingList votingListEntity = votingListDAO
- .findByTopiaId(votingListId);
-
- if (votingListEntity != null) {
- votingListConverter.setTransaction(transaction);
- result = votingListConverter
- .createVotingListDTO(votingListEntity);
- }
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entity found: "
- + ((result == null) ? "null" : result.getId()));
- }
-
- return result;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
- public List<VotingListDTO> findVotingListByName(String name) {
- TopiaContext transaction = null;
- List<VotingListDTO> results = null;
- List<VotingList> votingListEntities = null;
- try {
- transaction = rootContext.beginTransaction();
-
- votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
-
- votingListEntities = votingListDAO.findAllByName(name);
-
- votingListConverter.setTransaction(transaction);
- results = votingListConverter
- .createVotingListDTOs(votingListEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: "
- + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
- public List<VotingListDTO> selectVotingList(Map<String, Object> properties) {
- TopiaContext transaction = null;
- List<VotingListDTO> results = null;
- List<VotingList> votingListEntities = null;
- try {
- transaction = rootContext.beginTransaction();
-
- votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
-
- if (properties == null) {
- votingListEntities = votingListDAO.findAll();
- if (log.isWarnEnabled()) {
- log
- .warn("Attention : toutes les listes ont été sélectionnés !");
- }
- } else {
- votingListEntities = votingListDAO
- .findAllByProperties(properties);
- }
- votingListConverter.setTransaction(transaction);
- results = votingListConverter
- .createVotingListDTOs(votingListEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: "
- + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
public String createPersonList(PersonListDTO personList) {
TopiaContext transaction = null;
String topiaId = "";
@@ -357,41 +182,6 @@
}
@Override
- public boolean createPersonLists(List<PersonListDTO> personLists,
- String userId, TopiaContext transaction) {
- if (personLists.isEmpty() || userId.length() == 0) {
- return false;
- }
-
- try {
- personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
-
- personListConverter.setTransaction(transaction);
- for (PersonListDTO personList : personLists) {
- PersonList entity = personListDAO.create();
-
- // Création des comptes de la liste
- // FIXME do not call a Service from an other one
- ServicePollAccount spa = new ServicePollAccountImpl();
- for (PollAccountDTO account : personList.getPollAccounts()) {
- account.setPersonListId(entity.getTopiaId());
- }
- entity.setPollAccount(spa.createPollAccounts(personList
- .getPollAccounts(), transaction));
-
- personList.setUserId(userId);
- personListConverter
- .populatePersonListEntity(personList, entity);
- }
-
- return true;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return false;
- }
- }
-
- @Override
public void createAccountInPersonList(PersonListDTO personList, PollAccountDTO account) {
TopiaContext transaction = null;
try {
@@ -564,38 +354,6 @@
}
@Override
- public List<PersonListDTO> findPersonListByName(String name) {
- TopiaContext transaction = null;
- List<PersonListDTO> results = null;
- List<PersonList> personListEntities = null;
- try {
- transaction = rootContext.beginTransaction();
-
- personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
-
- personListEntities = personListDAO.findAllByName(name);
-
- personListConverter.setTransaction(transaction);
- results = personListConverter
- .createPersonListDTOs(personListEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: "
- + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
public List<PersonListDTO> findPersonListByUser(String userId) {
TopiaContext transaction = null;
List<PersonListDTO> results = null;
@@ -629,44 +387,4 @@
ContextUtil.doFinally(transaction);
}
}
-
- @Override
- public List<PersonListDTO> selectPersonList(Map<String, Object> properties) {
- TopiaContext transaction = null;
- List<PersonListDTO> results = null;
- List<PersonList> personListEntities = null;
- try {
- transaction = rootContext.beginTransaction();
-
- personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
-
- if (properties == null) {
- personListEntities = personListDAO.findAll();
- if (log.isWarnEnabled()) {
- log
- .warn("Attention : toutes les listes ont été sélectionnés !");
- }
- } else {
- personListEntities = personListDAO
- .findAllByProperties(properties);
- }
- personListConverter.setTransaction(transaction);
- results = personListConverter
- .createPersonListDTOs(personListEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: "
- + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
}
\ No newline at end of file
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 17:37:14 UTC (rev 2891)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 18:01:14 UTC (rev 2892)
@@ -84,25 +84,4 @@
* @return un compte
*/
public PollAccountDTO findPollAccountByAccountId(String pollAccountId);
-
- /**
- * Récupération des comptes d'un utilisateur.
- *
- * @param userId l'identifiant de l'utilisateur
- * @return la liste des comptes de l'utilisateur
- * @deprecated useless method : used nowhere
- */
- @Deprecated
- public List<PollAccountDTO> findPollAccountsByUser(String userId);
-
- /**
- * Recherche des comptes à partir d'un filtre.
- *
- * @param properties filtre sur les champs de la table pollAccount
- * @return les comptes
- * @deprecated useless method : used nowhere
- */
- @Deprecated
- public List<PollAccountDTO> selectPollAccounts(
- Map<String, Object> properties);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 17:37:14 UTC (rev 2891)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 18:01:14 UTC (rev 2892)
@@ -250,79 +250,4 @@
ContextUtil.doFinally(transaction);
}
}
-
- @Override
- public List<PollAccountDTO> findPollAccountsByUser(String userId) {
- TopiaContext transaction = null;
- List<PollAccountDTO> results = null;
- List<PollAccount> pollAccountEntities = null;
- UserAccountDAO userDAO = null;
- try {
- transaction = rootContext.beginTransaction();
-
- userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
- UserAccount user = userDAO.findByTopiaId(userId);
-
- pollAccountEntities = new ArrayList<PollAccount>();
- pollAccountEntities.addAll(user.getPollAccount());
-
- converter.setTransaction(transaction);
- results = converter.createPollAccountDTOs(pollAccountEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: "
- + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
- public List<PollAccountDTO> selectPollAccounts(
- Map<String, Object> properties) {
- TopiaContext transaction = null;
- List<PollAccountDTO> results = null;
- List<PollAccount> pollAccountEntities = null;
- try {
- transaction = rootContext.beginTransaction();
-
- pollAccountDAO = PollenModelDAOHelper
- .getPollAccountDAO(transaction);
-
- if (properties == null) {
- pollAccountEntities = pollAccountDAO.findAll();
- if (log.isWarnEnabled()) {
- log
- .warn("Attention : tous les comptes ont été sélectionnés !");
- }
- } else {
- pollAccountEntities = pollAccountDAO
- .findAllByProperties(properties);
- }
- converter.setTransaction(transaction);
- results = converter.createPollAccountDTOs(pollAccountEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: "
- + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
}
\ No newline at end of file
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 17:37:14 UTC (rev 2891)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 18:01:14 UTC (rev 2892)
@@ -105,57 +105,6 @@
}
/**
- * Test of deleteVotingList method, of class ServiceListImpl.
- */
- @Test
- public void testDeleteVotingList() {
- VotingListDTO dto = new VotingListDTO();
- dto.setName("Test_DeleteVotingList");
- String votingListId = instance.createVotingList(dto);
- dto.setId(votingListId);
- boolean result = instance.deleteVotingList(votingListId);
- assertTrue(result);
- }
-
- /**
- * Test of findVotingListById method, of class ServiceListImpl.
- */
- @Test
- public void testFindVotingListById() {
- VotingListDTO dto = new VotingListDTO();
- dto.setName("test_findVotingListById");
- String votingListId = instance.createVotingList(dto);
- VotingListDTO result = instance.findVotingListById(votingListId);
- String resultId = result.getId();
- assertEquals(votingListId, resultId);
- }
-
- /**
- * Test of findVotingListByName method, of class ServiceListImpl.
- */
- @Test
- public void testFindVotingListByName() {
- VotingListDTO dto = new VotingListDTO();
- dto.setName("Test_findVotingListByName");
- String votingListId = instance.createVotingList(dto);
- List<VotingListDTO> result = instance
- .findVotingListByName("Test_findVotingListByName");
- assertEquals(result.size(), 1);
- }
-
- /**
- * Test of selectVotingList method, of class ServiceListImpl.
- */
- @Test
- public void testSelectVotingList() {
- VotingListDTO dto = new VotingListDTO();
- dto.setName("test_selectVotingList");
- String votingListId = instance.createVotingList(dto);
- List<VotingListDTO> result = instance.selectVotingList(null);
- assertTrue(result.size() > 0);
- }
-
- /**
* Test of createPersonList method, of class ServiceListImpl.
*/
@Test
@@ -291,29 +240,4 @@
String resultId = result.getId();
assertEquals(personListId, resultId);
}
-
- /**
- * Test of findPersonListByName method, of class ServiceListImpl.
- */
- @Test
- public void testFindPersonListByName() {
- PersonListDTO dto = new PersonListDTO();
- dto.setName("test_findPersonListByName");
- String personListId = instance.createPersonList(dto);
- List<PersonListDTO> result = instance
- .findPersonListByName("test_findPersonListByName");
- assertEquals(result.size(), 1);
- }
-
- /**
- * Test of selectPersonlist method, of class ServiceListImpl.
- */
- @Test
- public void testSelectPersonlist() {
- PersonListDTO dto = new PersonListDTO();
- dto.setName("test_selectPersonList");
- String personListId = instance.createPersonList(dto);
- List<PersonListDTO> result = instance.selectPersonList(null);
- assertTrue(result.size() > 0);
- }
}
\ No newline at end of file
1
0
r2891 - trunk/pollen-business/src/main/java/org/chorem/pollen/business
by fdesbois@users.chorem.org 26 Feb '10
by fdesbois@users.chorem.org 26 Feb '10
26 Feb '10
Author: fdesbois
Date: 2010-02-26 18:37:14 +0100 (Fri, 26 Feb 2010)
New Revision: 2891
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java
Log:
ups :)
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-02-26 17:32:17 UTC (rev 2890)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-02-26 17:37:14 UTC (rev 2891)
@@ -43,7 +43,6 @@
}
public String getKey() {
- PollenProperty.EMAIL_HOST.getValue();
return key;
}
1
0
Author: fdesbois
Date: 2010-02-26 18:32:17 +0100 (Fri, 26 Feb 2010)
New Revision: 2890
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.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/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
trunk/pollen-ui/src/main/webapp/user/UserLists.tml
Log:
- Refactor account usage in personList -> createAccountInPersonList and deleteAccountFromPersonList :
easier usage in ui module.
- other improves
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -43,6 +43,7 @@
}
public String getKey() {
+ PollenProperty.EMAIL_HOST.getValue();
return key;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -71,7 +71,7 @@
}
if (ePersonList.getPollAccount().size() > 0) {
DataPollAccountConverter converter = new DataPollAccountConverter();
- personListDTO.setPollAccountDTOs(converter
+ personListDTO.setPollAccounts(converter
.createPollAccountDTOs(ePersonList.getPollAccount()));
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -18,6 +18,7 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
/**
@@ -35,7 +36,7 @@
private String name = "";
- private List<PollAccountDTO> pollAccountDTOs = new ArrayList<PollAccountDTO>();
+ private List<PollAccountDTO> persons = new ArrayList<PollAccountDTO>();
public PersonListDTO() {
@@ -76,12 +77,34 @@
this.name = name;
}
- public List<PollAccountDTO> getPollAccountDTOs() {
- return pollAccountDTOs;
+ public List<PollAccountDTO> getPollAccounts() {
+ return persons;
}
- public void setPollAccountDTOs(List<PollAccountDTO> pollAccountDTOs) {
- this.pollAccountDTOs = pollAccountDTOs;
+ public void setPollAccounts(List<PollAccountDTO> persons) {
+ this.persons = persons;
}
+ public boolean addPollAccount(PollAccountDTO account) {
+ if (persons == null) {
+ persons = new ArrayList<PollAccountDTO>();
+ }
+ return persons.add(account);
+ }
+
+ public boolean removePollAccount(String accountId) {
+ if (persons == null) {
+ return false;
+ }
+ Iterator<PollAccountDTO> it = persons.iterator();
+ while (it.hasNext()) {
+ PollAccountDTO account = it.next();
+ if (accountId.equals(account.getId())) {
+ it.remove();
+ return true;
+ }
+ }
+ return false;
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -20,6 +20,7 @@
import java.util.Map;
import org.chorem.pollen.business.dto.PersonListDTO;
+import org.chorem.pollen.business.dto.PollAccountDTO;
import org.chorem.pollen.business.dto.VotingListDTO;
import org.chorem.pollen.business.persistence.VotingList;
import org.nuiton.topia.TopiaContext;
@@ -126,14 +127,23 @@
TopiaContext transaction);
/**
- * Mise à jour d'une liste de favoris
+ * Create an {@code account} in a {@code personList}.
*
- * @param personlistDTO la liste
- * @return true si la liste a été mise à jours
+ * @param personList where the account will be added
+ * @param account to create
*/
- public boolean updatePersonList(PersonListDTO personlistDTO);
+ void createAccountInPersonList(PersonListDTO personList,
+ PollAccountDTO account);
/**
+ * Delete an account using its {@code accountId} from a {@code personList}.
+ *
+ * @param personList where the account will be removed
+ * @param accountId topiaId of the account to delete
+ */
+ void deleteAccountFromPersonList(PersonListDTO personList, String accountId);
+
+ /**
* Suppression d'une liste de favoris
*
* @param personListId l'identifiant de la liste
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -22,8 +22,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenConverter;
import org.chorem.pollen.business.converters.DataPersonListConverter;
import org.chorem.pollen.business.converters.DataVotingListConverter;
import org.chorem.pollen.business.dto.PersonListDTO;
@@ -31,6 +31,8 @@
import org.chorem.pollen.business.dto.VotingListDTO;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PersonListDAO;
+import org.chorem.pollen.business.persistence.PollAccount;
+import org.chorem.pollen.business.persistence.PollAccountDAO;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.UserAccountDAO;
@@ -38,6 +40,7 @@
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.TopiaContext;
+import static org.nuiton.i18n.I18n._;
/**
* Implémentation du service de gestion des listes.
@@ -59,6 +62,9 @@
public ServiceListImpl() {
rootContext = PollenContext.getRootContext();
+
+ PollenConverter.preparePollAccountConverters();
+ PollenConverter.prepareVotingListConverters();
}
@Override
@@ -327,11 +333,11 @@
// Création des comptes de la liste
// FIXME do not call a Service from an other one
ServicePollAccount spa = new ServicePollAccountImpl();
- for (PollAccountDTO account : personList.getPollAccountDTOs()) {
+ for (PollAccountDTO account : personList.getPollAccounts()) {
account.setPersonListId(entity.getTopiaId());
}
entity.setPollAccount(spa.createPollAccounts(personList
- .getPollAccountDTOs(), transaction));
+ .getPollAccounts(), transaction));
topiaId = entity.getTopiaId();
@@ -367,11 +373,11 @@
// Création des comptes de la liste
// FIXME do not call a Service from an other one
ServicePollAccount spa = new ServicePollAccountImpl();
- for (PollAccountDTO account : personList.getPollAccountDTOs()) {
+ for (PollAccountDTO account : personList.getPollAccounts()) {
account.setPersonListId(entity.getTopiaId());
}
entity.setPollAccount(spa.createPollAccounts(personList
- .getPollAccountDTOs(), transaction));
+ .getPollAccounts(), transaction));
personList.setUserId(userId);
personListConverter
@@ -386,50 +392,78 @@
}
@Override
- public boolean updatePersonList(PersonListDTO personList) {
+ public void createAccountInPersonList(PersonListDTO personList, PollAccountDTO account) {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
- PersonList entity = personListDAO.findByTopiaId(personList.getId());
+ PersonList eList = personListDAO.findByTopiaId(personList.getId());
- personListConverter.setTransaction(transaction);
- personListConverter.populatePersonListEntity(personList, entity);
+ PollAccountDAO accountDAO =
+ PollenModelDAOHelper.getPollAccountDAO(transaction);
- personListDAO.update(entity);
+ // Create new pollAccount
+ String accountUID = PollenContext.createPollenUrlId();
+ PollAccount eAccount = accountDAO.create(accountUID);
+ PollenConverter.convert(account, eAccount);
- // mise à jour ou création des comptes
- // FIXME do not call a Service from an other one
- ServicePollAccount spa = new ServicePollAccountImpl();
- for (PollAccountDTO pollAccountDTO : personList
- .getPollAccountDTOs()) {
- pollAccountDTO.setPersonListId(entity.getTopiaId());
- boolean updated = spa.updatePollAccount(pollAccountDTO);
- if (!updated) {
- pollAccountDTO.setId(spa.createPollAccount(pollAccountDTO));
- }
+ // Add the account into the list
+ eList.addPollAccount(eAccount);
- if (log.isDebugEnabled()) {
- log.debug("PollAccount " + pollAccountDTO.getVotingId()
- + " (" + pollAccountDTO.getId() + ") updated: "
- + updated);
- }
- }
+ transaction.commitTransaction();
+ // Update change in dtos
+ account.setId(eAccount.getTopiaId());
+ account.setAccountId(eAccount.getAccountId());
+ personList.addPollAccount(account);
+
+ } catch (Exception eee) {
+ PollenContext.doCatch(eee,
+ _("pollen.error.serviceList.createAccountForPersonList",
+ personList.getName(), account.getVotingId()),
+ transaction
+ );
+ } finally {
+ PollenContext.doFinally(transaction);
+ }
+ }
+
+ @Override
+ public void deleteAccountFromPersonList(PersonListDTO personList, String accountId) {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // Find the account
+ PollAccountDAO accountDAO =
+ PollenModelDAOHelper.getPollAccountDAO(transaction);
+ PollAccount eAccount = accountDAO.findByTopiaId(accountId);
+
+ personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
+
+ PersonList eList = personListDAO.findByTopiaId(personList.getId());
+
+ // The remove will delete the comment because no poll will be
+ // attached to him (delete-orphan)
+ eList.removePollAccount(eAccount);
+
+ accountDAO.delete(eAccount);
+
transaction.commitTransaction();
- if (log.isDebugEnabled()) {
- log.debug("Entity updated: " + personList.getId());
- }
+ // Update change in dto
+ personList.removePollAccount(accountId);
- return true;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return false;
+ } catch (Exception eee) {
+ PollenContext.doCatch(eee,
+ _("pollen.error.serviceList.deleteAccountFromPersonList",
+ accountId, personList.getName(), personList.getId()),
+ transaction
+ );
} finally {
- ContextUtil.doFinally(transaction);
+ PollenContext.doFinally(transaction);
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -42,19 +42,6 @@
public String createPollAccount(PollAccountDTO pollAccount);
/**
- * Creation d'un compte utilisateur.
- *
- * @param votingId l'identifiant du votant
- * @param email l'email du votant
- * @param userId l'identifiant de l'utilisateur
- * @return le topiaId du compte créé
- * @deprecated useless method : not used in UI
- */
- @Deprecated
- public PollAccount createPollAccount(String votingId, String email,
- String userId);
-
- /**
* Creation des comptes utilisateur.
*
* @param pollAccounts les comptes à creer
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -90,43 +90,6 @@
}
@Override
- public PollAccount createPollAccount(String votingId, String email,
- String userId) {
- TopiaContext transaction = null;
- String topiaId;
- PollAccount pollAccountEntity = null;
- try {
- transaction = rootContext.beginTransaction();
-
- pollAccountDAO = PollenModelDAOHelper
- .getPollAccountDAO(transaction);
-
- // Identifiant du compte
- String id = ContextUtil.createPollenUrlId();
- pollAccountEntity = pollAccountDAO.create(PollAccount.ACCOUNT_ID, id);
-
- converter.setTransaction(transaction);
- converter.populatePollAccountEntity(votingId, email, userId,
- pollAccountEntity);
-
- topiaId = pollAccountEntity.getTopiaId();
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entity created: " + topiaId);
- }
-
- return pollAccountEntity;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- ContextUtil.doFinally(transaction);
- }
- }
-
- @Override
public List<PollAccount> createPollAccounts(
List<PollAccountDTO> pollAccounts, TopiaContext transaction) {
if (pollAccounts.isEmpty()) {
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-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-02-26 17:32:17 UTC (rev 2890)
@@ -4,6 +4,8 @@
pollen.error.context.rollback=
pollen.error.context.start=
pollen.error.context.stop=
+pollen.error.serviceList.createAccountForPersonList=
+pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.servicePoll.addComment=
pollen.error.servicePoll.createPoll=
pollen.error.servicePoll.delete=
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-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-02-26 17:32:17 UTC (rev 2890)
@@ -4,6 +4,8 @@
pollen.error.context.rollback=Erreur lors de l'annulation de la transaction
pollen.error.context.start=Erreur lors du d\u00E9marrage de l'application
pollen.error.context.stop=Erreur lors de l'arr\u00EAt de l'application
+pollen.error.serviceList.createAccountForPersonList=
+pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire cr\u00E9\u00E9 par %1$s pour le sondage %2$s (%3$s)
pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s cr\u00E9\u00E9 par %2$s
pollen.error.servicePoll.deleteComment=Impossible de supprimer le commentaire ayant pour identifiant "%1$s", appartenenant au sondage %2$s (%3$s)
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -16,7 +16,6 @@
package org.chorem.pollen.business.services;
-import org.chorem.pollen.business.PollenBusinessException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -24,12 +23,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.TestData;
import org.chorem.pollen.business.TestManager;
import org.chorem.pollen.business.dto.PersonListDTO;
+import org.chorem.pollen.business.dto.PollAccountDTO;
import org.chorem.pollen.business.dto.VotingListDTO;
-import org.chorem.pollen.business.utils.ContextUtil;
+import org.chorem.pollen.business.persistence.PersonList;
+import org.chorem.pollen.business.persistence.PersonListDAO;
+import org.chorem.pollen.business.persistence.PollAccount;
+import org.chorem.pollen.business.persistence.PollAccountDAO;
+import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -162,19 +168,105 @@
/**
* Test of updatePersonList method, of class ServiceListImpl.
+ * @throws Exception
*/
@Test
- public void testUpdatePersonList() {
+ public void testCreateAccountInPersonList() throws Exception {
+ // temp stop, must refactor all tests from this class
+ TestManager.stop();
+ TestManager.start("createAccountInPersonList");
+ instance = new ServiceListImpl();
+
+ /** PREPARE DATA **/
PersonListDTO dto = new PersonListDTO();
- dto.setName("test_UpdatePersonList");
- String personListId = instance.createPersonList(dto);
+ dto.setName("list");
+ final String personListId = instance.createPersonList(dto);
dto.setId(personListId);
- dto.setName("new name");
- boolean result = instance.updatePersonList(dto);
- assertTrue(result);
+
+ final PollAccountDTO account = new PollAccountDTO();
+ account.setVotingId("Jack Pot");
+ account.setEmail("jackpot(a)pompedup.fr");
+
+ /** EXEC METHOD **/
+ instance.createAccountInPersonList(dto, account);
+ Assert.assertNotNull(account.getAccountId());
+ Assert.assertNotNull(account.getId());
+ Assert.assertEquals(1, dto.getPollAccounts().size());
+
+ TestData test = new TestData() {
+
+ @Override
+ protected void test() throws Exception {
+ PollAccountDAO dao =
+ PollenModelDAOHelper.getPollAccountDAO(transaction);
+
+ PollAccount eAccount = dao.findByTopiaId(account.getId());
+ Assert.assertNotNull(eAccount);
+ Assert.assertNotNull(eAccount.getPersonList());
+ Assert.assertEquals(personListId,
+ eAccount.getPersonList().getTopiaId());
+ }
+
+ };
+
+ test.execute();
+
+ // temp stop, must refactor all tests from this class
+ TestManager.stop();
}
+
/**
+ * Test of updatePersonList method, of class ServiceListImpl.
+ */
+ @Test
+ public void testDeleteAccountFromPersonList() throws Exception {
+ // temp stop, must refactor all tests from this class
+ TestManager.stop();
+ TestManager.start("deleteAccountFromPersonList");
+ instance = new ServiceListImpl();
+
+ /** PREPARE DATA **/
+ PersonListDTO dto = new PersonListDTO();
+ dto.setName("list");
+ final String personListId = instance.createPersonList(dto);
+ dto.setId(personListId);
+
+ final PollAccountDTO account = new PollAccountDTO();
+ account.setVotingId("Jack Pot");
+ account.setEmail("jackpot(a)pompedup.fr");
+
+ instance.createAccountInPersonList(dto, account);
+
+ /** EXEC METHOD **/
+ instance.deleteAccountFromPersonList(dto, account.getId());
+
+ TestData test = new TestData() {
+
+ @Override
+ protected void test() throws Exception {
+ PollAccountDAO dao =
+ PollenModelDAOHelper.getPollAccountDAO(transaction);
+
+ PollAccount eAccount = dao.findByTopiaId(account.getId());
+ Assert.assertNull(eAccount);
+
+ PersonListDAO listDAO =
+ PollenModelDAOHelper.getPersonListDAO(transaction);
+
+ PersonList ePersonList = listDAO.findByTopiaId(personListId);
+ Assert.assertEquals(0, ePersonList.getPollAccount().size());
+ }
+
+ };
+
+ test.execute();
+
+ // temp stop, must refactor all tests from this class
+ TestManager.stop();
+ }
+
+ /**
* Test of deletePersonList method, of class ServiceListImpl.
*/
@Test
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -25,6 +25,7 @@
import java.util.Map;
import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link;
@@ -34,7 +35,6 @@
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Mixins;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
@@ -48,7 +48,6 @@
import org.apache.tapestry5.ioc.services.PropertyAccess;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.upload.services.UploadSymbols;
-import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -118,9 +117,6 @@
/** Mixin de selection de liste de favoris */
@SuppressWarnings("unused")
- @Component(parameters = { "event=change",
- "onCompleteCallback=literal:onCompleteZoneUpdate" })
- @Mixins( { "ck/OnEvent" })
private Select listSelect;
@InjectComponent
@@ -1008,21 +1004,22 @@
* est créé. Il sera retourné à la fonction JavaScript onCompleteCallback
* pour mettre à jour la zone.
*
+ * @param value
* @return un JSONObject contenant l'url de l'évènement mettant à jour la
* zone.
*/
public JSONObject onChangeFromListSelect(String value) {
- if (!"".equals(value)) {
+ if (StringUtils.isNotEmpty(value)) {
personList = serviceList.findPersonListById(value);
// Copie des personnes de la liste de favoris dans la liste de votants
- for (PollAccountDTO account : personList.getPollAccountDTOs()) {
+ for (PollAccountDTO account : personList.getPollAccounts()) {
account.setId("");
account.setPersonListId("");
}
votingLists.get(currentList).setPollAccountDTOs(
- personList.getPollAccountDTOs());
+ personList.getPollAccounts());
}
return createParamsForCallback();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-02-26 17:32:17 UTC (rev 2890)
@@ -208,7 +208,7 @@
accountsFile.getFileName()));
return this;
}
- newList.getPollAccountDTOs().addAll(accounts);
+ newList.getPollAccounts().addAll(accounts);
}
// Import LDAP des comptes
@@ -220,7 +220,7 @@
accountsUrl));
return this;
}
- newList.getPollAccountDTOs().addAll(accounts);
+ newList.getPollAccounts().addAll(accounts);
}
// Création de la nouvelle liste
@@ -263,17 +263,20 @@
* Méthode appelée à la création d'un compte.
*/
Object onSuccessFromCreateAccountForm() {
- for (PollAccountDTO dto : selectedList.getPollAccountDTOs()) {
+ // TODO : use onValidateForm method : test return block, may be
+ // a problem between failure and success
+ for (PollAccountDTO dto : selectedList.getPollAccounts()) {
if (dto.getVotingId().equals(newAccount.getVotingId())) {
createAccountForm.recordError(messages.format("accountExists",
newAccount.getVotingId()));
}
}
if (!createAccountForm.getHasErrors()) {
- newAccount.setPersonListId(selectedList.getId());
- selectedList.getPollAccountDTOs().add(newAccount);
- serviceList.updatePersonList(selectedList);
- selectedList = serviceList.findPersonListById(selectedList.getId());
+// newAccount.setPersonListId(selectedList.getId());
+// selectedList.getPollAccounts().add(newAccount);
+// serviceList.updatePersonList(selectedList);
+// selectedList = serviceList.findPersonListById(selectedList.getId());
+ serviceList.createAccountInPersonList(selectedList, account);
}
return listsZone.getBody();
}
@@ -282,16 +285,17 @@
* Méthode appelée à la suppression d'un compte.
*/
Object onActionFromDeleteAccount(String accountId) {
- Iterator<PollAccountDTO> it = selectedList.getPollAccountDTOs()
- .iterator();
- while (it.hasNext()) {
- if (accountId.equals(it.next().getId())) {
- it.remove();
- }
- }
- serviceList.updatePersonList(selectedList);
- servicePollAccount.deletePollAccount(accountId);
- selectedList = serviceList.findPersonListById(selectedList.getId());
+// Iterator<PollAccountDTO> it = selectedList.getPollAccounts()
+// .iterator();
+// while (it.hasNext()) {
+// if (accountId.equals(it.next().getId())) {
+// it.remove();
+// }
+// }
+// serviceList.updatePersonList(selectedList);
+// servicePollAccount.deletePollAccount(accountId);
+// selectedList = serviceList.findPersonListById(selectedList.getId());
+ serviceList.deleteAccountFromPersonList(selectedList, accountId);
return listsZone.getBody();
}
Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-26 17:32:17 UTC (rev 2890)
@@ -171,7 +171,8 @@
<t:if test="personListsExists">
<div>
<t:label for="listSelect" />:
- <t:select t:id="listSelect" t:model="personLists" t:encoder="personLists" t:value="personList"></t:select>
+ <t:select t:id="listSelect" t:model="personLists" t:encoder="personLists" t:value="personList"
+ t:mixins="ck/onEvent" t:event="change" t:onCompleteCallback="literal:onCompleteZoneUpdate"></t:select>
<span t:type="ck/Tooltip" title="${message:help}" value="${message:listSelect-help}" effect="appear">
<img src="${asset:context:img/help.png}" alt="${message:help}"/>
</span>
Modified: trunk/pollen-ui/src/main/webapp/user/UserLists.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-02-26 17:24:00 UTC (rev 2889)
+++ trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-02-26 17:32:17 UTC (rev 2890)
@@ -27,7 +27,7 @@
<!-- Affichage de la liste -->
- <t:grid t:source="selectedList.pollAccountDTOs" t:row="account" model="listModel"
+ <t:grid t:source="selectedList.pollAccounts" t:row="account" model="listModel"
t:rowsPerPage="10" t:pagerPosition="bottom" t:rowClass="prop:evenodd.next" t:inPlace="true">
<p:functionsCell>
<t:actionlink t:id="deleteAccount" context="account.id" t:zone="listsZone">
1
0
Author: echatellier
Date: 2010-02-26 18:24:00 +0100 (Fri, 26 Feb 2010)
New Revision: 2889
Modified:
trunk/README.txt
Log:
Bad commit of unused tomcat link
Modified: trunk/README.txt
===================================================================
--- trunk/README.txt 2010-02-26 17:19:09 UTC (rev 2888)
+++ trunk/README.txt 2010-02-26 17:24:00 UTC (rev 2889)
@@ -65,12 +65,8 @@
Pour cela, lancez pollen avec la commande suivante :
-::
-
java -jar pollen-x.x.x.war
Ensuite, ouvrez un navigateur à l'adresse : http://localhost:8080
-Vous pouvez aussi utiliser des options de lancement : http://winstone.sourceforge.net/#commandLine
-
-.. _Tomcat: http://tomcat.apache.org/
\ No newline at end of file
+Vous pouvez aussi utiliser des options de lancement : http://winstone.sourceforge.net/#commandLine
\ No newline at end of file
1
0
Author: echatellier
Date: 2010-02-26 18:19:09 +0100 (Fri, 26 Feb 2010)
New Revision: 2888
Modified:
trunk/README.txt
Log:
Ajout de la doc du mode embarqu?\195?\169 dans le README.txt ?\195?\169galement
Modified: trunk/README.txt
===================================================================
--- trunk/README.txt 2010-02-26 13:32:46 UTC (rev 2887)
+++ trunk/README.txt 2010-02-26 17:19:09 UTC (rev 2888)
@@ -56,3 +56,21 @@
(identifiant "admin", mot de passe "pollen"). Par mesure de sécurité il est
important de supprimer cet utilisateur après avoir créer un autre compte
administrateur.
+
+Conteneur embarqué
+------------------
+
+Depuis pollen-1.1.1, il est possible de le lancer avec un conteneur embarqué
+seulement en disposant du fichier war.
+
+Pour cela, lancez pollen avec la commande suivante :
+
+::
+
+ java -jar pollen-x.x.x.war
+
+Ensuite, ouvrez un navigateur à l'adresse : http://localhost:8080
+
+Vous pouvez aussi utiliser des options de lancement : http://winstone.sourceforge.net/#commandLine
+
+.. _Tomcat: http://tomcat.apache.org/
\ No newline at end of file
1
0
r2887 - in trunk: pollen-business/src/main/java/org/chorem/pollen/business pollen-business/src/main/java/org/chorem/pollen/business/dto pollen-business/src/main/java/org/chorem/pollen/business/services pollen-business/src/test/java/org/chorem/pollen/business/services pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll pollen-ui/src/main/webapp/poll
by fdesbois@users.chorem.org 26 Feb '10
by fdesbois@users.chorem.org 26 Feb '10
26 Feb '10
Author: fdesbois
Date: 2010-02-26 14:32:46 +0100 (Fri, 26 Feb 2010)
New Revision: 2887
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
Log:
- Remove method findByPollId in servicePoll --> refactor UI / business (dto update after creation)
- Add creatorName attribute in PollDTO to avoid conflict with creatorId in creation
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-02-26 13:32:46 UTC (rev 2887)
@@ -174,6 +174,7 @@
PollAccount creator = entity.getCreator();
UserAccount user = creator.getUserAccount();
dto.setCreatorId(creator.getTopiaId());
+ dto.setCreatorName(creator.getVotingId());
dto.setCreatorEmail(creator.getEmail());
if (creator.getUserAccount() != null) {
dto.setUserId(user.getTopiaId());
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java 2010-02-26 13:32:46 UTC (rev 2887)
@@ -73,10 +73,13 @@
private String userId = "";
- // Carefull, not TopiaId but pollAccount.votingId = creator name depends
- // on case : for saving, it's the votingId, for display it's the topiaId
+ /** topiaId of the creator (pollAccount) **/
private String creatorId = "";
+ /** name of the creator (pollAccount.votingId) **/
+ private String creatorName;
+
+ /** email of the creator **/
private String creatorEmail = "";
private List<CommentDTO> comments = new ArrayList<CommentDTO>();
@@ -303,6 +306,14 @@
this.creatorId = creatorId;
}
+ public String getCreatorName() {
+ return creatorName;
+ }
+
+ public void setCreatorName(String creatorName) {
+ this.creatorName = creatorName;
+ }
+
public String getCreatorEmail() {
return creatorEmail;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-02-26 13:32:46 UTC (rev 2887)
@@ -55,16 +55,6 @@
public boolean deletePoll(String pollId);
/**
- * Récupération d'un sondage à partir de son identifiant ToPIA
- *
- * @param pollId identifiant topia du sondage
- * @return le sondage
- * @deprecated use {@link #findPollByPollId } with the correct id instead
- */
- @Deprecated
- public PollDTO findPollById(String pollId);
-
- /**
* Récupération d'un sondage à partir de son identifiant.
*
* @param pollId identifiant du sondage (différent du topiaId)
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-26 13:32:46 UTC (rev 2887)
@@ -99,7 +99,8 @@
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
// Create with a new pollId generated for links
- Poll entity = pollDAO.create(PollenContext.createPollenUrlId());
+ String pollId = PollenContext.createPollenUrlId();
+ Poll entity = pollDAO.create(pollId);
PollenConverter.convert(pollDTO, entity);
// ** Manage the poll creator
@@ -136,6 +137,12 @@
}
result = entity.getTopiaId();
+
+ // Update dto : need creator and id update
+ // WARN : Update for choices, preventRules and
+ // votingLists is not needed in this case
+ PollenConverter.convert(entity, pollDTO);
+
} catch (Exception eee) {
PollenContext.doCatch(eee,
_("pollen.error.servicePoll.createPoll",
@@ -150,7 +157,7 @@
/**
* Prepare pollAccount as creator for {@code poll} save. If userId is
* defined, the pollAccount will be searched in database testing all fields
- * (user, creatorId as votingId and email). If no result is found or no
+ * (user, creatorName as votingId and email). If no result is found or no
* userId, a new pollAccount is created.
*
* @param transaction current TopiaContext
@@ -169,7 +176,7 @@
// Prepare properties for find or create
Map<String, Object> accountProperties = new HashMap<String, Object>();
accountProperties.put(PollAccount.USER_ACCOUNT, user);
- accountProperties.put(PollAccount.VOTING_ID, poll.getCreatorId());
+ accountProperties.put(PollAccount.VOTING_ID, poll.getCreatorName());
accountProperties.put(PollAccount.EMAIL, poll.getCreatorEmail());
PollAccountDAO accountDAO =
@@ -304,52 +311,7 @@
}
}
- /**
- * This method must be deleted after ui refactor in PollCreation page.
- * Only used for CreationValidation page that not need complete poll data.
- * Only main and creator params will be load in dto using
- * {@link ConverterHelper#convert(Poll, PollDTO) }
- *
- * @param id topiaId of the poll
- * @return the PollDTO corresponding
- */
@Override
- public PollDTO findPollById(String id) {
- TopiaContext transaction = null;
- PollDTO result = null;
- try {
- transaction = rootContext.beginTransaction();
-
- pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
-
- Poll pollEntity = pollDAO.findByTopiaId(id);
-
- if (pollEntity != null) {
- result = PollenConverter.convert(pollEntity, new PollDTO());
- }
-
-// if (pollEntity != null) {
-// converter.setTransaction(transaction);
-// result = converter.createPollDTO(pollEntity);
-// }
-
- //transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entity found: "
- + ((result == null) ? "null" : result.getId()));
- }
-
- return result;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- PollenContext.doFinally(transaction);
- }
- }
-
- @Override
public PollDTO findPollByPollId(String pollId) {
TopiaContext transaction = null;
PollDTO result = null;
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-02-26 13:32:46 UTC (rev 2887)
@@ -93,7 +93,7 @@
dto.setBeginChoiceDate(new Date());
dto.setBeginDate(new Date());
dto.setChoiceType(ChoiceType.TEXT);
- dto.setCreatorId("erwan");
+ dto.setCreatorName("erwan");
dto.setDescription("Test_createPoll");
dto.setEndDate(new Date());
dto.setAnonymous(false);
@@ -187,27 +187,6 @@
}
/**
- * Test of findPollById method, of class ServicePollImpl.
- */
- @Test
- public void testFindPollById() throws Exception {
- TestManager.start("testFindPollById");
- instance = new ServicePollImpl();
-
- String pollId = "";
- PollDTO dto = new PollDTO();
- dto.setDescription("Test_findPollById");
- dto.setTitle("Test_findPollById");
- dto.setAnonymous(false);
- dto.setPollType(PollType.FREE);
- dto.setChoiceType(ChoiceType.TEXT);
- dto.setVoteCounting(VoteCountingType.NORMAL);
- pollId = instance.createPoll(dto);
- PollDTO result = instance.findPollById(pollId);
- assertEquals(pollId, result.getId());
- }
-
- /**
* Test of findPollByPollId method, of class ServicePollImpl.
*/
@Test
@@ -224,7 +203,7 @@
dto.setChoiceType(ChoiceType.TEXT);
dto.setVoteCounting(VoteCountingType.NORMAL);
pollId = instance.createPoll(dto);
- String pollUID = instance.findPollById(pollId).getPollId();
+ String pollUID = dto.getPollId();
log.debug("pollUID : " + pollUID);
PollDTO result = instance.findPollByPollId(pollUID);
log.debug("title : " + result.getTitle());
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-26 13:32:46 UTC (rev 2887)
@@ -796,9 +796,11 @@
private void createPoll() {
// Création du sondage
- poll.setId(servicePoll.createPoll(poll));
+ servicePoll.createPoll(poll);
- if (poll.getId() != null) {
+ // FD-20100226 : Can't be null, an exception will be thrown if a
+ // problem comes from createPoll
+ //if (poll.getId() != null) {
// Création des images
if (poll.getChoiceType() == ChoiceType.IMAGE) {
@@ -806,13 +808,15 @@
ImageUtil.saveImages(imgTypeChoices, dir);
}
- // Mise à jour du sondage
- poll = servicePoll.findPollById(poll.getId());
+ // FD-20100226 : not necessary, the service will update
+ // automatically the poll when it was created
+ // Mise à jour du sondage :
+ //poll = servicePoll.findPollById(poll.getId());
// Mise à jour du flux Atom et envoi d'un mail de confirmation
addFeedEntry();
sendMailNotification();
- }
+ //}
}
/** Ajout d'une entrée dans le flux de syndication */
@@ -1178,7 +1182,7 @@
// Initialisation du sondage
poll = new PollDTO();
if (userExists) {
- poll.setCreatorId(user.getLogin());
+ poll.setCreatorName(user.getLogin());
poll.setCreatorEmail(user.getEmail());
}
@@ -1215,10 +1219,11 @@
poll = PollHelper.getPoll(oldPoll);
// Initialisation du créateur du sondage
- PollAccountDTO creator = servicePollAccount.findPollAccountById(oldPoll
- .getCreatorId());
- poll.setCreatorId(creator.getVotingId());
- poll.setCreatorEmail(creator.getEmail());
+// PollAccountDTO creator = servicePollAccount.findPollAccountById(oldPoll
+// .getCreatorId());
+ //poll.setCreatorId(oldPoll.getCreatorId());
+ poll.setCreatorName(oldPoll.getCreatorName());
+ poll.setCreatorEmail(oldPoll.getCreatorEmail());
// Initialisation des règles de notification
notificationPreventRule = PollHelper
Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-25 15:17:00 UTC (rev 2886)
+++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-26 13:32:46 UTC (rev 2887)
@@ -15,7 +15,7 @@
<legend>${stepLegend}</legend>
<div>
<t:label for="votingId" />
- <t:textfield t:id="votingId" t:value="poll.creatorid" t:validate="required,minlength=2"/>
+ <t:textfield t:id="votingId" t:value="poll.creatorName" t:validate="required,minlength=2"/>
</div>
<div>
<t:label for="email" />
1
0
r2886 - in trunk/pollen-business/src: main/java/org/chorem/pollen/business main/java/org/chorem/pollen/business/services test/java/org/chorem/pollen/business test/java/org/chorem/pollen/business/services
by fdesbois@users.chorem.org 25 Feb '10
by fdesbois@users.chorem.org 25 Feb '10
25 Feb '10
Author: fdesbois
Date: 2010-02-25 16:17:00 +0100 (Thu, 25 Feb 2010)
New Revision: 2886
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
Log:
- Add currentDate in PollenContext for tests
- Refactor old query to use TopiaQuery :D
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java 2010-02-25 13:13:26 UTC (rev 2885)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java 2010-02-25 15:17:00 UTC (rev 2886)
@@ -20,21 +20,20 @@
protected PollenExceptionType type;
public PollenBusinessException(PollenExceptionType type) {
- super(type.toString());
+ super(type.getMessage());
}
public enum PollenExceptionType {
LOAD_CONFIGURATION(_("pollen.exception.load_configuration"));
- private String name;
+ private String message;
- PollenExceptionType(String name) {
- this.name = name;
+ PollenExceptionType(String message) {
+ this.message = message;
}
- @Override
- public String toString() {
- return name;
+ public String getMessage() {
+ return message;
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-02-25 13:13:26 UTC (rev 2885)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-02-25 15:17:00 UTC (rev 2886)
@@ -1,11 +1,11 @@
package org.chorem.pollen.business;
+import java.util.Date;
import java.util.Properties;
import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.chorem.pollen.business.services.ServiceUserImpl;
import org.nuiton.i18n.I18n;
@@ -37,6 +37,8 @@
private static ApplicationConfig configuration;
+ private static Date currentDate;
+
/**
* Default configuration file will be loaded using
* {@link org.nuiton.util.ApplicationConfig }.
@@ -254,4 +256,15 @@
return UUID.randomUUID().toString().replaceAll("-", "");
}
+ public static void setCurrentDate(Date currentDate) {
+ PollenContext.currentDate = currentDate;
+ }
+
+ public static Date getCurrentDate() {
+ if (currentDate == null) {
+ currentDate = new Date();
+ }
+ return currentDate;
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-25 13:13:26 UTC (rev 2885)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-02-25 15:17:00 UTC (rev 2886)
@@ -17,6 +17,7 @@
package org.chorem.pollen.business.services;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -25,8 +26,6 @@
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenConverter;
import org.chorem.pollen.business.converters.DataPollConverter;
import org.chorem.pollen.business.converters.DataVotingListConverter;
@@ -58,6 +57,8 @@
import org.chorem.pollen.business.PollenContext;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
import static org.nuiton.i18n.I18n._;
/**
@@ -576,27 +577,43 @@
public List<PollDTO> findRunningPolls(boolean withEndDate) {
TopiaContext transaction = null;
List<PollDTO> results = null;
- List<Poll> pollEntities = null;
try {
transaction = rootContext.beginTransaction();
- // requête de sélection des sondages
+ PollDAO dao = PollenModelDAOHelper.getPollDAO(transaction);
+
+ String beginDate = Poll.BEGIN_DATE;
+ String endDate = Poll.END_DATE;
+ Date currentDate = PollenContext.getCurrentDate();
+
+ TopiaQuery query = dao.createQuery().
+ addNullOr(beginDate, Op.LT, currentDate);
+
if (withEndDate) {
- pollEntities = transaction
- .find("from "
- + Poll.class.getName()
- + " as poll where (poll.endDate is not null and poll.endDate > current_timestamp())"
- + " and (poll.beginDate is null or poll.beginDate < current_timestamp())");
+ query.add(endDate, Op.GT, currentDate);
} else {
- pollEntities = transaction
- .find("from "
- + Poll.class.getName()
- + " as poll where (poll.endDate is null or poll.endDate > current_timestamp())"
- + " and (poll.beginDate is null or poll.beginDate < current_timestamp())");
+ query.addNullOr(endDate, Op.GT, currentDate);
}
+ List<Poll> entities = dao.findAllByQuery(query);
+
+ // requête de sélection des sondages
+// if (withEndDate) {
+// pollEntities = transaction
+// .find("from "
+// + Poll.class.getName()
+// + " as poll where (poll.endDate is not null and poll.endDate > current_timestamp())"
+// + " and (poll.beginDate is null or poll.beginDate < current_timestamp())");
+// } else {
+// pollEntities = transaction
+// .find("from "
+// + Poll.class.getName()
+// + " as poll where (poll.endDate is null or poll.endDate > current_timestamp())"
+// + " and (poll.beginDate is null or poll.beginDate < current_timestamp())");
+// }
+
converter.setTransaction(transaction);
- results = converter.createPollDTOs(pollEntities);
+ results = converter.createPollDTOs(entities);
transaction.commitTransaction();
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-02-25 13:13:26 UTC (rev 2885)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-02-25 15:17:00 UTC (rev 2886)
@@ -3,6 +3,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,6 +45,10 @@
PollenContext.loadConfiguration(config);
PollenContext.start();
+
+ // Set currentDate to 23/02/2010 for tests
+ Calendar calendar = new GregorianCalendar(2010, 1, 23, 0, 0, 0);
+ PollenContext.setCurrentDate(calendar.getTime());
}
public static void stop() throws IOException {
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-02-25 13:13:26 UTC (rev 2885)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-02-25 15:17:00 UTC (rev 2886)
@@ -17,7 +17,6 @@
import java.io.IOException;
import java.util.ArrayList;
-import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.dto.CommentDTO;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -27,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.TestData;
import org.chorem.pollen.business.TestManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -38,7 +38,6 @@
import org.chorem.pollen.business.persistence.CommentDAO;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
-import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
@@ -48,7 +47,6 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
/**
* Tests du service de gestion des sondages.
@@ -331,7 +329,7 @@
TestManager.start("testFindRunningPolls");
instance = new ServicePollImpl();
- Date now = new Date();
+ Date now = PollenContext.getCurrentDate();
// sondage en cours sans date de fin
PollDTO poll1 = new PollDTO();
1
0