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
r2985 - in trunk: . pollen-business/src/main/xmi pollen-ui pollen-ui/src/main/java/org/chorem/pollen/ui/base pollen-ui/src/main/java/org/chorem/pollen/ui/components pollen-ui/src/main/java/org/chorem/pollen/ui/pages pollen-ui/src/main/java/org/chorem/pollen/ui/services
by fdesbois@users.chorem.org 04 May '10
by fdesbois@users.chorem.org 04 May '10
04 May '10
Author: fdesbois
Date: 2010-05-04 16:07:47 +0200 (Tue, 04 May 2010)
New Revision: 2985
Url: http://chorem.org/repositories/revision/pollen/2985
Log:
Remove authentication services, use nuiton-tapestry-extra that provides these services.
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
Modified:
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/pom.xml
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
trunk/pom.xml
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/pom.xml
===================================================================
--- trunk/pollen-ui/pom.xml 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/pom.xml 2010-05-04 14:07:47 UTC (rev 2985)
@@ -31,6 +31,10 @@
<artifactId>tapestry-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-tapestry-extra</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -4,7 +4,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.ui.components.Border;
-import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
* AbstractPollenPage
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-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -41,7 +41,7 @@
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.pages.Index;
import org.chorem.pollen.ui.services.PollenManager;
-import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -15,7 +15,7 @@
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.services.PollenManager;
-import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
/**
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -1,146 +0,0 @@
-package org.chorem.pollen.ui.services;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.runtime.Component;
-import org.apache.tapestry5.services.ComponentEventRequestParameters;
-import org.apache.tapestry5.services.ComponentRequestFilter;
-import org.apache.tapestry5.services.ComponentRequestHandler;
-import org.apache.tapestry5.services.ComponentSource;
-import org.apache.tapestry5.services.PageRenderLinkSource;
-import org.apache.tapestry5.services.PageRenderRequestParameters;
-import org.apache.tapestry5.services.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * AbstractAuthenticationFilter
- *
- * Created: 3 mai 2010
- *
- * @param <U> type of User
- * @param <A> type of Annotation that manage authentication on pages/components
- * @author fdesbois
- * $Id$
- */
-public abstract class AbstractAuthenticationFilter<U, A extends Annotation>
- implements ComponentRequestFilter {
-
- private static final Logger logger =
- LoggerFactory.getLogger(AbstractAuthenticationFilter.class);
-
- private final PageRenderLinkSource pageRender;
-
- private final ComponentSource componentSource;
-
- private final Response response;
-
- private final ServiceAuthentication<U> serviceAuthentication;
-
- protected Class<A> annotationClass;
-
- public AbstractAuthenticationFilter(PageRenderLinkSource renderLinkSource,
- ComponentSource componentSource, Response response,
- ServiceAuthentication<U> serviceAuthentication,
- Class<A> annotationClass) {
- this.pageRender = renderLinkSource;
- this.componentSource = componentSource;
- this.response = response;
- this.serviceAuthentication = serviceAuthentication;
- this.annotationClass = annotationClass;
-
- if (logger.isTraceEnabled()) {
- logger.trace("Construct");
- }
- }
-
- @Override
- public void handleComponentEvent(
- ComponentEventRequestParameters parameters,
- ComponentRequestHandler handler) throws IOException {
-
- if (logger.isTraceEnabled()) {
- logger.trace("handleComponentEvent");
- }
-
- if (redirectUnauthorizedUser(parameters.getActivePageName())) {
- return;
- }
-
- handler.handleComponentEvent(parameters);
-
- }
-
- @Override
- public void handlePageRender(PageRenderRequestParameters parameters,
- ComponentRequestHandler handler) throws IOException {
-
- if (logger.isTraceEnabled()) {
- logger.trace("handlePageRender");
- }
-
- if (redirectUnauthorizedUser(parameters.getLogicalPageName())) {
- return;
- }
-
- handler.handlePageRender(parameters);
- }
-
- protected boolean redirectUnauthorizedUser(String pageName)
- throws IOException {
-
- Component page = componentSource.getPage(pageName);
-
- if (logger.isTraceEnabled()) {
- logger.trace("Page name : " + pageName);
- logger.trace("Page class : " + page.getClass());
- logger.trace("RequiresLogin annotation : " +
- page.getClass().isAnnotationPresent(annotationClass));
- logger.trace("User in session : " +
- serviceAuthentication.isUserConnected());
- }
-
- if (!page.getClass().isAnnotationPresent(annotationClass)) {
- return false;
- }
-
- AuthenticationRedirect redirectType = AuthenticationRedirect.CONNEXION;
-
- if (serviceAuthentication.isUserConnected()) {
- U user = serviceAuthentication.getUserConnected();
- if (logger.isTraceEnabled()) {
- logger.trace("User connected : " + user);
- logger.trace("User allowed : " +
- serviceAuthentication.isAllowed(page.getClass()));
- }
-
- if (serviceAuthentication.isAllowed(page.getClass())) {
- return false;
- }
-
- redirectType = AuthenticationRedirect.NOT_ALLOWED;
- }
-
- Class<?> redirectPage = getRedirectPage(redirectType);
- Link link = pageRender.createPageRenderLinkWithContext(redirectPage,
- pageName);
-
- if (logger.isTraceEnabled()) {
- logger.trace("Redirection to " + redirectPage.getSimpleName() +
- " page...");
- }
-
- response.sendRedirect(link);
-
- return true;
- }
-
- protected enum AuthenticationRedirect {
- CONNEXION, NOT_ALLOWED;
- }
-
- protected abstract Class<?> getRedirectPage(
- AuthenticationRedirect redirectType);
-}
-
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -41,6 +41,7 @@
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.service.ServiceUserImpl;
import org.chorem.pollen.ui.data.PollUri;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -8,7 +8,8 @@
import org.chorem.pollen.ui.data.RequiresAuthentication;
import org.chorem.pollen.ui.pages.Connexion;
import org.chorem.pollen.ui.pages.ErrorPage;
-import org.chorem.pollen.ui.services.AbstractAuthenticationFilter.AuthenticationRedirect;
+import org.nuiton.web.tapestry5.services.AbstractAuthenticationFilter;
+import org.nuiton.web.tapestry5.services.ServiceAuthentication;
/**
* AuthenticationFilter
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -1,27 +0,0 @@
-
-package org.chorem.pollen.ui.services;
-
-import org.chorem.pollen.entity.UserAccount;
-
-/**
- * ServiceAuthentication
- *
- * Created: 3 mai 2010
- *
- * @param <U> user type
- * @author fdesbois
- * $Id$
- */
-public interface ServiceAuthentication<U> {
-
- boolean isUserConnected();
-
- U getUserConnected();
-
- void setUserConnected(U user);
-
- boolean isAllowed(Class<?> page);
-
- U getNewUserInstance();
-
-}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -1,71 +0,0 @@
-
-package org.chorem.pollen.ui.services;
-
-import java.lang.annotation.Annotation;
-import org.apache.tapestry5.services.ApplicationStateManager;
-
-/**
- * ServiceAuthenticationImpl
- *
- * Created: 3 mai 2010
- *
- * @param <U>
- * @param <A>
- * @author fdesbois
- * $Id$
- */
-public abstract class ServiceAuthenticationAbstract<U, A extends Annotation>
- implements ServiceAuthentication<U> {
-
- private final ApplicationStateManager stateManager;
-
- private Class<U> userClass;
-
- private Class<A> annotationClass;
-
- public ServiceAuthenticationAbstract(ApplicationStateManager stateManager,
- Class<U> userClass, Class<A> annotationClass) {
- this.stateManager = stateManager;
- this.userClass = userClass;
- this.annotationClass = annotationClass;
- }
-
- @Override
- public boolean isUserConnected() {
- return stateManager.exists(userClass);
- }
-
- @Override
- public U getUserConnected() {
- return stateManager.getIfExists(userClass);
- }
-
- @Override
- public void setUserConnected(U user) {
- stateManager.set(userClass, user);
- }
-
- @Override
- public boolean isAllowed(Class<?> page) {
- if (page.isAnnotationPresent(annotationClass) &&
- isUserConnected()) {
-
- A check = page.getAnnotation(annotationClass);
-
- U user = getUserConnected();
-
- return checkAuthorizations(user, check);
-
- // Check if user not admin is allowed
-// if (!user.getAdmin() && check.adminOnly()) {
-// return false;
-// }
-// return false;
- }
- // No restriction if annotation is not present
- return true;
- }
-
- protected abstract boolean checkAuthorizations(U user, A annotation);
-
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 14:07:47 UTC (rev 2985)
@@ -5,6 +5,7 @@
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountImpl;
import org.chorem.pollen.ui.data.RequiresAuthentication;
+import org.nuiton.web.tapestry5.services.ServiceAuthenticationAbstract;
/**
* ServiceAuthenticationImpl
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-05-04 13:22:03 UTC (rev 2984)
+++ trunk/pom.xml 2010-05-04 14:07:47 UTC (rev 2985)
@@ -84,6 +84,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-tapestry-extra</artifactId>
+ <version>${nuiton-web.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.10</version>
@@ -313,6 +318,7 @@
<eugene.version>2.0.2-SNAPSHOT</eugene.version>
<i18n.version>1.2.2</i18n.version>
<tapestry.version>5.1.0.5</tapestry.version>
+ <nuiton-web.version>0.1-SNAPSHOT</nuiton-web.version>
<nuiton-utils.version>1.2.2</nuiton-utils.version>
<processor.version>1.0.2</processor.version>
1
0
r2984 - trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services
by fdesbois@users.chorem.org 04 May '10
by fdesbois@users.chorem.org 04 May '10
04 May '10
Author: fdesbois
Date: 2010-05-04 15:22:03 +0200 (Tue, 04 May 2010)
New Revision: 2984
Url: http://chorem.org/repositories/revision/pollen/2984
Log:
rename main method for redirection if user is not allowed (or not authenticated)
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 10:11:20 UTC (rev 2983)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 13:22:03 UTC (rev 2984)
@@ -11,15 +11,11 @@
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.PageRenderRequestParameters;
import org.apache.tapestry5.services.Response;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.ui.data.RequiresAuthentication;
-import org.chorem.pollen.ui.pages.Connexion;
-import org.chorem.pollen.ui.pages.ErrorPage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * RequiresAuthenticationFilter
+ * AbstractAuthenticationFilter
*
* Created: 3 mai 2010
*
@@ -68,7 +64,7 @@
logger.trace("handleComponentEvent");
}
- if (dispatchedToLoginPage(parameters.getActivePageName())) {
+ if (redirectUnauthorizedUser(parameters.getActivePageName())) {
return;
}
@@ -84,14 +80,15 @@
logger.trace("handlePageRender");
}
- if (dispatchedToLoginPage(parameters.getLogicalPageName())) {
+ if (redirectUnauthorizedUser(parameters.getLogicalPageName())) {
return;
}
handler.handlePageRender(parameters);
}
- private boolean dispatchedToLoginPage(String pageName) throws IOException {
+ protected boolean redirectUnauthorizedUser(String pageName)
+ throws IOException {
Component page = componentSource.getPage(pageName);
@@ -108,7 +105,6 @@
return false;
}
-// Class<?> redirectPage = Connexion.class;
AuthenticationRedirect redirectType = AuthenticationRedirect.CONNEXION;
if (serviceAuthentication.isUserConnected()) {
@@ -123,7 +119,6 @@
return false;
}
-// redirectPage = ErrorPage.class;
redirectType = AuthenticationRedirect.NOT_ALLOWED;
}
1
0
Author: fdesbois
Date: 2010-05-04 12:11:20 +0200 (Tue, 04 May 2010)
New Revision: 2983
Url: http://chorem.org/repositories/revision/pollen/2983
Log:
- Add license descriptor
- Evo #191 : use AuthenticationFilter and ServiceAuthentication to manage connected user authorizations
- need Javadoc + these classes can be put into nuiton-tapestry-extra (AbstratMappedGridDataSource, ServiceAuthentication, ServiceAuthenticationAbstract, AbstractAuthenticationFilter)
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
trunk/pollen-ui/src/main/webapp/Connexion.tml
trunk/src/license/
trunk/src/license/project.xml
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties
trunk/pollen-ui/src/main/webapp/css/loginComponent.css
Modified:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
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/UserProfile.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml
trunk/pollen-ui/src/main/webapp/ErrorPage.tml
trunk/pollen-ui/src/main/webapp/css/main.css
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,10 +1,10 @@
package org.chorem.pollen.ui.base;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.ui.components.Border;
+import org.chorem.pollen.ui.services.ServiceAuthentication;
/**
* AbstractPollenPage
@@ -16,13 +16,9 @@
public abstract class AbstractPollenPage implements PollenPage {
/** Connected UserAccount from Session **/
- @SessionState
- @Property
- private UserAccount user;
+ @Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
- @Property
- private boolean userExists;
-
/**
* Retrieve the border layout of the page.
*
@@ -31,38 +27,13 @@
public abstract Border getBorder();
/**
- * Default value set to false for needAuthentification.
- *
- * @return false
- * @see PollenPage#isNeedAuthentification()
- */
- @Override
- public boolean isNeedAuthentification() {
- return false;
- }
-
- /**
- * Default value set to true for canDisplayPage.
- *
- * @return true
- * @see PollenPage#canDisplayPage()
- */
- @Override
- public boolean canDisplayPage() {
- return true;
- }
-
- /**
* Retrieve the connected user from Session.
*
* @return the UserAccount corresponding to connected user
*/
@Override
public UserAccount getUserConnected() {
- if (isUserConnected()) {
- return user;
- }
- return null;
+ return serviceAuthentication.getUserConnected();
}
/**
@@ -71,7 +42,7 @@
* @param user to set in session.
*/
public void setUserConnected(UserAccount user) {
- this.user = user;
+ serviceAuthentication.setUserConnected(user);
}
/**
@@ -81,7 +52,7 @@
*/
@Override
public boolean isUserConnected() {
- return userExists;
+ return serviceAuthentication.isUserConnected();
}
/**
@@ -91,7 +62,7 @@
*/
@Override
public boolean isAdminConnected() {
- return isUserConnected() && user.getAdmin();
+ return isUserConnected() && getUserConnected().getAdmin();
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -13,20 +13,6 @@
public interface PollenPage {
/**
- * Return true if the page need an authentification to be displayed.
- *
- * @return true for authentification needed
- */
- boolean isNeedAuthentification();
-
- /**
- * Return true if the page can be displayed, depends on user rights.
- *
- * @return true for display allowed
- */
- boolean canDisplayPage();
-
- /**
* Retrieve connected user from session.
*
* @return the user currently connected.
@@ -52,7 +38,7 @@
*
* @param message to display
*/
- public void addInfo(String message) ;
+ public void addInfo(String message);
/**
* Add a fatal {@code message} to display. Only the fatal {@code message}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -23,14 +23,11 @@
import java.util.Locale;
import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.InjectContainer;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.PersistentLocale;
@@ -41,10 +38,10 @@
import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.service.ServiceUser;
-import org.chorem.pollen.ui.base.PollenPage;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.pages.Index;
import org.chorem.pollen.ui.services.PollenManager;
+import org.chorem.pollen.ui.services.ServiceAuthentication;
import org.slf4j.Logger;
/**
@@ -127,20 +124,7 @@
@Property
private String password;
- /**
- * Objet de session représentant l'utilisateur identifié
- */
- @SessionState
- @Property
- private UserAccount user;
- /**
- * vrai si l'utilisateur s'est identifié, faux sinon
- */
- @SuppressWarnings("unused")
- @Property
- private boolean userExists;
-
/** Locale courante */
@Inject
private Locale currentLocale;
@@ -151,11 +135,14 @@
@Inject
private PersistentLocale localeService;
+ /** Injection des services */
@Inject
private PollenManager manager;
- /** Injection des services */
@Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
+
+ @Inject
private ServiceUser serviceUser;
/**
@@ -173,19 +160,8 @@
@InjectComponent
private ContextLink feedContext;
- @InjectContainer
- private PollenPage page;
-
- @Inject
- private Block loginBlock;
-
- @Inject
- private Block pageBlock;
-
private boolean fatal;
- private boolean needAuthentification;
-
private String serverPath;
/**
@@ -201,19 +177,12 @@
} else {
logo = "pollen" + pageLogo + "_en.png";
}
-
- // Error messages for display authorization
- if (isNeedAuthentification()) {
- addError(messages.get("pollen.ui.user.display.notConnected"));
- } else if (!page.canDisplayPage()) {
- addError(messages.get("pollen.ui.user.display.notAllowed"));
- }
}
boolean afterRender() {
- if (needAuthentification) {
- return false;
- }
+// if (needAuthentification) {
+// return false;
+// }
// Check if fatal errors has been added to the border
// Reload the page if feedBack hasn't been reloaded yet to display
@@ -231,14 +200,14 @@
return true;
}
- public Object getActiveBlock() {
- if (isNeedAuthentification()) {
- return loginBlock;
- } else if (canDisplayBody()) {
- return pageBlock;
- }
- return null;
- }
+// public Object getActiveBlock() {
+// if (isNeedAuthentification()) {
+// return loginBlock;
+// } else if (canDisplayBody()) {
+// return pageBlock;
+// }
+// return null;
+// }
public String getServerPath() {
if (serverPath == null) {
@@ -264,12 +233,12 @@
fatal = true;
}
- public boolean isNeedAuthentification() {
- return !userExists && page.isNeedAuthentification();
- }
+// public boolean isNeedAuthentification() {
+// return !userExists && page.isNeedAuthentification();
+// }
public boolean canDisplayBody() {
- return !fatal && page.canDisplayPage();
+ return !fatal/* && page.canDisplayPage()*/;
}
public DateFormat getDateFormat() {
@@ -281,6 +250,14 @@
return feedContext;
}
+ public boolean isUserExists() {
+ return serviceAuthentication.isUserConnected();
+ }
+
+ public UserAccount getUser() {
+ return serviceAuthentication.getUserConnected();
+ }
+
/**
* User connection. Call business to check user existence.
*
@@ -289,10 +266,10 @@
@Log
Object onSuccessFromConnection() {
// No need to connect if user exists
- if (!userExists) {
+ if (!serviceAuthentication.isUserConnected()) {
try {
UserAccount current = serviceUser.connect(login, password);
- user = current;
+ serviceAuthentication.setUserConnected(current);
// Change locale for user
//localeService.set(new Locale(user.getLanguage()));
feedback.addInfo(messages.get("loginOk"));
@@ -311,7 +288,7 @@
* @return la zone à mettre à jour
*/
Object onActionFromLogout() {
- user = null;
+ serviceAuthentication.setUserConnected(null);
request.getSession(false).invalidate();
return Index.class;
}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,97 +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.components;
-
-import org.apache.tapestry5.annotations.Component;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.chorem.pollen.PollenBusinessException;
-import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.service.ServiceUser;
-import org.chorem.pollen.ui.services.PollenManager;
-
-/**
- * Formulaire d'identification. Formulaire que l'utilisateur doit remplir pour
- * se connecter quand il veut accéder à une page qui demande à être identifié.
- *
- * @author kmorin
- * @version $Id$
- */
-@IncludeStylesheet("context:css/loginComponent.css")
-public class LoginComponent {
-
- /** Affichage des messages pour l'utilisateur */
- @Component(id = "loginCompFeedback")
- private FeedBack feedback;
-
- /**
- * Objet de session représentant l'utilisateur identifié.
- */
- @SuppressWarnings("unused")
- @SessionState
- private UserAccount user;
- @SuppressWarnings("unused")
- @Property
- private boolean userExists;
-
- /**
- * Champ login du formulaire d'identification
- */
- @Property
- private String connectionLogin;
-
- /**
- * Champ password du formulaire d'identification
- */
- @Property
- private String connectionPassword;
-
- @Inject
- private Messages messages;
-
- /** Injection des services */
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private PollenManager manager;
-
- /**
- * Methode appelée lorsque l'utilisateur s'identifie
- *
- * @return la zone à mettre à jour
- */
- Object onSuccessFromLoginCompForm() {
- // Récupération de l'utilisateur identifié
- UserAccount current;
- try {
- current = serviceUser.connect(connectionLogin, connectionPassword);
- if (current != null) {
- user = current;
- } else {
- feedback.addError(messages.get("loginFailed"));
- }
- } catch (PollenBusinessException eee) {
- // TODO
- feedback.addError(messages.get("loginFailed"));
- }
- return this;
- }
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -16,18 +16,19 @@
import org.slf4j.LoggerFactory;
/**
- * ContactDataSource
+ * AbstractMappedGridDataSource
*
+ * TODO : javadoc
+ *
* Created: 18 janv. 2010
*
* @param <K> Type of the map key
* @param <E> Type of the map value
* @author fdesbois <fdesbois(a)codelutin.com>
*/
-public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity>
+public abstract class AbstractMappedGridDataSource<K, E>
implements GridDataSource {
-
private Logger log =
LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
@@ -40,15 +41,19 @@
private int nbRowsPerPage;
@Override
+ public abstract Class<?> getRowType();
+
+ protected abstract int count();
+
+ protected abstract Map<K, E> execute(int startIndex, int endIndex,
+ SortConstraint orderBy);
+
+ @Override
public int getAvailableRows() {
if (nbRows < 0) {
- try {
- nbRows = count();
- if (log.isDebugEnabled()) {
- log.debug("Count : " + nbRows);
- }
- } catch (PollenException eee) {
- throw new TapestryException("", eee);
+ nbRows = count();
+ if (log.isDebugEnabled()) {
+ log.debug("Count : " + nbRows);
}
}
return nbRows;
@@ -61,24 +66,39 @@
log.debug("Prepare results : " + startIndex + ", " + endIndex);
}
nbRowsPerPage = endIndex - startIndex + 1;
- try {
- mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints));
- listResults = new ArrayList<E>(mapResults.values());
- } catch (PollenException eee) {
- throw new TapestryException("", eee);
+ mapResults = execute(startIndex, endIndex,
+ getSortConstraint(sortConstraints));
+ listResults = new ArrayList<E>(mapResults.values());
+ }
+
+ @Override
+ public Object getRowValue(int index) {
+ index = index % nbRowsPerPage;
+ if (index >= listResults.size()) {
+ if (log.isErrorEnabled()) {
+ log.error("Size error : " + index + " / " + listResults.size());
+ }
+ return null;
}
+ return CollectionUtils.get(listResults, index);
}
- protected abstract Map<K, E> execute(int startIndex, int endIndex,
- SortConstraint orderBy) throws PollenException;
+ public E get(K key) {
+ return mapResults.get(key);
+ }
- protected abstract int count() throws PollenException;
+ public List<E> values() {
+ return listResults;
+ }
- protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) {
- for (SortConstraint constraint : sortConstraints)
- {
- final ColumnSort sort = constraint.getColumnSort();
+ public boolean contains(K key) {
+ return mapResults.containsKey(key);
+ }
+ protected SortConstraint getSortConstraint(
+ List<SortConstraint> sortConstraints) {
+ for (SortConstraint constraint : sortConstraints) {
+ final ColumnSort sort = constraint.getColumnSort();
if (sort != ColumnSort.UNSORTED) {
return constraint;
}
@@ -104,31 +124,4 @@
return filterOrder;
}
- @Override
- public Object getRowValue(int index) {
- index = index % nbRowsPerPage;
- if (index >= listResults.size()) {
- if (log.isErrorEnabled()) {
- log.error("Size error : " + index + " / " + listResults.size());
- }
- return null;
- }
- return CollectionUtils.get(listResults, index);
- }
-
- @Override
- public abstract Class<?> getRowType();
-
- public E get(K key) {
- return mapResults.get(key);
- }
-
- public List<E> values() {
- return listResults;
- }
-
- public boolean contains(K key) {
- return mapResults.containsKey(key);
- }
-
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,25 @@
+
+package org.chorem.pollen.ui.data;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used on pages and components that need authentication
+ * to be rendered.
+ *
+ * Created: 3 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+@Target( { ElementType.TYPE })
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface RequiresAuthentication {
+
+ boolean adminOnly() default false;
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/RequiresAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,127 @@
+
+package org.chorem.pollen.ui.pages;
+
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.ui.base.AbstractPollenPage;
+import org.chorem.pollen.ui.components.Border;
+import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.chorem.pollen.ui.services.ServiceAuthentication;
+import org.slf4j.Logger;
+
+/**
+ * Connexion
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class Connexion extends AbstractPollenPage {
+
+ @InjectComponent
+ private Border border;
+
+ @Override
+ public Border getBorder() {
+ return border;
+ }
+
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar();
+ }
+
+ @InjectComponent
+ private Form loginForm;
+
+ /**
+ * Champ login du formulaire d'identification
+ */
+ @Property
+ private String connectionLogin;
+
+ /**
+ * Champ password du formulaire d'identification
+ */
+ @Property
+ private String connectionPassword;
+
+ /** Injection des services */
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private ServiceAuthentication<UserAccount> serviceAuthentication;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private PollenManager manager;
+
+ @Inject
+ private PageRenderLinkSource pageRender;
+
+ private String pageName;
+
+ void onActivate(String pageName) {
+ this.pageName = pageName;
+ }
+
+ String onPassivate() {
+ return pageName;
+ }
+
+ void setupRender() {
+ addError(messages.format("pollen.ui.user.display.notConnected",
+ pageName));
+ }
+
+ void onValidateFormFromLoginForm() {
+ UserAccount current;
+ try {
+ current = serviceUser.connect(connectionLogin, connectionPassword);
+ if (current != null) {
+ serviceAuthentication.setUserConnected(current);
+ } else {
+ loginForm.recordError(messages.get("loginFailed"));
+ }
+ } catch (PollenBusinessException eee) {
+ // TODO two different errors, on password or on login
+ //addError(messages.get("loginFailed"));
+ String message = manager.getErrorMessage(eee, messages, logger);
+ loginForm.recordError(message);
+ }
+ }
+
+ /**
+ * Methode appelée lorsque l'utilisateur s'identifie
+ *
+ * @return la zone à mettre à jour
+ */
+ @Log
+ Object onSuccessFromLoginForm() {
+ if (pageName == null) {
+ pageName = "index";
+ }
+ return pageRender.createPageRenderLink(pageName);
+ }
+
+ @Log
+ void onFailureFromLoginForm() {
+
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/Connexion.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -2,6 +2,8 @@
package org.chorem.pollen.ui.pages;
import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
@@ -23,13 +25,33 @@
@InjectComponent
private Border border;
+ @Inject
+ private Messages messages;
+
+ private String pageName;
+
@Override
public Border getBorder() {
return border;
}
- public AddressBarItem[] getAddress() {
- return AddressBar.newBar().getItems();
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar();
}
+
+ void onActivate(String pageName) {
+ this.pageName = pageName;
+ }
+
+ String onPassivate() {
+ return pageName;
+ }
+
+ void setupRender() {
+ if (pageName != null) {
+ addError(messages.format("pollen.ui.user.display.notAllowed",
+ pageName));
+ }
+ }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/AdminUsers.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -39,6 +39,7 @@
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
import org.chorem.pollen.ui.data.UserAccountDataSource;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -49,6 +50,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
+@RequiresAuthentication(adminOnly = true)
@IncludeStylesheet("context:css/usersAdmin.css")
public class AdminUsers extends AbstractPollenPage {
@@ -66,16 +68,6 @@
return border;
}
- @Override
- public boolean isNeedAuthentification() {
- return true;
- }
-
- @Override
- public boolean canDisplayPage() {
- return isAdminConnected();
- }
-
public AddressBar getAddressBar() {
return AddressBar.newBar().appendCurrent(title);
}
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-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -29,6 +29,7 @@
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
/**
* Classe de la page d'affichage des listes de votants favorites de
@@ -39,6 +40,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
+@RequiresAuthentication
@IncludeStylesheet("context:css/lists.css")
public class UserLists extends AbstractPollenPage {
@@ -60,16 +62,6 @@
public Border getBorder() {
return border;
}
-
- @Override
- public boolean isNeedAuthentification() {
- return true;
- }
-
- @Override
- public boolean canDisplayPage() {
- return isUserConnected();
- }
public AddressBar getAddressBar() {
return AddressBar.newBar().appendCurrent(title);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserProfile.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -38,6 +38,7 @@
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
import org.chorem.pollen.ui.services.PollenManager;
import org.slf4j.Logger;
@@ -48,6 +49,7 @@
* @author rannou
* @version $Id$
*/
+@RequiresAuthentication
@IncludeStylesheet("context:css/account.css")
public class UserProfile extends AbstractPollenPage {
@@ -59,16 +61,6 @@
return border;
}
- @Override
- public boolean isNeedAuthentification() {
- return true;
- }
-
- @Override
- public boolean canDisplayPage() {
- return isUserConnected();
- }
-
@Inject
private Logger logger;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserRegister.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -16,8 +16,6 @@
package org.chorem.pollen.ui.pages.user;
-
-import java.util.Locale;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.Component;
@@ -61,18 +59,13 @@
public Border getBorder() {
return border;
}
+//
+// @Override
+// public boolean canDisplayPage() {
+// addInfo("Vous devez vous déconnecter pour créer un compte");
+// return !isUserConnected();
+// }
- @Override
- public boolean isNeedAuthentification() {
- return false;
- }
-
- @Override
- public boolean canDisplayPage() {
- addInfo("Vous devez vous déconnecter pour créer un compte");
- return !isUserConnected();
- }
-
@Inject
private Logger logger;
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,151 @@
+package org.chorem.pollen.ui.services;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.runtime.Component;
+import org.apache.tapestry5.services.ComponentEventRequestParameters;
+import org.apache.tapestry5.services.ComponentRequestFilter;
+import org.apache.tapestry5.services.ComponentRequestHandler;
+import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.apache.tapestry5.services.PageRenderRequestParameters;
+import org.apache.tapestry5.services.Response;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
+import org.chorem.pollen.ui.pages.Connexion;
+import org.chorem.pollen.ui.pages.ErrorPage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * RequiresAuthenticationFilter
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> type of User
+ * @param <A> type of Annotation that manage authentication on pages/components
+ * @author fdesbois
+ * $Id$
+ */
+public abstract class AbstractAuthenticationFilter<U, A extends Annotation>
+ implements ComponentRequestFilter {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(AbstractAuthenticationFilter.class);
+
+ private final PageRenderLinkSource pageRender;
+
+ private final ComponentSource componentSource;
+
+ private final Response response;
+
+ private final ServiceAuthentication<U> serviceAuthentication;
+
+ protected Class<A> annotationClass;
+
+ public AbstractAuthenticationFilter(PageRenderLinkSource renderLinkSource,
+ ComponentSource componentSource, Response response,
+ ServiceAuthentication<U> serviceAuthentication,
+ Class<A> annotationClass) {
+ this.pageRender = renderLinkSource;
+ this.componentSource = componentSource;
+ this.response = response;
+ this.serviceAuthentication = serviceAuthentication;
+ this.annotationClass = annotationClass;
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Construct");
+ }
+ }
+
+ @Override
+ public void handleComponentEvent(
+ ComponentEventRequestParameters parameters,
+ ComponentRequestHandler handler) throws IOException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("handleComponentEvent");
+ }
+
+ if (dispatchedToLoginPage(parameters.getActivePageName())) {
+ return;
+ }
+
+ handler.handleComponentEvent(parameters);
+
+ }
+
+ @Override
+ public void handlePageRender(PageRenderRequestParameters parameters,
+ ComponentRequestHandler handler) throws IOException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("handlePageRender");
+ }
+
+ if (dispatchedToLoginPage(parameters.getLogicalPageName())) {
+ return;
+ }
+
+ handler.handlePageRender(parameters);
+ }
+
+ private boolean dispatchedToLoginPage(String pageName) throws IOException {
+
+ Component page = componentSource.getPage(pageName);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Page name : " + pageName);
+ logger.trace("Page class : " + page.getClass());
+ logger.trace("RequiresLogin annotation : " +
+ page.getClass().isAnnotationPresent(annotationClass));
+ logger.trace("User in session : " +
+ serviceAuthentication.isUserConnected());
+ }
+
+ if (!page.getClass().isAnnotationPresent(annotationClass)) {
+ return false;
+ }
+
+// Class<?> redirectPage = Connexion.class;
+ AuthenticationRedirect redirectType = AuthenticationRedirect.CONNEXION;
+
+ if (serviceAuthentication.isUserConnected()) {
+ U user = serviceAuthentication.getUserConnected();
+ if (logger.isTraceEnabled()) {
+ logger.trace("User connected : " + user);
+ logger.trace("User allowed : " +
+ serviceAuthentication.isAllowed(page.getClass()));
+ }
+
+ if (serviceAuthentication.isAllowed(page.getClass())) {
+ return false;
+ }
+
+// redirectPage = ErrorPage.class;
+ redirectType = AuthenticationRedirect.NOT_ALLOWED;
+ }
+
+ Class<?> redirectPage = getRedirectPage(redirectType);
+ Link link = pageRender.createPageRenderLinkWithContext(redirectPage,
+ pageName);
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Redirection to " + redirectPage.getSimpleName() +
+ " page...");
+ }
+
+ response.sendRedirect(link);
+
+ return true;
+ }
+
+ protected enum AuthenticationRedirect {
+ CONNEXION, NOT_ALLOWED;
+ }
+
+ protected abstract Class<?> getRedirectPage(
+ AuthenticationRedirect redirectType);
+}
+
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AbstractAuthenticationFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -27,8 +27,10 @@
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.services.ApplicationStateContribution;
import org.apache.tapestry5.services.ApplicationStateCreator;
+import org.apache.tapestry5.services.ApplicationStateManager;
import org.apache.tapestry5.services.BindingFactory;
import org.apache.tapestry5.services.BindingSource;
+import org.apache.tapestry5.services.ComponentRequestFilter;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.entity.UserAccount;
@@ -88,6 +90,13 @@
return new ServiceImageImpl(manager.getContext());
}
+ public ServiceAuthentication<UserAccount> buildServiceAuthentication(
+ ApplicationStateManager stateManager) {
+ ServiceAuthentication<UserAccount> instance =
+ new ServiceAuthenticationImpl(stateManager);
+ return instance;
+ }
+
/**
* Execute PollenManager when registry startup.
* The manager will be instantiated using
@@ -207,10 +216,11 @@
* Used to instanciate SessionState UserAccount when session expires.
*
* @param configuration to add the ApplicationStateCreator.
- * @param serviceUser to instantiate user
+ * @param serviceAuthentication to instantiate user
*/
- public void contributeApplicationStateManager(MappedConfiguration<Class<?>, ApplicationStateContribution> configuration,
- final ServiceUser serviceUser) {
+ public void contributeApplicationStateManager(MappedConfiguration<Class<?>,
+ ApplicationStateContribution> configuration,
+ final ServiceAuthentication<UserAccount> serviceAuthentication) {
if (logger.isInfoEnabled()) {
logger.info("Execute contributeApplicationStateManager");
}
@@ -220,7 +230,7 @@
@Override
public UserAccount create() {
- return serviceUser.getNewUser();
+ return serviceAuthentication.getNewUserInstance();
}
};
@@ -228,6 +238,22 @@
new ApplicationStateContribution("session", creator));
}
+ /**
+ * Contribution to ComponentRequestHandler service. The
+ * {@link AuthenticationFilter} is added to the configuration of
+ * the service to provide authentication managment on user connected.
+ *
+ * @param configuration of ComponentRequestHandler
+ * @see ServiceAuthentication
+ * @see AuthenticationFilter
+ * @see ComponentRequestFilter
+ */
+ public static void contributeComponentRequestHandler(
+ OrderedConfiguration<ComponentRequestFilter> configuration) {
+ configuration.addInstance("RequiresAuthentication",
+ AuthenticationFilter.class);
+ }
+
public static void contributeBindingSource(
MappedConfiguration<String, BindingFactory> configuration,
BindingSource bindingSource) {
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,42 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.services.ComponentSource;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+import org.apache.tapestry5.services.Response;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
+import org.chorem.pollen.ui.pages.Connexion;
+import org.chorem.pollen.ui.pages.ErrorPage;
+import org.chorem.pollen.ui.services.AbstractAuthenticationFilter.AuthenticationRedirect;
+
+/**
+ * AuthenticationFilter
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class AuthenticationFilter extends
+ AbstractAuthenticationFilter<UserAccount, RequiresAuthentication>{
+
+ public AuthenticationFilter(PageRenderLinkSource renderLinkSource,
+ ComponentSource componentSource, Response response,
+ ServiceAuthentication<UserAccount> serviceAuthentication) {
+ super(renderLinkSource, componentSource, response,
+ serviceAuthentication, RequiresAuthentication.class);
+ }
+
+ @Override
+ protected Class<?> getRedirectPage(AuthenticationRedirect redirectType) {
+ switch (redirectType) {
+ case CONNEXION:
+ return Connexion.class;
+ case NOT_ALLOWED:
+ return ErrorPage.class;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AuthenticationFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,27 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.chorem.pollen.entity.UserAccount;
+
+/**
+ * ServiceAuthentication
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U> user type
+ * @author fdesbois
+ * $Id$
+ */
+public interface ServiceAuthentication<U> {
+
+ boolean isUserConnected();
+
+ U getUserConnected();
+
+ void setUserConnected(U user);
+
+ boolean isAllowed(Class<?> page);
+
+ U getNewUserInstance();
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthentication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,71 @@
+
+package org.chorem.pollen.ui.services;
+
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.services.ApplicationStateManager;
+
+/**
+ * ServiceAuthenticationImpl
+ *
+ * Created: 3 mai 2010
+ *
+ * @param <U>
+ * @param <A>
+ * @author fdesbois
+ * $Id$
+ */
+public abstract class ServiceAuthenticationAbstract<U, A extends Annotation>
+ implements ServiceAuthentication<U> {
+
+ private final ApplicationStateManager stateManager;
+
+ private Class<U> userClass;
+
+ private Class<A> annotationClass;
+
+ public ServiceAuthenticationAbstract(ApplicationStateManager stateManager,
+ Class<U> userClass, Class<A> annotationClass) {
+ this.stateManager = stateManager;
+ this.userClass = userClass;
+ this.annotationClass = annotationClass;
+ }
+
+ @Override
+ public boolean isUserConnected() {
+ return stateManager.exists(userClass);
+ }
+
+ @Override
+ public U getUserConnected() {
+ return stateManager.getIfExists(userClass);
+ }
+
+ @Override
+ public void setUserConnected(U user) {
+ stateManager.set(userClass, user);
+ }
+
+ @Override
+ public boolean isAllowed(Class<?> page) {
+ if (page.isAnnotationPresent(annotationClass) &&
+ isUserConnected()) {
+
+ A check = page.getAnnotation(annotationClass);
+
+ U user = getUserConnected();
+
+ return checkAuthorizations(user, check);
+
+ // Check if user not admin is allowed
+// if (!user.getAdmin() && check.adminOnly()) {
+// return false;
+// }
+// return false;
+ }
+ // No restriction if annotation is not present
+ return true;
+ }
+
+ protected abstract boolean checkAuthorizations(U user, A annotation);
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationAbstract.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,36 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.services.ApplicationStateManager;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.UserAccountImpl;
+import org.chorem.pollen.ui.data.RequiresAuthentication;
+
+/**
+ * ServiceAuthenticationImpl
+ *
+ * Created: 4 mai 2010
+ *
+ * @author fdesbois
+ * $Id$
+ */
+public class ServiceAuthenticationImpl extends
+ ServiceAuthenticationAbstract<UserAccount, RequiresAuthentication> {
+
+ public ServiceAuthenticationImpl(ApplicationStateManager stateManager) {
+ super(stateManager, UserAccount.class, RequiresAuthentication.class);
+ }
+
+ @Override
+ protected boolean checkAuthorizations(UserAccount user,
+ RequiresAuthentication annotation) {
+ // No problem for an admin or if the annotation has no limitation
+ return user.getAdmin() || !annotation.adminOnly();
+ }
+
+ @Override
+ public UserAccount getNewUserInstance() {
+ return new UserAccountImpl();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceAuthenticationImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-05-04 10:11:20 UTC (rev 2983)
@@ -17,8 +17,8 @@
pollen.ui.user.register.sendEmail=Un email vous a \u00E9t\u00E9 envoy\u00E9 \u00E0 l'adresse %1$s.
pollen.ui.user.validate.passwords=Les deux mots de passe ne correspondent pas.
pollen.ui.user.update.success=Modification enregistr\u00E9e avec succ\u00E8s.
-pollen.ui.user.display.notConnected=Vous devez vous connecter pour acc\u00E9der \u00E0 cette page.
-pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00E9cessaires pour acc\u00E9der \u00E0 cette page.
+pollen.ui.user.display.notConnected=Vous devez vous connecter pour acc\u00E9der \u00E0 la page %1$s.
+pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00E9cessaires pour acc\u00E9der \u00E0 la page %1$s.
pollen.ui.user.create.title=Cr\u00E9er un nouvel utilisateur
pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9.
pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le m\u00EAme que son identifiant.
@@ -38,6 +38,15 @@
pollen.ui.list.update.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
pollen.ui.list.update.addParticipant=Ajouter un nouvel utilisateur \u00E0 la liste
+# OLD LOGIN_COMPONENT
+connectionLegend=Connexion
+loginSubmit=Me connecter
+loginComp-label=Identifiant
+loginComp-required-message=Vous devez entrer votre identifiant.
+passwordComp-label=Mot de passe
+passwordComp-required-message=Vous devez entrer votre mot de passe.
+loginFailed=Mauvais identifiant ou mot de passe.
+
# FORM:: user
firstName-label=Pr\u00E9nom
lastName-label=Nom
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-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -159,21 +159,7 @@
<t:feedback t:id="errorJs" />
</noscript>
<t:feedback t:id="borderFeedback" t:autoClear="false"/>
- <t:delegate t:to="activeBlock" />
- <t:block t:id="loginBlock">
- <t:LoginComponent />
- </t:block>
- <t:block t:id="pageBlock">
- <t:body />
- </t:block>
- <!--<t:if t:test="needAuthentification">
- <t:LoginComponent />
- <p:else>
- <t:if t:test="canDisplayBody()">
- <t:body />
- </t:if>
- </p:else>
- </t:if>-->
+ <t:body />
</div>
</div>
Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,18 +0,0 @@
-
-<t:form t:id="loginCompForm" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <FieldSet>
- <legend>${message:connectionLegend}</legend>
- <t:feedback t:id="loginCompFeedback" />
- <div>
- <t:label for="connectionLogin" />
- <input t:type="TextField" t:id="connectionLogin" validate="required" />
- </div>
- <div>
- <t:label for="connectionPassword" />
- <input t:type="PasswordField" t:id="connectionPassword" validate="required" />
- </div>
- <div class="buttons">
- <input t:id="submitLoginCompForm" t:type="Submit" t:value="${message:loginSubmit}" />
- </div>
- </FieldSet>
-</t:form>
Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_en.properties 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,7 +0,0 @@
-connectionLegend=LogIn
-loginSubmit=Log me in
-loginComp-label=Login
-loginComp-required-message=You must enter your login.
-passwordComp-label=Password
-passwordComp-required-message=You must enter your password.
-loginFailed=Login or password invalid.
\ No newline at end of file
Deleted: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/LoginComponent_fr.properties 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,7 +0,0 @@
-connectionLegend=Connexion
-loginSubmit=Me connecter
-loginComp-label=Identifiant
-loginComp-required-message=Vous devez entrer votre identifiant.
-passwordComp-label=Mot de passe
-passwordComp-required-message=Vous devez entrer votre mot de passe.
-loginFailed=Mauvais identifiant ou mot de passe.
\ No newline at end of file
Added: trunk/pollen-ui/src/main/webapp/Connexion.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/Connexion.tml (rev 0)
+++ trunk/pollen-ui/src/main/webapp/Connexion.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<t:border t:addressBar="addressBar" t:pageLogo="literal:Index"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <t:form t:id="loginForm">
+ <fieldset>
+ <legend>${message:connectionLegend}</legend>
+ <t:errors />
+ <div>
+ <t:label for="connectionLogin" />
+ <input t:type="TextField" t:id="connectionLogin" validate="required" />
+ </div>
+ <div>
+ <t:label for="connectionPassword" />
+ <input t:type="PasswordField" t:id="connectionPassword" validate="required" />
+ </div>
+ <div class="buttons">
+ <input t:id="submitLoginCompForm" t:type="Submit" t:value="${message:loginSubmit}" />
+ </div>
+ </fieldset>
+ </t:form>
+
+</t:border>
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/webapp/Connexion.tml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-ui/src/main/webapp/ErrorPage.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/ErrorPage.tml 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/webapp/ErrorPage.tml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,4 +1,4 @@
-<t:border t:address="address" t:pageLogo="literal:Index"
+<t:border t:addressBar="addressBar" t:pageLogo="literal:Index"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
</t:border>
Deleted: trunk/pollen-ui/src/main/webapp/css/loginComponent.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/loginComponent.css 2010-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/webapp/css/loginComponent.css 2010-05-04 10:11:20 UTC (rev 2983)
@@ -1,35 +0,0 @@
-#loginCompForm fieldset {
- border: 1px solid #aab;
- padding: 15px;
- padding-bottom: 10px;
- width: 280px;
- margin: auto;
- margin-top: 20px;
- vertical-align: top;
- text-align: left;
-}
-
-#loginCompForm div {
- margin-bottom: 10px;
-}
-
-#loginCompForm label {
- display: block;
- width: 100px;
- float: left;
-}
-
-.buttons {
- text-align: center;
- margin-top: 20px;
- padding-left: 0px;
-}
-
-.fb-error {
- width: 270px;
- margin: auto;
- text-align: center;
- color: #f00;
- font-weight: bold;
- border: 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-04-30 09:40:14 UTC (rev 2982)
+++ trunk/pollen-ui/src/main/webapp/css/main.css 2010-05-04 10:11:20 UTC (rev 2983)
@@ -392,4 +392,32 @@
#po-footer a,
#po-footer span {
color:#727a7e;
+}
+
+/** old LoginComponent > Connexion page **/
+#loginCompForm fieldset {
+ border: 1px solid #aab;
+ padding: 15px;
+ padding-bottom: 10px;
+ width: 280px;
+ margin: auto;
+ margin-top: 20px;
+ vertical-align: top;
+ text-align: left;
+}
+
+#loginCompForm div {
+ margin-bottom: 10px;
+}
+
+#loginCompForm label {
+ display: block;
+ width: 100px;
+ float: left;
+}
+
+#loginCompForm .buttons {
+ text-align: center;
+ margin-top: 20px;
+ padding-left: 0px;
}
\ No newline at end of file
Added: trunk/src/license/project.xml
===================================================================
--- trunk/src/license/project.xml (rev 0)
+++ trunk/src/license/project.xml 2010-05-04 10:11:20 UTC (rev 2983)
@@ -0,0 +1,105 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project xmlns="http://maven-site.nuiton.org/maven-license-plugin/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven-site.nuiton.org/maven-license-plugin/1.0.0 http://maven-site.nuiton.org/maven-license-plugin/licenseProjectDescriptor-…">
+ <mainLicense>gpl_v3</mainLicense>
+
+ <headers>
+
+ <header>
+ <commentStyle>java</commentStyle>
+ <fileSets>
+ <fileSet>
+ <basedir>src/main/java</basedir>
+ <include>**/*.java</include>
+ </fileSet>
+ <fileSet>
+ <!-- assets for tapestry -->
+ <basedir>src/main/webapp</basedir>
+ <includes>
+ <include>**/*.css</include>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <!-- tests -->
+ <basedir>src/test/java</basedir>
+ <include>**/*.java</include>
+ </fileSet>
+ <fileSet>
+ <!-- generated sources with EUGene -->
+ <basedir>target/generated-sources/java</basedir>
+ <include>**/*.java</include>
+ </fileSet>
+ </fileSets>
+ </header>
+
+ <header>
+ <commentStyle>rst</commentStyle>
+ <fileSet>
+ <!-- maven-site -->
+ <basedir>src/site</basedir>
+ <include>**/*.rst</include>
+ </fileSet>
+ </header>
+
+ <header>
+ <commentStyle>xml</commentStyle>
+ <fileSets>
+ <fileSet>
+ <!-- tapestry templates for pages -->
+ <basedir>src/main/webapp</basedir>
+ <includes>
+ <include>**/*.tml</include>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <!-- tapestry templates for components -->
+ <basedir>src/main/resources</basedir>
+ <includes>
+ <include>**/*.tml</include>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <!-- test pages for components -->
+ <basedir>src/test/java</basedir>
+ <include>**/*.tml</include>
+ </fileSet>
+ <fileSet>
+ <!-- maven-site -->
+ <basedir>src/site</basedir>
+ <include>**/*.xml</include>
+ </fileSet>
+ <fileSet>
+ <!-- generated sources with EUGene (hibernate mappings) -->
+ <basedir>target/generated-sources/java</basedir>
+ <include>**/*.xml</include>
+ </fileSet>
+ </fileSets>
+ </header>
+
+ <header>
+ <commentStyle>properties</commentStyle>
+ <fileSets>
+ <fileSet>
+ <!-- i18n -->
+ <basedir>src/main/resources</basedir>
+ <include>**/*.properties</include>
+ </fileSet>
+ <fileSet>
+ <!-- i18n for tapestry -->
+ <basedir>src/main/webapp</basedir>
+ <include>**/*.properties</include>
+ </fileSet>
+ <fileSet>
+ <!-- maven filtered properties -->
+ <basedir>src/main/filters</basedir>
+ <include>**/*.properties</include>
+ </fileSet>
+ </fileSets>
+ </header>
+ </headers>
+
+</project>
Property changes on: trunk/src/license/project.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
30 Apr '10
Author: fdesbois
Date: 2010-04-30 11:40:14 +0200 (Fri, 30 Apr 2010)
New Revision: 2982
Url: http://chorem.org/repositories/revision/pollen/2982
Log:
Repare pollForm from previous version 1.3
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties
trunk/pollen-ui/src/main/webapp/js/pollForm.js
trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-30 09:40:14 UTC (rev 2982)
@@ -10,6 +10,7 @@
import org.chorem.pollen.entity.Comment;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.PollAccountImpl;
import org.chorem.pollen.entity.PollImpl;
import org.chorem.pollen.entity.UserAccount;
import org.nuiton.topia.TopiaContext;
@@ -51,8 +52,19 @@
}
@Override
- protected Poll executeGetNewPoll() {
- return new PollImpl();
+ protected Poll executeGetNewPoll(UserAccount user) {
+ Poll poll = new PollImpl();
+ // Initialize creator as an admin for the poll
+ PollAccount creator = new PollAccountImpl();
+ creator.setAdmin(true);
+ if (user != null) {
+ // Link the creator with the user
+ creator.setName(user.getDisplayName());
+ creator.setEmail(user.getEmail());
+ creator.setUserAccount(user);
+ }
+ poll.setCreator(creator);
+ return poll;
}
@Override
@@ -69,6 +81,9 @@
PollenDAOHelper.getPollDAO(transaction).create(poll);
+ // need to create uid for both poll and creator
+ // need to create creator (name, email, user, admin)
+
transaction.commitTransaction();
}
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-30 09:40:14 UTC (rev 2982)
@@ -59,7 +59,10 @@
*/
@Override
public UserAccount getUserConnected() {
- return user;
+ if (isUserConnected()) {
+ return user;
+ }
+ return null;
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-30 09:40:14 UTC (rev 2982)
@@ -312,6 +312,7 @@
*/
Object onActionFromLogout() {
user = null;
+ request.getSession(false).invalidate();
return Index.class;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-04-30 09:40:14 UTC (rev 2982)
@@ -7,6 +7,7 @@
import org.apache.tapestry5.upload.services.UploadedFile;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.entity.Choice;
+import org.chorem.pollen.entity.ChoiceImpl;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.ui.services.ServiceImage;
import org.slf4j.Logger;
@@ -231,28 +232,35 @@
setName(name);
}
+ protected Choice getChoice() {
+ if (choice == null) {
+ choice = new ChoiceImpl();
+ }
+ return choice;
+ }
+
public void setName(String name) {
- choice.setName(name);
+ getChoice().setName(name);
}
public String getName() {
- return choice.getName();
+ return getChoice().getName();
}
public void setDescription(String description) {
- choice.setDescription(description);
+ getChoice().setDescription(description);
}
public String getDescription() {
- return choice.getDescription();
+ return getChoice().getDescription();
}
public void setChoiceType(ChoiceType choiceType) {
- choice.setChoiceType(choiceType);
+ getChoice().setChoiceType(choiceType);
}
public ChoiceType getChoiceType() {
- return choice.getChoiceType();
+ return getChoice().getChoiceType();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-04-30 09:40:14 UTC (rev 2982)
@@ -26,6 +26,8 @@
import org.chorem.pollen.entity.Choice;
import org.chorem.pollen.entity.Poll;
import org.chorem.pollen.entity.PreventRule;
+import org.chorem.pollen.entity.PreventRuleImpl;
+import org.chorem.pollen.mail.PreventRuleManager;
import org.chorem.pollen.service.ServicePoll;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
@@ -103,6 +105,7 @@
* the pollUID exist.
*
* @return poll existing or a new one
+ * @throws PollenBusinessException
*/
public Poll getPoll() throws PollenBusinessException {
if (poll == null) {
@@ -116,17 +119,7 @@
if (log.isDebugEnabled()) {
log.debug("Init new poll");
}
- poll = servicePoll.getNewPoll();
-
- // FIXME : manage PollAccount creator
-
-// if (userExists) {
-// String creatorName =
-// user.getFirstName() + " " + user.getLastName();
-// poll.setCreatorName(creatorName);
-// poll.setCreatorEmail(user.getEmail());
-// poll.setUserId(user.getId());
-// }
+ poll = servicePoll.getNewPoll(getUserConnected());
}
}
return poll;
@@ -136,6 +129,7 @@
* Test if the form mode is for creation : new poll.
*
* @return true if it's the create mode, false otherwise
+ * @throws PollenBusinessException
*/
public boolean isCreateMode() throws PollenBusinessException {
return StringUtils.isEmpty(getPoll().getTopiaId());
@@ -145,6 +139,7 @@
* Page title for border component.
*
* @return the page title depends on create or update mode.
+ * @throws PollenBusinessException
*/
public String getPageTitle() throws PollenBusinessException {
String title = "";
@@ -337,9 +332,12 @@
*/
public PreventRule getNotification() {
if (notification == null) {
-// notification = new PreventRuleImpl("vote", 0, true,
-// PreventRuleManager.EMAIL_ACTION);
-// notification.set
+ // FIXME-FD20100430 : move this in business module
+ notification = new PreventRuleImpl();
+ notification.setScope("vote");
+ notification.setSensibility(0);
+ notification.setRepeated(true);
+ notification.setMethod(PreventRuleManager.EMAIL_ACTION);
}
return notification;
}
@@ -364,8 +362,12 @@
*/
public PreventRule getReminder() {
if (reminder == null) {
-// reminder = new PreventRuleDTO("rappel", 0, false,
-// PreventRuleManager.EMAIL_ACTION);
+ // FIXME-FD20100430 : move this in business module
+ reminder = new PreventRuleImpl();
+ reminder.setScope("rappel");
+ reminder.setSensibility(0);
+ reminder.setRepeated(false);
+ reminder.setMethod(PreventRuleManager.EMAIL_ACTION);
}
return reminder;
}
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/PollForm_fr.properties 2010-04-30 09:40:14 UTC (rev 2982)
@@ -25,8 +25,8 @@
endDate-validate=La date de fin doit-\u00EAtre post\u00E9rieure \u00E0 la date de d\u00E9but.
pollType-label=Restriction des votants
pollType-help=<strong>Aucune</strong> : accessible \u00E0 tout le monde<br/><strong>Liste simple</strong> : accessible uniquement \u00E0 une liste de votants<br/><strong>Par groupes</strong> : accessible \u00E0 plusieurs listes de votants
-voteCounting-label=D\u00E9pouillement
-voteCounting-help=<strong>Normal</strong> : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/><strong>Pourcentage</strong> : attribution d\'un pourcentage \u00E0 chaque choix<br/><strong>Condorcet</strong> : classement des choix par ordre de pr\u00E9f\u00E9rence<br/><strong>Nombre</strong> : R\u00E9ponse libre. Fait la somme et la moyenne des nombres.
+VoteCountingType-label=D\u00E9pouillement
+VoteCountingType-help=<strong>Normal</strong> : s\u00E9lection de 1 ou n choix parmis les choix possibles<br/><strong>Pourcentage</strong> : attribution d\'un pourcentage \u00E0 chaque choix<br/><strong>Condorcet</strong> : classement des choix par ordre de pr\u00E9f\u00E9rence<br/><strong>Nombre</strong> : R\u00E9ponse libre. Fait la somme et la moyenne des nombres.
# Labels for enums
PollType.FREE=Aucune
Modified: trunk/pollen-ui/src/main/webapp/js/pollForm.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/webapp/js/pollForm.js 2010-04-30 09:40:14 UTC (rev 2982)
@@ -16,7 +16,7 @@
this.notificationFragmentId = 'notificationHidden';
// Attributes for voteCounting and choiceNb synchronization
- this.voteCounting = this.form.voteCounting;
+ this.voteCounting = this.form.voteCountingType;
this.voteCountingNormal = voteCountingNormal;
this.choiceNbFragmentId = 'choiceNbHidden';
this.choiceNb = this.form.choiceNb;
Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-04-30 08:47:02 UTC (rev 2981)
+++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-04-30 09:40:14 UTC (rev 2982)
@@ -1,13 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<t:border t:addressBar="addressBar" t:pageLogo="literal:Creation" t:pageBodyId="p-pollForm" t:pageTitle="prop:pageTitle"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-<t:feedback t:id="feedback"/>
+
<h1 class="titlePoll">
<t:if t:test="createMode">
${message:mainTitle-create}
<p:else>${poll.title}</p:else>
</t:if>
</h1>
+
<t:zone t:id="mainZone" t:update="show">
<form t:type="form" t:id="mainForm" t:zone="mainZone" action="post">
<t:errors/>
1
0
Author: fdesbois
Date: 2010-04-30 10:47:02 +0200 (Fri, 30 Apr 2010)
New Revision: 2981
Url: http://chorem.org/repositories/revision/pollen/2981
Log:
Continue UserLists managment...
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java
Removed:
trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
trunk/pollen-business/src/main/xmi/pollen.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java
trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
___________________________________________________________________
Modified: svn:keywords
- "Author Date Id Revision HeadURL"
+ Id
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
___________________________________________________________________
Modified: svn:keywords
- "Author Date Id Revision HeadURL"
+ Author Date Id Revision HeadURL
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
___________________________________________________________________
Modified: svn:keywords
- "Author Date Id Revision HeadURL"
+ Author Date Id Revision HeadURL
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -0,0 +1,24 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * FavoriteParticipantImpl
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class FavoriteParticipantImpl extends FavoriteParticipantAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getId() {
+ return getTopiaId();
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -57,7 +57,6 @@
public void setContext(PollenContext context) {
this.context = context;
- prepareFavoriteListBinder();
}
@Override
@@ -76,14 +75,6 @@
context.closeTransaction(transaction);
}
- protected void prepareFavoriteListBinder() {
- BinderBuilder builder = new BinderBuilder(PollAccount.class,
- PollAccount.LIST,
- PollAccount.NAME,
- PollAccount.USER_ACCOUNT);
- BinderProvider.registerBinder(builder, BINDER_CONTEXT_FAVORITE_LIST);
- }
-
/**
* Copy {@code source} user account to {@code destination} one.
* The email is lower cased in the {@code destination} user account.
@@ -227,7 +218,7 @@
// Execute create
UserAccount newUser = dao.create(user.getLogin());
copyUserAccount(user, newUser);
- user.setTopiaId(newUser.getTopiaId());
+// user.setTopiaId(newUser.getTopiaId());
transaction.commitTransaction();
}
@@ -318,9 +309,8 @@
// check favoriteList name exist for user
UserAccount user = list.getUserAccount();
int count = dao.createQuery().
- add(PollAccount.LIST, true).
- add(PollAccount.USER_ACCOUNT, user).
- add(PollAccount.NAME, list.getName()).
+ add(FavoriteList.USER_ACCOUNT, user).
+ add(FavoriteList.NAME, list.getName()).
executeCount();
// existing list found
if (count > 0) {
@@ -329,13 +319,10 @@
list.getName(), user.getDisplayName());
}
- // Create unique Id for the new List
- String UId = context.createPollenUrlId();
- FavoriteList newList = dao.create(UId);
- BinderProvider.getBinder(FavoriteList.class,
- BINDER_CONTEXT_FAVORITE_LIST).
- copy(list, newList);
- dao.update(newList);
+ FavoriteList newList = dao.create(
+ FavoriteList.USER_ACCOUNT, list.getUserAccount(),
+ FavoriteList.NAME, list.getName());
+// list.setTopiaId(newList.getTopiaId());
transaction.commitTransaction();
}
@@ -363,6 +350,7 @@
throws TopiaException {
FavoriteParticipant result = new FavoriteParticipantImpl();
result.setFavoriteList(list);
+ result.setWeight(1.);
return result;
}
@@ -370,7 +358,36 @@
protected void executeCreateFavoriteParticipant(TopiaContext transaction,
FavoriteParticipant participant)
throws PollenBusinessException, TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
+
+ FavoriteList list = participant.getFavoriteList();
+// int count = dao.createQuery().
+// add(FavoriteParticipant.FAVORITE_LIST, list).
+// add(FavoriteParticipant.NAME, participant.getName()).
+// add(FavoriteParticipant.EMAIL, participant.getEmail()).
+// executeCount();
+// // existing participant found
+// if (count > 0) {
+// throw new PollenBusinessException(
+// PollenExceptionType.FAVORITE_PARTICIPANT_EXIST,
+// list.getName(), list.getName());
+// }
+
+ // Create newParticipant with naturalId
+ FavoriteParticipant newParticipant =
+ dao.create(FavoriteParticipant.FAVORITE_LIST, list,
+ FavoriteParticipant.NAME, participant.getName(),
+ FavoriteParticipant.EMAIL, participant.getEmail());
+
+ // Set other field
+ newParticipant.setWeight(participant.getWeight());
+
+ // Update input participant with new topiaId
+// participant.setTopiaId(newParticipant.getTopiaId());
+
+ transaction.commitTransaction();
}
@Override
@@ -397,9 +414,17 @@
FavoriteParticipantDAO dao =
PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- Map<String, FavoriteParticipant> results = dao.findAllMappedByQuery(
- query, FavoriteParticipant.EMAIL, String.class);
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+ Map<String, FavoriteParticipant> results =
+ dao.findAllMappedByQuery(query);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Results : " + results);
+ }
+
return results;
}
Modified: trunk/pollen-business/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-30 08:47:02 UTC (rev 2981)
@@ -13,4 +13,6 @@
org.chorem.pollen.entity.FavoriteList.attribute.name.tagvalue.naturalId=true
org.chorem.pollen.entity.FavoriteParticipant.attribute.favoriteList.tagvalue.naturalId=true
-org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.naturalId=true
\ No newline at end of file
+org.chorem.pollen.entity.FavoriteParticipant.attribute.name.tagvalue.naturalId=true
+org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.naturalId=true
+org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.notNull=false
\ No newline at end of file
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
___________________________________________________________________
Modified: svn:keywords
- "Author Date Id Revision HeadURL"
+ Author Date Id Revision HeadURL
Copied: trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java (from rev 2973, trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java)
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -0,0 +1,143 @@
+
+package org.chorem.pollen.business;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenContext;
+import org.chorem.pollen.PollenContextImpl;
+import org.chorem.pollen.PollenDAOHelper;
+import org.chorem.pollen.entity.UserAccount;
+import org.chorem.pollen.entity.UserAccountDAO;
+import org.chorem.pollen.service.ServiceUserImpl;
+import org.junit.After;
+import org.junit.Ignore;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * TestManager
+ *
+ * Created: 24 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+@Ignore
+public class AbstractServiceTest {
+
+ private static final Log log = LogFactory.getLog(AbstractServiceTest.class);
+
+ protected PollenContext context;
+
+ protected ServiceUserImpl serviceUser;
+
+ public void start(String dbname) throws IOException {
+ log.info("## START ## : " + dbname);
+
+ InputStream input = AbstractServiceTest.class.
+ getResourceAsStream("/PollenTest.properties");
+
+ Properties options = new Properties();
+ options.load(input);
+
+ ApplicationConfig config = new ApplicationConfig();
+ config.setOptions(options);
+ config.setOption(
+ "hibernate.connection.url",
+ "jdbc:h2:file:target/surefire-data/" + dbname
+ );
+
+ getContext().loadConfiguration(config);
+ getContext().start(getServiceUser());
+
+ // Set currentDate to 23/02/2010 for tests
+ Calendar calendar = new GregorianCalendar(2010, 1, 23, 0, 0, 0);
+ ((PollenContextImpl)getContext()).setCurrentDate(calendar.getTime());
+ }
+
+ @After
+ public void stop() throws IOException {
+ getContext().stop();
+ context = null;
+ serviceUser = null;
+ }
+
+ public PollenContext getContext() {
+ if (context == null) {
+ context = new PollenContextImpl();
+ }
+ return context;
+ }
+
+ public ServiceUserImpl getServiceUser() {
+ if (serviceUser == null) {
+ serviceUser = new ServiceUserImpl();
+ serviceUser.setContext(getContext());
+ }
+ return serviceUser;
+ }
+
+ public TopiaContext beginTransaction() throws TopiaException {
+ return getContext().beginTransaction();
+ }
+
+// public ServiceEmailImpl getServiceEmail() {
+// ServiceEmailImpl instance = new ServiceEmailImpl();
+// instance.setContext(getContext());
+// return instance;
+// }
+//
+// public ServicePollImpl getServicePoll() {
+// ServicePollImpl instance = new ServicePollImpl();
+// instance.setContext(getContext());
+// return instance;
+// }
+
+ /**
+ * Create a user :<br />
+ * <ul>
+ * <li>login : homer</li>
+ * <li>email : homer(a)simpson.us</li>
+ * <li>password : wouhou</li>
+ * </ul>
+ * You can decide if this user is an admin using {@code admin} argument.
+ *
+ * @param admin flag to create the user as an admin
+ * @return the new UserAccount created
+ * @throws TopiaException
+ * @throws PollenBusinessException
+ */
+ public UserAccount createUser(boolean admin)
+ throws TopiaException, PollenBusinessException {
+
+ UserAccount user = getServiceUser().getNewUser();
+ user.setLogin("homer");
+ user.setEmail("homer(a)simpson.us");
+ user.setNewPassword("wouhou");
+ user.setAdmin(admin);
+
+ getServiceUser().createUser(user);
+
+ TopiaContext transaction = getContext().beginTransaction();
+ try {
+ UserAccountDAO dao =
+ PollenDAOHelper.getUserAccountDAO(transaction);
+
+ UserAccount findUser = dao.findByLogin(user.getLogin());
+ return findUser;
+ } finally {
+ transaction.closeContext();
+ }
+ }
+
+}
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/business/AbstractServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -20,7 +20,7 @@
public void execute() throws Exception {
transaction = null;
try {
- transaction = TestManager.beginTransaction();
+ //transaction = beginTransaction();
test();
Deleted: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -1,99 +0,0 @@
-
-package org.chorem.pollen.business;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.PollenContext;
-import org.chorem.pollen.PollenContextImpl;
-import org.chorem.pollen.service.ServiceEmail;
-import org.chorem.pollen.service.ServiceEmailImpl;
-import org.chorem.pollen.service.ServicePoll;
-import org.chorem.pollen.service.ServicePollImpl;
-import org.chorem.pollen.service.ServiceUser;
-import org.chorem.pollen.service.ServiceUserImpl;
-import org.junit.Ignore;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * TestManager
- *
- * Created: 24 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-@Ignore
-public class TestManager {
-
- private static final Log log = LogFactory.getLog(TestManager.class);
-
- private static PollenContext context;
-
- public static void start(String dbname) throws IOException {
- log.info("## START ## : " + dbname);
-
- InputStream input = TestManager.class.
- getResourceAsStream("/PollenTest.properties");
-
- Properties options = new Properties();
- options.load(input);
-
- ApplicationConfig config = new ApplicationConfig();
- config.setOptions(options);
- config.setOption(
- "hibernate.connection.url",
- "jdbc:h2:file:target/surefire-data/" + dbname
- );
-
- getContext().loadConfiguration(config);
- getContext().start(getServiceUser());
-
- // Set currentDate to 23/02/2010 for tests
- Calendar calendar = new GregorianCalendar(2010, 1, 23, 0, 0, 0);
- ((PollenContextImpl)getContext()).setCurrentDate(calendar.getTime());
- }
-
- public static void stop() throws IOException {
- getContext().stop();
- }
-
- public static PollenContext getContext() {
- if (context == null) {
- context = new PollenContextImpl();
- }
- return context;
- }
-
- public static TopiaContext beginTransaction() throws TopiaException {
- return getContext().beginTransaction();
- }
-
- public static ServiceUserImpl getServiceUser() {
- ServiceUserImpl instance = new ServiceUserImpl();
- instance.setContext(getContext());
- return instance;
- }
-
- public static ServiceEmailImpl getServiceEmail() {
- ServiceEmailImpl instance = new ServiceEmailImpl();
- instance.setContext(getContext());
- return instance;
- }
-
- public static ServicePollImpl getServicePoll() {
- ServicePollImpl instance = new ServicePollImpl();
- instance.setContext(getContext());
- return instance;
- }
-
-}
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/service/ServiceUserImplTest.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -1,22 +1,17 @@
package org.chorem.pollen.service;
-import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
-import org.chorem.pollen.business.TestManager;
+import org.chorem.pollen.business.AbstractServiceTest;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
-import org.junit.After;
-import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
@@ -24,46 +19,24 @@
*
* @author fdesbois
*/
-public class ServiceUserImplTest {
+public class ServiceUserImplTest extends AbstractServiceTest {
private static final Log log = LogFactory.getLog(ServiceUserImplTest.class);
-
- public ServiceUserImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() throws IOException {
- TestManager.stop();
- }
-
+
@Test
public void testCopyUserAccount() throws Exception {
- TestManager.start("testManageNewPassword");
-
- ServiceUserImpl serviceUser = TestManager.getServiceUser();
+ start("testManageNewPassword");
- UserAccount user = serviceUser.getNewUser();
+ UserAccount user = getServiceUser().getNewUser();
user.setLogin("homer");
user.setNewPassword("wouhou");
log.info("test 1 : Encode new password");
UserAccount destination = new UserAccountImpl();
- serviceUser.copyUserAccount(user, destination);
+ getServiceUser().copyUserAccount(user, destination);
Assert.assertNotNull(destination.getPassword());
- String expected = TestManager.getContext().encodePassword("wouhou");
+ String expected = getContext().encodePassword("wouhou");
Assert.assertEquals(expected, destination.getPassword());
log.info("test 2 : Do not encode new password -> newPassword empty");
@@ -75,19 +48,16 @@
@Test
public void testCheckPassword() throws Exception {
- TestManager.start("testCheckPassword");
+ start("testCheckPassword");
- ServiceUserImpl serviceUser = TestManager.getServiceUser();
-
- UserAccount user = serviceUser.getNewUser();
+ UserAccount user = getServiceUser().getNewUser();
user.setLogin("homer");
user.setNewPassword("wouhou");
- serviceUser.createUser(user);
+ getServiceUser().createUser(user);
- String encodedPassword =
- TestManager.getContext().encodePassword("wouhou");
+ String encodedPassword = getContext().encodePassword("wouhou");
- TopiaContext transaction = TestManager.beginTransaction();
+ TopiaContext transaction = beginTransaction();
try {
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
@@ -112,32 +82,28 @@
*/
@Test
public void testExecuteConnect() throws Exception {
- TestManager.start("testExecuteConnect");
+ start("testExecuteConnect");
- ServiceUser serviceUser = TestManager.getServiceUser();
+ // The password is wouhou and login is homer
+ UserAccount user = createUser(false);
- UserAccount user = serviceUser.getNewUser();
- user.setLogin("hsimpson");
- user.setEmail("hsimpson(a)springfield.us");
- user.setNewPassword("wouhou");
- serviceUser.createUser(user);
-
log.info("test 1 : Connection OK");
- UserAccount connected = serviceUser.connect("hsimpson", "wouhou");
+ UserAccount connected = getServiceUser().connect("homer", "wouhou");
Assert.assertEquals(user, connected);
log.info("test 2 : Connection problem on login -> user not exist");
try {
- serviceUser.connect("homer", "wouhou");
+ getServiceUser().connect("marge", "wouhou");
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_NOT_EXIST,
eee.getType());
}
- log.info("test 3 : Connection problem on password -> don't match with login");
+ log.info("test 3 : Connection problem on password -> " +
+ "don't match with login");
try {
- serviceUser.connect("hsimpson", "coucou");
+ getServiceUser().connect("homer", "coucou");
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_WRONG_PASSWORD,
@@ -150,10 +116,9 @@
*/
@Test
public void testExecuteGetNewUser() throws Exception {
- TestManager.start("testGetNewUser");
- ServiceUser serviceUser = TestManager.getServiceUser();
+ start("testGetNewUser");
- UserAccount user = serviceUser.getNewUser();
+ UserAccount user = getServiceUser().getNewUser();
Assert.assertNotNull(user);
Assert.assertEquals(false, user.getAdmin());
}
@@ -163,31 +128,29 @@
*/
@Test
public void testExecuteCreateUser() throws Exception {
- TestManager.start("testCreateUser");
- ServiceUser serviceUser = TestManager.getServiceUser();
+ start("testCreateUser");
- UserAccount user = serviceUser.getNewUser();
+ UserAccount user = getServiceUser().getNewUser();
user.setLogin("hsimpson");
user.setEmail("hsimpson(a)springfield.us");
user.setNewPassword("wouhou");
- String encodedPassword =
- TestManager.getContext().encodePassword("wouhou");
+ String encodedPassword = getContext().encodePassword("wouhou");
log.info("test 1 : Creation OK");
- serviceUser.createUser(user);
- Assert.assertNotNull(user.getTopiaId());
+ getServiceUser().createUser(user);
+ //Assert.assertNotNull(user.getTopiaId());
Assert.assertNotSame(encodedPassword, user.getPassword());
log.info("test 2 : Creation problem on login -> user exist");
- UserAccount user2 = serviceUser.getNewUser();
+ UserAccount user2 = getServiceUser().getNewUser();
user2.setLogin("hsimpson");
// Not the same email
user2.setEmail("hsimpson(a)springfield.com");
user2.setNewPassword("troubidou");
try {
- serviceUser.createUser(user2);
+ getServiceUser().createUser(user2);
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_LOGIN_EXIST,
@@ -195,13 +158,13 @@
}
log.info("test 3 : Creation problem on email -> user exist");
- UserAccount user3 = serviceUser.getNewUser();
+ UserAccount user3 = getServiceUser().getNewUser();
user3.setLogin("homer");
user3.setEmail("hsimpson(a)springfield.us");
user3.setNewPassword("troubidou");
try {
- serviceUser.createUser(user3);
+ getServiceUser().createUser(user3);
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_EMAIL_EXIST,
@@ -209,11 +172,11 @@
}
log.info("test 4 : Creation OK with no email");
- UserAccount user4 = serviceUser.getNewUser();
+ UserAccount user4 = getServiceUser().getNewUser();
user4.setLogin("marge");
user4.setNewPassword("troubidou");
- serviceUser.createUser(user4);
+ getServiceUser().createUser(user4);
Assert.assertNull(user4.getEmail());
}
@@ -222,27 +185,26 @@
*/
@Test
public void testExecuteUpdateUser() throws Exception {
- TestManager.start("testUpdateUser");
- ServiceUser serviceUser = TestManager.getServiceUser();
+ start("testUpdateUser");
- UserAccount user1 = serviceUser.getNewUser();
+ UserAccount user1 = getServiceUser().getNewUser();
user1.setLogin("hsimpson");
user1.setEmail("hsimpson(a)springfield.us");
user1.setNewPassword("wouhou");
- serviceUser.createUser(user1);
+ getServiceUser().createUser(user1);
- UserAccount user2 = serviceUser.getNewUser();
+ UserAccount user2 = getServiceUser().getNewUser();
String user2Password = "wouhou";
user2.setLogin("homer");
user2.setEmail("hsimpson(a)springfield.fr");
user2.setNewPassword(user2Password);
- serviceUser.createUser(user2);
+ getServiceUser().createUser(user2);
log.info("test 1 : Can't change login -> don't match with password");
user2.setLogin("homersimpson");
user2.setPassword(user2Password);
try {
- serviceUser.updateUser(user2, false);
+ getServiceUser().updateUser(user2, false);
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_WRONG_PASSWORD,
@@ -253,13 +215,13 @@
log.info("test 2 : Change email OK");
user2.setEmail("homersimpson(a)springield.fr");
user2.setPassword(user2Password);
- serviceUser.updateUser(user2, false);
+ getServiceUser().updateUser(user2, false);
log.info("test 3 : Change email problem -> user exist");
user2.setEmail(user1.getEmail());
user2.setPassword(user2Password);
try {
- serviceUser.updateUser(user2, false);
+ getServiceUser().updateUser(user2, false);
} catch (PollenBusinessException eee) {
log.error("Error : " + eee.getMessage());
Assert.assertEquals(PollenExceptionType.USER_EMAIL_EXIST,
@@ -275,26 +237,25 @@
*/
@Test
public void testExecuteDeleteUser() throws Exception {
- TestManager.start("testUpdateUser");
- ServiceUser serviceUser = TestManager.getServiceUser();
+ start("testUpdateUser");
try {
- serviceUser.deleteUser("test");
+ getServiceUser().deleteUser("test");
} catch (PollenException eee) {
log.error(eee);
Assert.assertEquals(IllegalArgumentException.class,
eee.getCause().getClass());
}
- UserAccount user = serviceUser.getNewUser();
+ UserAccount user = getServiceUser().getNewUser();
user.setLogin("user");
- serviceUser.createUser(user);
+ getServiceUser().createUser(user);
- serviceUser.deleteUser("user");
+ getServiceUser().deleteUser("user");
TopiaContext transaction = null;
try {
- transaction = TestManager.beginTransaction();
+ transaction = beginTransaction();
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
UserAccount userFound = dao.findByLogin("user");
Assert.assertNull(userFound);
@@ -303,60 +264,14 @@
}
}
- /**
- * Test of executeGetUsers method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteGetUsers() throws Exception {
- System.out.println("executeGetUsers");
- }
+ @Test
+ public void testCreateFavoriteParticipant() throws Exception {
+ start("testCreateFavoriteParticipant");
+
+ UserAccount user = createUser(false);
- /**
- * Test of executeGetNewList method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteGetNewList() throws Exception {
- System.out.println("executeGetNewList");
+ // TODO : test on naturalId and nullity
+
}
- /**
- * Test of executeCreateUpdateList method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteCreateUpdateList() throws Exception {
- System.out.println("executeCreateUpdateList");
- }
-
- /**
- * Test of executeDeleteList method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteDeleteList() throws Exception {
- System.out.println("executeDeleteList");
- }
-
- /**
- * Test of executeGetFavoriteLists method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteGetFavoriteLists() throws Exception {
- System.out.println("executeGetFavoriteLists");
- }
-
- /**
- * Test of executeGetNewPerson method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteGetNewPerson() throws Exception {
- System.out.println("executeGetNewPerson");
- }
-
- /**
- * Test of executeGetPerson method, of class ServiceUserImpl.
- */
- //@Test
- public void testExecuteGetPerson() throws Exception {
- System.out.println("executeGetPerson");
- }
-
}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -44,19 +44,20 @@
@Inject
private ServiceUser serviceUser;
+ @Persist
@Property
private FavoriteList favoriteListSelected;
private EvenOdd evenOdd;
@Persist
- private FavoriteParticipantDataSource accounts;
+ private FavoriteParticipantDataSource participants;
@Property
- private FavoriteParticipant account;
+ private FavoriteParticipant participant;
@Property
- private FavoriteParticipant newAccount;
+ private FavoriteParticipant newParticipant;
@InjectComponent
private Zone updateZone;
@@ -76,28 +77,32 @@
return favoriteListSelected != null;
}
- public FavoriteParticipantDataSource getAccounts() {
- if (accounts == null) {
+ public FavoriteParticipantDataSource getParticipants() {
+ if (participants == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Create DATASOURCE");
+ }
Filter filter = new Filter();
filter.setReference(favoriteListSelected);
- accounts = new FavoriteParticipantDataSource(serviceUser, filter);
+ participants =
+ new FavoriteParticipantDataSource(serviceUser, filter);
}
- return accounts;
+ return participants;
}
- void onActionFromRemoveAccount(String UId) {
+ void onActionFromRemoveParticipant(String UId) {
// NEED DELETE ACCOUNT FOR LIST
}
- void onPrepareFromAddAccount() {
- if (newAccount == null) {
- newAccount =
+ void onPrepareFromAddParticipant() {
+ if (newParticipant == null) {
+ newParticipant =
serviceUser.getNewFavoriteParticipant(favoriteListSelected);
}
}
- Object onSuccessFromAddAccount() {
- // NEED CREATE ACCOUNT FOR LIST
+ Object onSuccessFromAddParticipant() {
+ serviceUser.createFavoriteParticipant(newParticipant);
return updateZone.getBody();
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -1,32 +1,7 @@
-/*
- * #%L
- * Wao :: Web Interface
- *
- * $Id$
- * $HeadURL: svn+ssh://fdesbois@labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java $
- * %%
- * Copyright (C) 2009 - 2010 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
package org.chorem.pollen.ui.data;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
@@ -49,13 +24,17 @@
* @param <E> Type of the map value
* @author fdesbois <fdesbois(a)codelutin.com>
*/
-public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity> implements GridDataSource {
+public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity>
+ implements GridDataSource {
- private Logger log = LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
+ private Logger log =
+ LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
private Map<K, E> mapResults;
+ private List<E> listResults;
+
private int nbRows = -1;
private int nbRowsPerPage;
@@ -65,8 +44,8 @@
if (nbRows < 0) {
try {
nbRows = count();
- if (log.isTraceEnabled()) {
- log.trace("Count : " + nbRows);
+ if (log.isDebugEnabled()) {
+ log.debug("Count : " + nbRows);
}
} catch (PollenException eee) {
throw new TapestryException("", eee);
@@ -76,14 +55,15 @@
}
@Override
- public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) {
- if (log.isTraceEnabled()) {
- log.trace("Prepare results : " + startIndex + ", " + endIndex);
+ public void prepare(int startIndex, int endIndex,
+ List<SortConstraint> sortConstraints) {
+ if (log.isDebugEnabled()) {
+ log.debug("Prepare results : " + startIndex + ", " + endIndex);
}
nbRowsPerPage = endIndex - startIndex + 1;
try {
mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints));
-
+ listResults = new ArrayList<E>(mapResults.values());
} catch (PollenException eee) {
throw new TapestryException("", eee);
}
@@ -123,17 +103,17 @@
}
return filterOrder;
}
-
+
@Override
public Object getRowValue(int index) {
index = index % nbRowsPerPage;
- if (index >= mapResults.size()) {
+ if (index >= listResults.size()) {
if (log.isErrorEnabled()) {
- log.error("Size error : " + index + " / " + mapResults.size());
+ log.error("Size error : " + index + " / " + listResults.size());
}
return null;
}
- return CollectionUtils.get(mapResults, index);
+ return CollectionUtils.get(listResults, index);
}
@Override
@@ -143,8 +123,8 @@
return mapResults.get(key);
}
- public Collection<E> values() {
- return mapResults.values();
+ public List<E> values() {
+ return listResults;
}
public boolean contains(K key) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-04-30 08:47:02 UTC (rev 2981)
@@ -8,6 +8,8 @@
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.PollAccount;
import org.chorem.pollen.service.ServiceUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* UserAccountDataSource
@@ -23,6 +25,9 @@
public class FavoriteParticipantDataSource extends
AbstractMappedGridDataSource<String, FavoriteParticipant> {
+ private static final Logger logger =
+ LoggerFactory.getLogger(FavoriteParticipantDataSource.class);
+
private ServiceUser service;
private Filter filter;
@@ -39,6 +44,9 @@
filter.setStartIndex(startIndex);
filter.setEndIndex(endIndex);
filter.setOrderBy(resolveOrderBy(orderBy));
+ if (logger.isDebugEnabled()) {
+ logger.debug("LOAD DATA");
+ }
return service.getFavoriteParticipants(filter);
}
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-30 08:47:02 UTC (rev 2981)
@@ -36,7 +36,7 @@
pollen.ui.list.create.success=La liste %1$s a \u00E9t\u00E9 cr\u00E9\u00E9e avec succ\u00E8s.
pollen.ui.list.update.notSelected=Aucune liste s\u00E9lectionn\u00E9e.
pollen.ui.list.update.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
-pollen.ui.list.update.addAccount=Ajouter un nouvel utilisateur \u00E0 la liste
+pollen.ui.list.update.addParticipant=Ajouter un nouvel utilisateur \u00E0 la liste
# FORM:: user
firstName-label=Pr\u00E9nom
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-29 06:05:03 UTC (rev 2980)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-30 08:47:02 UTC (rev 2981)
@@ -13,11 +13,11 @@
<t:if test="canDisplayAccounts()">
<t:zone t:id="updateZone" show="show" update="show">
<!-- Display all Accounts child of favoriteListSelected -->
- <div t:type="grid" t:source="accounts.values()" t:row="account"
+ <div t:type="grid" t:source="participants" t:row="participant"
t:include="name, email, weight" t:add="actions"
t:rowsPerPage="20" t:rowClass="prop:evenodd.next" t:inPlace="true">
<p:actionsCell>
- <a t:type="actionlink" t:id="removeAccount" t:context="account.UId">
+ <a t:type="actionlink" t:id="removeParticipant" t:context="participant.id">
<img src="${asset:context:img/delete.png}" alt="${message:pollen.ui.list.remove}"/>
</a>
</p:actionsCell>
@@ -26,22 +26,21 @@
</p:empty>
</div>
- <!-- Add a new PollAccount to favoriteListSelected -->
- <form t:type="form" t:id="addAccount" t:zone="updateZone" action="tapestry">
+ <!-- Add a new FavoriteParticipant to favoriteListSelected -->
+ <form t:type="form" t:id="addParticipant" t:zone="updateZone" action="tapestry">
<table class="t-data-grid">
<tr>
<td class="votingId">
- <input t:type="textfield" t:id="name" t:value="newAccount.name" t:validate="required" size="10"/>
+ <input t:type="textfield" t:id="name" t:value="newParticipant.name" t:validate="required" size="10"/>
</td>
<td class="email">
- <input t:type="textfield" t:id="email" t:value="newAccount.email" t:validate="email" size="15"/>
+ <input t:type="textfield" t:id="email" t:value="newParticipant.email" t:validate="regexp" size="15"/>
</td>
<td class="weight">
- <input t:type="textfield" t:id="weight" t:value="newAccount.weight" size="5"/>
+ <input t:type="textfield" t:id="weight" t:value="newParticipant.weight" size="5"/>
</td>
<td class="functions">
- <input t:type="hidden" value="newAccount.list" />
- <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addAccount}"/>
+ <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addParticipant}"/>
</td>
</tr>
</table>
1
0
Author: tchemit
Date: 2010-04-29 08:05:03 +0200 (Thu, 29 Apr 2010)
New Revision: 2980
Log:
use i18n 1.2.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-29 05:45:52 UTC (rev 2979)
+++ trunk/pom.xml 2010-04-29 06:05:03 UTC (rev 2980)
@@ -311,7 +311,7 @@
<!--javadoc.version>2.4</javadoc.version-->
<topia.version>2.4-SNAPSHOT</topia.version>
<eugene.version>2.0.2-SNAPSHOT</eugene.version>
- <i18n.version>1.2.1</i18n.version>
+ <i18n.version>1.2.2</i18n.version>
<tapestry.version>5.1.0.5</tapestry.version>
<nuiton-utils.version>1.2.2</nuiton-utils.version>
<processor.version>1.0.2</processor.version>
1
0
Author: tchemit
Date: 2010-04-29 07:45:52 +0200 (Thu, 29 Apr 2010)
New Revision: 2979
Log:
Utilisation de mavenpom4redmine 2.1.3
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-28 14:05:02 UTC (rev 2978)
+++ trunk/pom.xml 2010-04-29 05:45:52 UTC (rev 2979)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.1.2</version>
+ <version>2.1.3</version>
</parent>
<groupId>org.chorem</groupId>
1
0
r2978 - in trunk/pollen-business/src: main/java/org/chorem/pollen main/java/org/chorem/pollen/bean main/java/org/chorem/pollen/entity main/java/org/chorem/pollen/service test/java/org/chorem/pollen
by fdesbois@users.chorem.org 28 Apr '10
by fdesbois@users.chorem.org 28 Apr '10
28 Apr '10
Author: fdesbois
Date: 2010-04-28 16:05:02 +0200 (Wed, 28 Apr 2010)
New Revision: 2978
Log:
- Clean old PropertyNameProvider
- Add a new api for building query using QueryBuilder and EntityQueryProperty
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
Removed:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java (from rev 2977, trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java)
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/EntityQueryProperty.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -0,0 +1,209 @@
+
+package org.chorem.pollen;
+
+import org.nuiton.topia.framework.*;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * EntityQueryProperty is used to simplify property concatenation in TopiaQuery.
+ * The usage is simple, the EntityQueryProperty need a mainAlias which represents
+ * the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
+ * is called to retrieve the correct property name used for the query.
+ * Exemple :
+ * <pre>
+ * BoatDAO dao = AppDAOHelper.getBoatDAO(topiaContext);
+ *
+ * // Property used in the query
+ * EntityQueryProperty boatProperty = new EntityQueryProperty("B");
+ *
+ * // It's better to create the query with the property name
+ * TopiaQuery query = dao.createQuery(boatProperty.name());
+ *
+ * // The property NAME of the boat need to be find equals to "ULUBERLU"
+ * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU");
+ *
+ * // It's avoid doing this :
+ * query.add("B." + Boat.NAME, "ULUBERLU");
+ * </pre>
+ * This last exemple is a simple case but for a more complex query with more
+ * than one entity, it's obvious that concatenation using + is not a good
+ * practice.<br />
+ * You can also use this class as a superclass for each entity, ex :
+ * <pre>
+ * public class BoatProperty extends EntityQueryProperty {
+ *
+ * public BoatProperty(String mainAlias) {
+ * super(mainAlias);
+ * }
+ *
+ * public String namePropertyName() {
+ * return nameProperty(Boat.NAME);
+ * }
+ * }
+ * </pre>
+ *
+ * Created: 14 avr. 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ */
+public class EntityQueryProperty {
+
+ /** alias of the entity **/
+ protected String mainAlias;
+
+ /** name of the property used for join in query **/
+ protected String propertyJoin;
+
+ /** class of the entity **/
+ protected Class<? extends TopiaEntity> entityClass;
+
+ /**
+ * Default constructor. mainAlias, propertyJoin and entityClass are null.
+ * You can use setters to initalize these three properties.
+ * You can use {@link #nameProperty(String)} method with a mainAlias null.
+ */
+ public EntityQueryProperty() {
+ }
+
+ /**
+ * Constructor with mainAlias.
+ *
+ * @param mainAlias of the entity corresponding to this EntityQueryProperty
+ */
+ public EntityQueryProperty(String mainAlias) {
+ setMainAlias(mainAlias);
+ }
+
+ /**
+ * Constructor with mainAlias and entityClass.
+ *
+ * @param mainAlias alias of the entity corresponding to this
+ * EntityQueryProperty
+ * @param entityClass class of the entity corresponding to this
+ * EntityQueryProperty
+ */
+ public EntityQueryProperty(String mainAlias,
+ Class<? extends TopiaEntity> entityClass) {
+ this(mainAlias);
+ setEntityClass(entityClass);
+ }
+
+ /**
+ * Setter for mainAlias.
+ *
+ * @param mainAlias of the entity corresponding to this EntityQueryProperty
+ */
+ public void setMainAlias(String mainAlias) {
+ this.mainAlias = mainAlias;
+ }
+
+ /**
+ * Setter for propertyJoin.
+ *
+ * @param propertyName name of the property used for join
+ * @see #namePropertyJoin()
+ */
+ public void setPropertyJoin(String propertyName) {
+ this.propertyJoin = propertyName;
+ }
+
+ /**
+ * Setter for entityClass.
+ *
+ * @param entityClass class of the entity corresponding to this
+ * EntityQueryProperty
+ */
+ public void setEntityClass(Class<? extends TopiaEntity> entityClass) {
+ this.entityClass = entityClass;
+ }
+
+ /**
+ * Name the entity as a property for a TopiaQuery. Careful, this name can
+ * be null if no mainAlias is properly set.
+ *
+ * @return the entity name to use in a TopiaQuery
+ */
+ public String name() {
+ return mainAlias;
+ }
+
+ /**
+ * Name a property from the Entity for a TopiaQuery. No matter if the
+ * mainAlias is null or not, the property will be correctly named.
+ *
+ * @param propertyName to named in the TopiaQuery
+ * @return the property name to use in a TopiaQuery
+ */
+ public String nameProperty(String propertyName) {
+ return TopiaQuery.getProperty(mainAlias, propertyName);
+ }
+
+ /**
+ * Name the property Id (TOPIA_ID) of the entity.
+ *
+ * @return the property name to use in a TopiaQuery
+ */
+ public String namePropertyId() {
+ return nameProperty(TopiaEntity.TOPIA_ID);
+ }
+
+ /**
+ * Name the property CreateDate (TOPIA_CREATE_DATE) of the entity.
+ *
+ * @return the property name to use in a TopiaQuery
+ */
+ public String namePropertyCreateDate() {
+ return nameProperty(TopiaEntity.TOPIA_CREATE_DATE);
+ }
+
+ /**
+ * Name the property join. The propertyJoin attribute need to be set to
+ * avoid NullPointerException.
+ *
+ * @return the property name to use in a TopiaQuery
+ */
+ public String namePropertyJoin() {
+ if (propertyJoin == null) {
+ throw new NullPointerException("propertyJoin is not set");
+ }
+ return nameProperty(propertyJoin);
+ }
+
+ /**
+ * Get the entityClass associated with this EntityQueryProperty.
+ * Can be useful in some case, to create other query for exemple or to
+ * use it in {@link TopiaQuery#addFrom(Class)} method.
+ * The entityClass need to be set before calling this method to avoid
+ * NullPointerException.
+ *
+ * @return the entity class corresponding to this EntityQueryProperty.
+ */
+ public Class<? extends TopiaEntity> getEntityClass() {
+ if (entityClass == null) {
+ throw new NullPointerException("entitClass is not set");
+ }
+ return entityClass;
+ }
+
+ /**
+ * Instanciate a new {@link TopiaQuery} based on this EntityQueryProperty.
+ * The entityClass need to be set although the TopiaQuery can't be
+ * instantiate.
+ *
+ * @return a new TopiaQuery with the main entity as the EntityQueryProperty
+ * provides it.
+ */
+ public TopiaQuery newQuery() {
+ return new TopiaQuery(getEntityClass(), name());
+ }
+
+ /**
+ * Simply the main name (mainAlias) of the EntityQueryProperty.
+ *
+ * @return the entity name associated to this EntityQueryProperty
+ */
+ @Override
+ public String toString() {
+ return name();
+ }
+}
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -0,0 +1,57 @@
+
+package org.chorem.pollen;
+
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
+
+/**
+ * PollenQueryBuilder
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class PollenQueryBuilder extends TopiaQueryBuilder {
+
+ public PollenQueryBuilder() {
+ super();
+ }
+
+ public PollenQueryBuilder(TopiaDAO<?> dao) {
+ super(dao);
+ }
+
+ public EntityQueryProperty getFavoriteListProperty(String alias) {
+ return getEntityProperty(FavoriteList.class, alias);
+ }
+
+ public EntityQueryProperty getFavoriteParticipantProperty(
+ String alias) {
+ return getEntityProperty(FavoriteParticipant.class, alias);
+ }
+
+ public TopiaQuery createQueryFindFavoriteParticipantsByFavoriteList(
+ Filter filter) {
+
+ EntityQueryProperty participantProperty =
+ getFavoriteParticipantProperty("P");
+
+ EntityQueryProperty listProperty =
+ getFavoriteListProperty("L");
+
+ listProperty.setPropertyJoin(FavoriteList.FAVORITE_PARTICIPANT);
+
+ createQueryFindElementsByCollection(
+ participantProperty, listProperty, filter);
+
+ return query;
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenQueryBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -0,0 +1,168 @@
+
+package org.chorem.pollen;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.chorem.pollen.bean.Filter;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * TopiaQueryBuilder is used to build a TopiaQuery. <br />
+ * Convention rules :
+ * <ul>
+ * <li>method with prefix {@code prepare} will modify the current query</li>
+ * <li>method with prefix {@code create} will instantiate a new query</li>
+ * </ul>
+ * <br />
+ * To use directly {@code prepare} methods, you have to set the query using
+ * {@link #setQuery(TopiaQuery)} or instantiate the builder with the entity
+ * dao using {@link #TopiaQueryBuilder(TopiaDAO)}, this will create a new query
+ * from dao.
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ */
+public class TopiaQueryBuilder {
+
+ protected TopiaQuery query;
+
+ public TopiaQueryBuilder() {
+ }
+
+ /**
+ * This will create a new TopiaQuery from the {@code dao} in argument.
+ *
+ * @param dao used to create a new TopiaQuery in the builder
+ */
+ public TopiaQueryBuilder(TopiaDAO<?> dao) {
+ setQuery(dao.createQuery());
+ }
+
+ public static TopiaQueryBuilder newInstance() {
+ return new TopiaQueryBuilder();
+ }
+
+ /**
+ * This will create a new TopiaQueryBuilder with a new TopiaQuery from
+ * the {@code dao} in argument.
+ *
+ * @param dao used to create a new TopiaQuery in the builder
+ * @return a new instance of TopiaQueryBuilder
+ */
+ public static TopiaQueryBuilder newInstance(TopiaDAO<?> dao) {
+ return new TopiaQueryBuilder(dao);
+ }
+
+ public void setQuery(TopiaQuery query) {
+ this.query = query;
+ }
+
+ public TopiaQuery getQuery() {
+ return query;
+ }
+
+ public EntityQueryProperty getEntityProperty(String alias) {
+ return new EntityQueryProperty(alias);
+ }
+
+ public EntityQueryProperty getEntityProperty(
+ Class<? extends TopiaEntity> entityClass, String alias) {
+ return new EntityQueryProperty(alias, entityClass);
+ }
+
+ public EntityQueryProperty getMainProperty() {
+ return getEntityProperty(query.getMainAlias());
+ }
+
+ /**
+ * Create a TopiaQuery to find all participants of a list with
+ * {@code filter} constraints (order, limit indexes, listId).
+ *
+ * @param filter used to add constraint in the query
+ * @param element
+ * @param collection
+ * @return the TopiaQuery created
+ * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid)
+ */
+ public TopiaQuery createQueryFindElementsByCollection(
+ EntityQueryProperty element,
+ EntityQueryProperty collection,
+ Filter filter) {
+
+ // Instanciate a new query based on element
+ query = element.newQuery();
+
+ // Add the collection in the From of the query
+ query.addFrom(collection.getEntityClass(), collection.name());
+
+ // Add the link between the collection and the element
+ query.addInElements(element.name(), collection.namePropertyJoin());
+
+ if (filter != null) {
+ // Add constraints from filter, the collection is given to provide
+ // the name of its ID property.
+ prepareQuery(filter, collection);
+ }
+
+ return query;
+ }
+
+ /**
+ * Prepare a query with filter : adding startIndex and endIndex as limit
+ * and orderBy if defined. Need an existing query in builder.
+ *
+ * @param filter Filter to add in the query
+ * @see #prepareQuery(Filter filter, EntityQueryProperty)
+ */
+ public void prepareQuery(Filter filter) {
+ prepareQuery(filter, null);
+ }
+
+ /**
+ * Prepare a query with filter. The {@code reference} is used
+ * to retrieve the name of ID property in case of filter using referenceId.
+ * Need an existing query in builder.
+ *
+ * @param filter Filter to add in the query
+ * @param reference used to filter on referenceId
+ */
+ public void prepareQuery(Filter filter,
+ EntityQueryProperty reference) {
+
+ Integer startIndex = filter.getStartIndex();
+ Integer endIndex = filter.getEndIndex();
+ String orderBy = filter.getOrderBy();
+ String referenceId = filter.getReferenceId();
+
+ // Add limits. Only startIndex do nothing.
+ // startIndex + endIndex provides the limit
+ if (filter.getStartIndex() != null && endIndex != null) {
+ query.setLimit(startIndex, endIndex);
+
+ // endIndex only provides the maxResults wanted
+ } else if (endIndex != null) {
+ query.setMaxResults(endIndex);
+ }
+
+ // Add order to the main entity in the query, splitted by comma
+ if (orderBy != null) {
+ List<String> order = new ArrayList<String>();
+ for (String elmt : orderBy.split(",")) {
+ order.add(getMainProperty().nameProperty(elmt.trim()));
+ }
+ query.addOrder(order.toArray(new String[order.size()]));
+
+ // Default order by creation date
+ } else {
+ query.addOrderDesc(getMainProperty().namePropertyCreateDate());
+ }
+
+ if (StringUtils.isNotEmpty(referenceId) && reference != null) {
+ query.add(reference.namePropertyId(), referenceId);
+ }
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/TopiaQueryBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -3,10 +3,6 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import org.apache.commons.lang.StringUtils;
-import org.chorem.pollen.entity.PropertyNameProviderImpl;
-import org.chorem.pollen.entity.PropertyNameProvider;
-import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaEntity;
/**
@@ -140,49 +136,4 @@
propertyChangeSupport.removePropertyChangeListener(listener);
}
- /**
- * Prepare a query with filter : adding startIndex and endIndex as limit
- * and orderBy if defined.
- *
- * @param query
- * @see #prepareQuery(TopiaQuery, PropertyUid)
- */
- public void prepareQuery(TopiaQuery query) {
- prepareQuery(query, null);
- }
-
- /**
- * Prepare a query with filter. The {@code property} is used
- * to retrieve the name of UID property in case of filter using uid.
- *
- * @param query to prepare
- * @param property to provide UID property name (using uid filter)
- */
- public void prepareQuery(TopiaQuery query, PropertyNameProvider property) {
- // Add limits. Only startIndex do nothing.
- // startIndex + endIndex provides the limit
- if (startIndex != null && endIndex != null) {
- query.setLimit(startIndex, endIndex);
-
- // endIndex only provides the maxResults wanted
- } else if (endIndex != null) {
- query.setMaxResults(endIndex);
- }
-
- if (StringUtils.isNotEmpty(referenceId) && property != null) {
- query.add(property.namePropertyId(), referenceId);
- }
-
- // Add order to the query, splitted by comma and trimmed using
- // {@link StringUtils#stripAll(String[])}
- if (orderBy != null) {
- String[] order = StringUtils.stripAll(orderBy.split(","));
- query.addOrder(order);
-
- // Default order by creation date
- } else {
- query.addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE);
- }
- }
-
}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,23 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-/**
- * FavoriteListProperty
- *
- * Created: 28 avr. 2010
- *
- * @author fdesbois
- */
-public class FavoriteListProperty extends PropertyNameProviderImpl
- implements ParticipantListProperty {
-
- public FavoriteListProperty(String mainAlias) {
- super(FavoriteList.class, mainAlias);
- }
-
- @Override
- public String namePropertyParticipant() {
- return nameProperty(FavoriteList.FAVORITE_PARTICIPANT);
- }
-
-}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,19 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * FavoriteParticipant
- *
- * Created: 28 avr. 2010
- *
- * @author fdesbois
- */
-public class FavoriteParticipantProperty extends PropertyNameProviderImpl
- implements ParticipantProperty {
-
- public FavoriteParticipantProperty(String mainAlias) {
- super(FavoriteParticipant.class, mainAlias);
- }
-}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,14 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-/**
- * ParticipantListProperty
- *
- * Created: 28 avr. 2010
- *
- * @author fdesbois
- */
-public interface ParticipantListProperty extends PropertyNameProvider {
-
- String namePropertyParticipant();
-}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,13 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-/**
- * ParticipantProperty
- *
- * Created: 28 avr. 2010
- *
- * @author fdesbois
- */
-public interface ParticipantProperty extends PropertyNameProvider {
-
-}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,21 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-/**
- * PollAccountProperty
- *
- * Created: 27 avr. 2010
- *
- * @author fdesbois
- * @since 2.0
- */
-public class PollAccountProperty extends PropertyNameProviderImpl {
-
- public PollAccountProperty(String mainAlias) {
- super(PollAccount.class, mainAlias);
- }
-
- public String namePropertyChild() {
- return nameProperty(PollAccount.CHILD);
- }
-}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,26 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * PropertyUid
- *
- * Created: 27 avr. 2010
- *
- * @author fdesbois
- * @since 2.0
- */
-public interface PropertyNameProvider {
-
- String name();
-
- String namePropertyId();
-
- String nameProperty(String propertyName);
-
- Class<? extends TopiaEntity> getEntityClass();
-
- TopiaQuery newQuery();
-}
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -1,110 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-import org.nuiton.topia.framework.*;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * EntityProperty is used to simplify property concatenation in TopiaQuery.
- * The usage is simple, the EntityProperty need a mainAlias which represents
- * the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
- * is called to retrieve the correct property name used for the query.
- * Exemple :
- * <pre>
- * BoatDAO dao = AppDAOHelper.getBoatDAO(topiaContext);
- *
- * // Property used in the query
- * EntityProperty boatProperty = new EntityProperty("B");
- *
- * // It's better to create the query with the property name
- * TopiaQuery query = dao.createQuery(boatProperty.name());
- *
- * // The property NAME of the boat need to be find equals to "ULUBERLU"
- * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU");
- *
- * // It's avoid doing this :
- * query.add("B." + Boat.NAME, "ULUBERLU");
- * </pre>
- * This last exemple is a simple case but for a more complex query with more
- * than one entity, it's obvious that concatenation using + is not a good
- * practice.<br />
- * You can also use this class as a superclass for each entity, ex :
- * <pre>
- * public class BoatProperty extends EntityProperty {
- *
- * public BoatProperty(String mainAlias) {
- * super(mainAlias);
- * }
- *
- * public String namePropertyName() {
- * return nameProperty(Boat.NAME);
- * }
- * }
- * </pre>
- *
- * Created: 14 avr. 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- */
-public class PropertyNameProviderImpl implements PropertyNameProvider {
-
- /** alias of the entity **/
- protected String mainAlias;
-
- protected Class<? extends TopiaEntity> entityClass;
-
- public PropertyNameProviderImpl(Class<? extends TopiaEntity> entityClass,
- String mainAlias) {
- this.mainAlias = mainAlias;
- this.entityClass = entityClass;
- }
-
- public void setMainAlias(String mainAlias) {
- this.mainAlias = mainAlias;
- }
-
- public void setEntityClass(Class<? extends TopiaEntity> entityClass) {
- this.entityClass = entityClass;
- }
-
- /**
- * Name the entity as a property for a TopiaQuery.
- *
- * @return the entity name used as a TopiaQuery property
- */
- @Override
- public String name() {
- return mainAlias;
- }
-
- /**
- * Name a property from the Entity for a TopiaQuery.
- *
- * @param propertyName to named in the TopiaQuery
- * @return the property name used as a TopiaQuery property
- */
- @Override
- public String nameProperty(String propertyName) {
- return TopiaQuery.getProperty(mainAlias, propertyName);
- }
-
- @Override
- public String namePropertyId() {
- return nameProperty(TopiaEntity.TOPIA_ID);
- }
-
- @Override
- public Class<? extends TopiaEntity> getEntityClass() {
- return entityClass;
- }
-
- @Override
- public TopiaQuery newQuery() {
- return new TopiaQuery(getEntityClass(), name());
- }
-
- @Override
- public String toString() {
- return name();
- }
-}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -16,14 +16,14 @@
import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.entity.FavoriteListDAO;
import org.chorem.pollen.entity.FavoriteListImpl;
-import org.chorem.pollen.entity.FavoriteListProperty;
import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.FavoriteParticipantDAO;
import org.chorem.pollen.entity.FavoriteParticipantImpl;
-import org.chorem.pollen.entity.FavoriteParticipantProperty;
-import org.chorem.pollen.entity.ParticipantListProperty;
-import org.chorem.pollen.entity.ParticipantProperty;
import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.EntityQueryProperty;
+import org.chorem.pollen.PollenQueryBuilder;
+import org.chorem.pollen.TopiaQueryBuilder;
+import org.chorem.pollen.entity.PollAccountDAO;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
@@ -280,12 +280,12 @@
Filter filter) throws TopiaException {
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
- TopiaQuery query = dao.createQuery();
- filter.prepareQuery(query);
+ TopiaQueryBuilder builder = new TopiaQueryBuilder(dao);
+ builder.prepareQuery(filter);
- Map<String, UserAccount> results = dao.findAllMappedByQuery(query,
- UserAccount.LOGIN, String.class);
+ Map<String, UserAccount> results = dao.findAllMappedByQuery(
+ builder.getQuery(), UserAccount.LOGIN, String.class);
return results;
}
@@ -294,46 +294,14 @@
Filter filter) throws TopiaException {
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
- TopiaQuery query = dao.createQuery();
- filter.prepareQuery(query);
+ TopiaQueryBuilder builder = new TopiaQueryBuilder(dao);
+ builder.prepareQuery(filter);
- int result = query.executeCount();
+ int result = builder.getQuery().executeCount();
return result;
}
- /**
- * Create a TopiaQuery to find all participants of a list with
- * {@code filter} constraints (order, limit indexes, listId).
- *
- * @param filter used to add constraint in the query
- * @param participantPropertyProvider
- * @param listPropertyProvider
- * @return the TopiaQuery created
- * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid)
- */
- protected TopiaQuery createQueryFindParticipantsByList(
- Filter filter,
- ParticipantProperty participantPropertyProvider,
- ParticipantListProperty listPropertyProvider) {
-
- // Instanciate a new query based on participant
- TopiaQuery query = participantPropertyProvider.newQuery();
-
- // Add the list in the From of the query
- query.addFrom(listPropertyProvider.getEntityClass(), listPropertyProvider.name());
-
- // Add the link between the list and the participant
- query.addInElements(participantPropertyProvider.name(),
- listPropertyProvider.namePropertyParticipant());
-
- // Add constraints from filter, the listProperty is given to provide
- // the name of its ID property.
- filter.prepareQuery(query, listPropertyProvider);
-
- return query;
- }
-
@Override
protected FavoriteList executeGetNewFavoriteList(UserAccount user) {
FavoriteList result = new FavoriteListImpl();
@@ -345,31 +313,31 @@
protected void executeCreateFavoriteList(TopiaContext transaction,
FavoriteList list) throws TopiaException, PollenBusinessException {
-// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
-//
-// // check favoriteList name exist for user
-// UserAccount user = list.getUserAccount();
-// int count = dao.createQuery().
-// add(PollAccount.LIST, true).
-// add(PollAccount.USER_ACCOUNT, user).
-// add(PollAccount.NAME, list.getName()).
-// executeCount();
-// // existing list found
-// if (count > 0) {
-// throw new PollenBusinessException(
-// PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
-// list.getName(), user.getDisplayName());
-// }
-//
-// // Create unique Id for the new List
-// String UId = context.createPollenUrlId();
-// PollAccount newList = dao.create(UId);
-// BinderProvider.getBinder(PollAccount.class,
-// BINDER_CONTEXT_FAVORITE_LIST).
-// copy(list, newList);
-// dao.update(newList);
-//
-// transaction.commitTransaction();
+ FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
+
+ // check favoriteList name exist for user
+ UserAccount user = list.getUserAccount();
+ int count = dao.createQuery().
+ add(PollAccount.LIST, true).
+ add(PollAccount.USER_ACCOUNT, user).
+ add(PollAccount.NAME, list.getName()).
+ executeCount();
+ // existing list found
+ if (count > 0) {
+ throw new PollenBusinessException(
+ PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
+ list.getName(), user.getDisplayName());
+ }
+
+ // Create unique Id for the new List
+ String UId = context.createPollenUrlId();
+ FavoriteList newList = dao.create(UId);
+ BinderProvider.getBinder(FavoriteList.class,
+ BINDER_CONTEXT_FAVORITE_LIST).
+ copy(list, newList);
+ dao.update(newList);
+
+ transaction.commitTransaction();
}
@Override
@@ -420,17 +388,14 @@
@Override
protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants(
TopiaContext transaction, Filter filter) throws TopiaException {
-
- FavoriteParticipantDAO dao =
- PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- ParticipantProperty participantProperty =
- new FavoriteParticipantProperty("P");
+ PollenQueryBuilder builder = new PollenQueryBuilder();
- ParticipantListProperty listProperty = new FavoriteListProperty("L");
+ TopiaQuery query =
+ builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
- TopiaQuery query = createQueryFindParticipantsByList(filter,
- participantProperty, listProperty);
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
Map<String, FavoriteParticipant> results = dao.findAllMappedByQuery(
query, FavoriteParticipant.EMAIL, String.class);
@@ -441,14 +406,14 @@
@Override
protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
Filter filter) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
-// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
-//
-// TopiaQuery query = createQueryFindAccountsByList(dao, filter);
-//
-// int result = query.executeCount();
-// return result;
+ PollenQueryBuilder builder = new PollenQueryBuilder();
+
+ TopiaQuery query =
+ builder.createQueryFindFavoriteParticipantsByFavoriteList(filter);
+
+ int result = query.executeCount(transaction);
+ return result;
}
}
Added: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java 2010-04-28 14:05:02 UTC (rev 2978)
@@ -0,0 +1,121 @@
+
+package org.chorem.pollen;
+
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.UserAccount;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ *
+ * @author fdesbois
+ */
+public class TopiaQueryBuilderTest {
+
+ private static final Log log =
+ LogFactory.getLog(TopiaQueryBuilderTest.class);
+
+ /**
+ * Test of prepareQuery method, of class Filter.
+ */
+ @Test
+ public void testPrepareQueryForFilter() {
+ log.info("testPrepareQueryForFilter");
+
+ Filter filter = new Filter();
+ filter.setStartIndex(1);
+ filter.setEndIndex(40);
+ filter.setOrderBy(UserAccount.LOGIN);
+
+ TopiaQueryBuilder builder = new TopiaQueryBuilder();
+ builder.setQuery(new TopiaQuery(UserAccount.class));
+ builder.prepareQuery(filter);
+
+ log.debug("Query : " + builder.getQuery());
+
+ Assert.assertEquals(builder.getQuery().fullQuery(),
+ "FROM " + UserAccount.class.getName() +
+ " ORDER BY " + UserAccount.LOGIN);
+
+ filter.setOrderBy(null);
+
+ builder.setQuery(new TopiaQuery(UserAccount.class));
+ builder.prepareQuery(filter);
+
+ log.debug("Query : " + builder.getQuery());
+
+ Assert.assertEquals(builder.getQuery().fullQuery(),
+ "FROM " + UserAccount.class.getName() +
+ " ORDER BY " + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
+
+ }
+
+ @Test
+ public void testCreateQueryFindElementsByCollection() throws IOException {
+
+ TopiaQueryBuilder builder = new TopiaQueryBuilder();
+
+ Filter filter = new Filter();
+ filter.setStartIndex(1);
+ filter.setEndIndex(40);
+ filter.setOrderBy(FavoriteParticipant.NAME);
+
+ EntityQueryProperty participantPropertyProvider =
+ builder.getEntityProperty(FavoriteParticipant.class, "P");
+
+ EntityQueryProperty listPropertyProvider =
+ builder.getEntityProperty(FavoriteList.class, "L");
+ listPropertyProvider.setPropertyJoin(FavoriteList.FAVORITE_PARTICIPANT);
+
+ log.info("test1 : orderBy FavoriteParticipant name");
+ TopiaQuery result = builder.createQueryFindElementsByCollection(
+ participantPropertyProvider, listPropertyProvider, filter);
+
+ log.debug("Query : " + result);
+
+ Assert.assertEquals(result.fullQuery(),
+ "SELECT P FROM " + FavoriteParticipant.class.getName() + " P, "
+ + FavoriteList.class.getName() + " L" +
+ " WHERE P IN elements (L." + FavoriteList.FAVORITE_PARTICIPANT +
+ ") ORDER BY P." + FavoriteParticipant.NAME);
+
+ log.info("test2 : orderBy not set (default to topiaCreateDate desc)");
+ filter.setOrderBy(null);
+
+ result = builder.createQueryFindElementsByCollection(
+ participantPropertyProvider, listPropertyProvider, filter);
+
+ log.debug("Query : " + result);
+
+ Assert.assertEquals(result.fullQuery(),
+ "SELECT P FROM " + FavoriteParticipant.class.getName() + " P, "
+ + FavoriteList.class.getName() + " L" +
+ " WHERE P IN elements (L." + FavoriteList.FAVORITE_PARTICIPANT +
+ ") ORDER BY P." + TopiaEntity.TOPIA_CREATE_DATE + " DESC");
+
+ log.info("test3 : orderBy name and email desc");
+ String orderBy = FavoriteParticipant.NAME + ", " + FavoriteParticipant.EMAIL + " desc";
+ filter.setOrderBy(orderBy);
+
+ result = builder.createQueryFindElementsByCollection(
+ participantPropertyProvider, listPropertyProvider, filter);
+
+ log.debug("Query : " + result);
+
+ Assert.assertEquals(result.fullQuery(),
+ "SELECT P FROM " + FavoriteParticipant.class.getName() + " P, "
+ + FavoriteList.class.getName() + " L" +
+ " WHERE P IN elements (L." + FavoriteList.FAVORITE_PARTICIPANT +
+ ") ORDER BY P." + FavoriteParticipant.NAME + ", P." +
+ FavoriteParticipant.EMAIL + " desc");
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/TopiaQueryBuilderTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
1
0
Author: fdesbois
Date: 2010-04-28 10:47:44 +0200 (Wed, 28 Apr 2010)
New Revision: 2977
Log:
- Change in model : Add two entities FavoriteList and FavoriteParticipant + add contracts to identify them as ParticipantList and Participant like PollAccount.
- Some trials on PropertyNameProvider to find the best way to use it
- Use transformers JavaInterfaceTransformer from EUGene and BinderHelperTransformer from ToPIA
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
Removed:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java
Modified:
trunk/pollen-business/pom.xml
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/pom.xml
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.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/UserListsUpdate.tml
trunk/pom.xml
Modified: trunk/pollen-business/pom.xml
===================================================================
--- trunk/pollen-business/pom.xml 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/pom.xml 2010-04-28 08:47:44 UTC (rev 2977)
@@ -114,7 +114,9 @@
<templates>
org.nuiton.topia.generator.TopiaMetaTransformer,
org.nuiton.topia.generator.ServiceTransformer,
- org.nuiton.topia.generator.BeanTransformer
+ org.nuiton.eugene.java.JavaInterfaceTransformer,
+ org.nuiton.eugene.java.JavaBeanTransformer,
+ org.nuiton.topia.generator.BinderHelperTransformer
</templates>
</configuration>
<goals>
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -3,7 +3,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.Date;
-import java.util.Locale;
import java.util.Properties;
import java.util.UUID;
import org.apache.commons.logging.Log;
@@ -20,7 +19,10 @@
import static org.nuiton.i18n.I18n.n_;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.TopiaEntityBinder;
import org.nuiton.util.StringUtil;
+import org.nuiton.util.beans.BinderBuilder;
/**
* PollenContext
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -4,8 +4,8 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.apache.commons.lang.StringUtils;
-import org.chorem.pollen.entity.EntityProperty;
-import org.chorem.pollen.entity.PropertyUid;
+import org.chorem.pollen.entity.PropertyNameProviderImpl;
+import org.chorem.pollen.entity.PropertyNameProvider;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -25,7 +25,7 @@
protected String orderBy;
- protected String uid;
+ protected String referenceId;
private PropertyChangeSupport propertyChangeSupport =
new PropertyChangeSupport(this);
@@ -36,7 +36,7 @@
public static final String PROPERTY_ORDER_BY = "orderBy";
- public static final String PROP_UID = "uid";
+ public static final String PROP_REFERENCE_ID = "referenceId";
/**
* Get the value of startIndex
@@ -55,7 +55,8 @@
public void setStartIndex(Integer startIndex) {
Integer oldStartIndex = this.startIndex;
this.startIndex = startIndex;
- propertyChangeSupport.firePropertyChange(PROPERTY_START_INDEX, oldStartIndex, startIndex);
+ propertyChangeSupport.firePropertyChange(PROPERTY_START_INDEX,
+ oldStartIndex, startIndex);
}
/**
@@ -75,7 +76,8 @@
public void setOrderBy(String orderBy) {
String oldOrderBy = this.orderBy;
this.orderBy = orderBy;
- propertyChangeSupport.firePropertyChange(PROPERTY_ORDER_BY, oldOrderBy, orderBy);
+ propertyChangeSupport.firePropertyChange(PROPERTY_ORDER_BY,
+ oldOrderBy, orderBy);
}
/**
@@ -95,27 +97,29 @@
public void setEndIndex(Integer endIndex) {
Integer oldEndIndex = this.endIndex;
this.endIndex = endIndex;
- propertyChangeSupport.firePropertyChange(PROPERTY_END_INDEX, oldEndIndex, endIndex);
+ propertyChangeSupport.firePropertyChange(PROPERTY_END_INDEX,
+ oldEndIndex, endIndex);
}
/**
- * Get the value of uid
+ * Get the value of referenceId
*
- * @return the value of uid
+ * @return the value of referenceId
*/
- public String getUid() {
- return uid;
+ public String getReferenceId() {
+ return referenceId;
}
/**
- * Set the value of uid
+ * Set the value of referenceId
*
- * @param uid new value of uid
+ * @param entity
*/
- public void setUid(String uid) {
- String oldUid = this.uid;
- this.uid = uid;
- propertyChangeSupport.firePropertyChange(PROP_UID, oldUid, uid);
+ public void setReference(TopiaEntity entity) {
+ String oldReferenceId = this.referenceId;
+ this.referenceId = entity.getTopiaId();
+ propertyChangeSupport.firePropertyChange(PROP_REFERENCE_ID,
+ oldReferenceId, referenceId);
}
/**
@@ -152,10 +156,9 @@
* to retrieve the name of UID property in case of filter using uid.
*
* @param query to prepare
- * @param ordered if order is needed (using orderBy filter)
* @param property to provide UID property name (using uid filter)
*/
- public void prepareQuery(TopiaQuery query, PropertyUid property) {
+ public void prepareQuery(TopiaQuery query, PropertyNameProvider property) {
// Add limits. Only startIndex do nothing.
// startIndex + endIndex provides the limit
if (startIndex != null && endIndex != null) {
@@ -166,8 +169,8 @@
query.setMaxResults(endIndex);
}
- if (StringUtils.isNotEmpty(uid) && property != null) {
- query.add(property.namePropertyUid(), uid);
+ if (StringUtils.isNotEmpty(referenceId) && property != null) {
+ query.add(property.namePropertyId(), referenceId);
}
// Add order to the query, splitted by comma and trimmed using
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -1,80 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-import org.nuiton.topia.framework.*;
-
-/**
- * EntityProperty is used to simplify property concatenation in TopiaQuery.
- * The usage is simple, the EntityProperty need a mainAlias which represents
- * the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
- * is called to retrieve the correct property name used for the query.
- * Exemple :
- * <pre>
- * BoatDAO dao = AppDAOHelper.getBoatDAO(topiaContext);
- *
- * // Property used in the query
- * EntityProperty boatProperty = new EntityProperty("B");
- *
- * // It's better to create the query with the property name
- * TopiaQuery query = dao.createQuery(boatProperty.name());
- *
- * // The property NAME of the boat need to be find equals to "ULUBERLU"
- * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU");
- *
- * // It's avoid doing this :
- * query.add("B." + Boat.NAME, "ULUBERLU");
- * </pre>
- * This last exemple is a simple case but for a more complex query with more
- * than one entity, it's obvious that concatenation using + is not a good
- * practice.<br />
- * You can also use this class as a superclass for each entity, ex :
- * <pre>
- * public class BoatProperty extends EntityProperty {
- *
- * public BoatProperty(String mainAlias) {
- * super(mainAlias);
- * }
- *
- * public String namePropertyName() {
- * return nameProperty(Boat.NAME);
- * }
- * }
- * </pre>
- *
- * Created: 14 avr. 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- */
-public class EntityProperty {
-
- /** alias of the entity **/
- protected String mainAlias;
-
- public EntityProperty(String mainAlias) {
- this.mainAlias = mainAlias;
- }
-
- /**
- * Name the entity as a property for a TopiaQuery.
- *
- * @return the entity name used as a TopiaQuery property
- */
- public String name() {
- return mainAlias;
- }
-
- /**
- * Name a property from the Entity for a TopiaQuery.
- *
- * @param propertyName to named in the TopiaQuery
- * @return the property name used as a TopiaQuery property
- */
- public String nameProperty(String propertyName) {
- return TopiaQuery.getProperty(mainAlias, propertyName);
- }
-
- @Override
- public String toString() {
- return name();
- }
-}
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,23 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * FavoriteListProperty
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois
+ */
+public class FavoriteListProperty extends PropertyNameProviderImpl
+ implements ParticipantListProperty {
+
+ public FavoriteListProperty(String mainAlias) {
+ super(FavoriteList.class, mainAlias);
+ }
+
+ @Override
+ public String namePropertyParticipant() {
+ return nameProperty(FavoriteList.FAVORITE_PARTICIPANT);
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteListProperty.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,19 @@
+
+package org.chorem.pollen.entity;
+
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * FavoriteParticipant
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois
+ */
+public class FavoriteParticipantProperty extends PropertyNameProviderImpl
+ implements ParticipantProperty {
+
+ public FavoriteParticipantProperty(String mainAlias) {
+ super(FavoriteParticipant.class, mainAlias);
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/FavoriteParticipantProperty.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,14 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * ParticipantListProperty
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois
+ */
+public interface ParticipantListProperty extends PropertyNameProvider {
+
+ String namePropertyParticipant();
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantListProperty.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,13 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * ParticipantProperty
+ *
+ * Created: 28 avr. 2010
+ *
+ * @author fdesbois
+ */
+public interface ParticipantProperty extends PropertyNameProvider {
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ParticipantProperty.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -1,27 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-/**
- * PollAccountImpl
- *
- * Created: 26 avr. 2010
- *
- * @author fdesbois
- */
-public class PollAccountImpl extends PollAccountAbstract {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public PollAccount getChildByUId(String UId) {
- if (child != null) {
- for (PollAccount account : child) {
- if (account.getUid().equals(UId)) {
- return account;
- }
- }
- }
- return null;
- }
-
-}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -9,19 +9,13 @@
* @author fdesbois
* @since 2.0
*/
-public class PollAccountProperty extends EntityProperty implements PropertyUid {
+public class PollAccountProperty extends PropertyNameProviderImpl {
public PollAccountProperty(String mainAlias) {
- super(mainAlias);
+ super(PollAccount.class, mainAlias);
}
- @Override
- public String namePropertyUid() {
- return nameProperty(PollAccount.UID);
- }
-
public String namePropertyChild() {
return nameProperty(PollAccount.CHILD);
}
-
}
Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java (from rev 2976, trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java)
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,26 @@
+
+package org.chorem.pollen.entity;
+
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * PropertyUid
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ * @since 2.0
+ */
+public interface PropertyNameProvider {
+
+ String name();
+
+ String namePropertyId();
+
+ String nameProperty(String propertyName);
+
+ Class<? extends TopiaEntity> getEntityClass();
+
+ TopiaQuery newQuery();
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProvider.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java (from rev 2976, trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java)
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,110 @@
+
+package org.chorem.pollen.entity;
+
+import org.nuiton.topia.framework.*;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * EntityProperty is used to simplify property concatenation in TopiaQuery.
+ * The usage is simple, the EntityProperty need a mainAlias which represents
+ * the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
+ * is called to retrieve the correct property name used for the query.
+ * Exemple :
+ * <pre>
+ * BoatDAO dao = AppDAOHelper.getBoatDAO(topiaContext);
+ *
+ * // Property used in the query
+ * EntityProperty boatProperty = new EntityProperty("B");
+ *
+ * // It's better to create the query with the property name
+ * TopiaQuery query = dao.createQuery(boatProperty.name());
+ *
+ * // The property NAME of the boat need to be find equals to "ULUBERLU"
+ * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU");
+ *
+ * // It's avoid doing this :
+ * query.add("B." + Boat.NAME, "ULUBERLU");
+ * </pre>
+ * This last exemple is a simple case but for a more complex query with more
+ * than one entity, it's obvious that concatenation using + is not a good
+ * practice.<br />
+ * You can also use this class as a superclass for each entity, ex :
+ * <pre>
+ * public class BoatProperty extends EntityProperty {
+ *
+ * public BoatProperty(String mainAlias) {
+ * super(mainAlias);
+ * }
+ *
+ * public String namePropertyName() {
+ * return nameProperty(Boat.NAME);
+ * }
+ * }
+ * </pre>
+ *
+ * Created: 14 avr. 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ */
+public class PropertyNameProviderImpl implements PropertyNameProvider {
+
+ /** alias of the entity **/
+ protected String mainAlias;
+
+ protected Class<? extends TopiaEntity> entityClass;
+
+ public PropertyNameProviderImpl(Class<? extends TopiaEntity> entityClass,
+ String mainAlias) {
+ this.mainAlias = mainAlias;
+ this.entityClass = entityClass;
+ }
+
+ public void setMainAlias(String mainAlias) {
+ this.mainAlias = mainAlias;
+ }
+
+ public void setEntityClass(Class<? extends TopiaEntity> entityClass) {
+ this.entityClass = entityClass;
+ }
+
+ /**
+ * Name the entity as a property for a TopiaQuery.
+ *
+ * @return the entity name used as a TopiaQuery property
+ */
+ @Override
+ public String name() {
+ return mainAlias;
+ }
+
+ /**
+ * Name a property from the Entity for a TopiaQuery.
+ *
+ * @param propertyName to named in the TopiaQuery
+ * @return the property name used as a TopiaQuery property
+ */
+ @Override
+ public String nameProperty(String propertyName) {
+ return TopiaQuery.getProperty(mainAlias, propertyName);
+ }
+
+ @Override
+ public String namePropertyId() {
+ return nameProperty(TopiaEntity.TOPIA_ID);
+ }
+
+ @Override
+ public Class<? extends TopiaEntity> getEntityClass() {
+ return entityClass;
+ }
+
+ @Override
+ public TopiaQuery newQuery() {
+ return new TopiaQuery(getEntityClass(), name());
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyNameProviderImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Deleted: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -1,15 +0,0 @@
-
-package org.chorem.pollen.entity;
-
-/**
- * PropertyUid
- *
- * Created: 27 avr. 2010
- *
- * @author fdesbois
- * @since 2.0
- */
-public interface PropertyUid {
-
- String namePropertyUid();
-}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/UserAccountImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -40,13 +40,7 @@
this.newPassword = newPassword;
}
-
@Override
- public void addFavoriteList(PollAccount list) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
public String getDisplayName() {
String name = "";
String separator = "";
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -6,16 +6,24 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.PollenBinderHelper;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenDAOHelper;
import org.chorem.pollen.PollenException;
import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteListDAO;
+import org.chorem.pollen.entity.FavoriteListImpl;
+import org.chorem.pollen.entity.FavoriteListProperty;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.FavoriteParticipantDAO;
+import org.chorem.pollen.entity.FavoriteParticipantImpl;
+import org.chorem.pollen.entity.FavoriteParticipantProperty;
+import org.chorem.pollen.entity.ParticipantListProperty;
+import org.chorem.pollen.entity.ParticipantProperty;
import org.chorem.pollen.entity.PollAccount;
-import org.chorem.pollen.entity.PollAccountDAO;
-import org.chorem.pollen.entity.PollAccountImpl;
-import org.chorem.pollen.entity.PollAccountProperty;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
@@ -23,6 +31,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.topia.persistence.util.TopiaEntityBinder;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderBuilder;
import org.nuiton.util.beans.BinderProvider;
@@ -48,7 +57,6 @@
public void setContext(PollenContext context) {
this.context = context;
- prepareUserAccountBinder();
prepareFavoriteListBinder();
}
@@ -68,14 +76,6 @@
context.closeTransaction(transaction);
}
- protected void prepareUserAccountBinder() {
- BinderBuilder builder = new BinderBuilder(UserAccount.class,
- UserAccount.ADMIN,
- UserAccount.FIRST_NAME,
- UserAccount.LAST_NAME);
- BinderProvider.registerBinder(builder);
- }
-
protected void prepareFavoriteListBinder() {
BinderBuilder builder = new BinderBuilder(PollAccount.class,
PollAccount.LIST,
@@ -93,7 +93,13 @@
* @see org.nuiton.util.beans.Binder#copy(Object, Object, String...)
*/
protected void copyUserAccount(UserAccount source, UserAccount destination) {
- BinderProvider.getBinder(UserAccount.class).copy(source, destination);
+ TopiaEntityBinder<UserAccount> binder =
+ PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class);
+
+ binder.copy(source, destination, UserAccount.ADMIN,
+ UserAccount.FIRST_NAME,
+ UserAccount.LAST_NAME);
+ // Don't keep case for email
destination.setEmail(StringUtils.lowerCase(source.getEmail()));
// Manage new password if needed
String password = source.getNewPassword();
@@ -296,134 +302,153 @@
return result;
}
+ /**
+ * Create a TopiaQuery to find all participants of a list with
+ * {@code filter} constraints (order, limit indexes, listId).
+ *
+ * @param filter used to add constraint in the query
+ * @param participantPropertyProvider
+ * @param listPropertyProvider
+ * @return the TopiaQuery created
+ * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid)
+ */
+ protected TopiaQuery createQueryFindParticipantsByList(
+ Filter filter,
+ ParticipantProperty participantPropertyProvider,
+ ParticipantListProperty listPropertyProvider) {
+
+ // Instanciate a new query based on participant
+ TopiaQuery query = participantPropertyProvider.newQuery();
+
+ // Add the list in the From of the query
+ query.addFrom(listPropertyProvider.getEntityClass(), listPropertyProvider.name());
+
+ // Add the link between the list and the participant
+ query.addInElements(participantPropertyProvider.name(),
+ listPropertyProvider.namePropertyParticipant());
+
+ // Add constraints from filter, the listProperty is given to provide
+ // the name of its ID property.
+ filter.prepareQuery(query, listPropertyProvider);
+
+ return query;
+ }
+
@Override
- protected PollAccount executeGetNewList(UserAccount user) {
- PollAccount result = new PollAccountImpl();
- result.setList(true);
+ protected FavoriteList executeGetNewFavoriteList(UserAccount user) {
+ FavoriteList result = new FavoriteListImpl();
result.setUserAccount(user);
return result;
}
@Override
protected void executeCreateFavoriteList(TopiaContext transaction,
- PollAccount list) throws TopiaException, PollenBusinessException {
+ FavoriteList list) throws TopiaException, PollenBusinessException {
- PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
-
- // check favoriteList name exist for user
- UserAccount user = list.getUserAccount();
- int count = dao.createQuery().
- add(PollAccount.LIST, true).
- add(PollAccount.USER_ACCOUNT, user).
- add(PollAccount.NAME, list.getName()).
- executeCount();
- // existing list found
- if (count > 0) {
- throw new PollenBusinessException(
- PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
- list.getName(), user.getDisplayName());
- }
-
- // Create unique Id for the new List
- String UId = context.createPollenUrlId();
- PollAccount newList = dao.create(UId);
- BinderProvider.getBinder(PollAccount.class,
- BINDER_CONTEXT_FAVORITE_LIST).
- copy(list, newList);
- dao.update(newList);
-
- transaction.commitTransaction();
+// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+//
+// // check favoriteList name exist for user
+// UserAccount user = list.getUserAccount();
+// int count = dao.createQuery().
+// add(PollAccount.LIST, true).
+// add(PollAccount.USER_ACCOUNT, user).
+// add(PollAccount.NAME, list.getName()).
+// executeCount();
+// // existing list found
+// if (count > 0) {
+// throw new PollenBusinessException(
+// PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
+// list.getName(), user.getDisplayName());
+// }
+//
+// // Create unique Id for the new List
+// String UId = context.createPollenUrlId();
+// PollAccount newList = dao.create(UId);
+// BinderProvider.getBinder(PollAccount.class,
+// BINDER_CONTEXT_FAVORITE_LIST).
+// copy(list, newList);
+// dao.update(newList);
+//
+// transaction.commitTransaction();
}
@Override
- protected void executeDeleteList(TopiaContext transaction,
- PollAccount list) throws TopiaException {
+ protected void executeDeleteFavoriteList(TopiaContext transaction,
+ FavoriteList list) throws TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- protected List<PollAccount> executeGetFavoriteLists(
+ protected List<FavoriteList> executeGetFavoriteLists(
TopiaContext transaction, UserAccount user) throws TopiaException {
- PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+ FavoriteListDAO dao = PollenDAOHelper.getFavoriteListDAO(transaction);
- TopiaQuery query = dao.createQuery().
- add(PollAccount.LIST, true).
- add(PollAccount.USER_ACCOUNT, user);
+ List<FavoriteList> results = dao.findAllByUserAccount(user);
- List<PollAccount> results = dao.findAllByQuery(query);
-
return results;
}
@Override
- protected PollAccount executeGetNewAccount(TopiaContext transaction)
+ protected FavoriteParticipant executeGetNewFavoriteParticipant(
+ TopiaContext transaction, FavoriteList list)
throws TopiaException {
- PollAccount result = new PollAccountImpl();
+ FavoriteParticipant result = new FavoriteParticipantImpl();
+ result.setFavoriteList(list);
return result;
}
@Override
- protected PollAccount executeGetPerson(TopiaContext transaction,
- String accountUId)
+ protected void executeCreateFavoriteParticipant(TopiaContext transaction,
+ FavoriteParticipant participant)
throws PollenBusinessException, TopiaException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- protected Map<String, PollAccount> executeGetAccounts(
+ protected void executeDeleteFavoriteParticipant(TopiaContext transaction,
+ FavoriteParticipant participant) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ protected void executeUpdateFavoriteParticipant(TopiaContext transaction,
+ FavoriteParticipant participant) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ protected Map<String, FavoriteParticipant> executeGetFavoriteParticipants(
TopiaContext transaction, Filter filter) throws TopiaException {
+
+ FavoriteParticipantDAO dao =
+ PollenDAOHelper.getFavoriteParticipantDAO(transaction);
- PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+ ParticipantProperty participantProperty =
+ new FavoriteParticipantProperty("P");
- TopiaQuery query = createQueryFindAccountsByList(dao, filter);
+ ParticipantListProperty listProperty = new FavoriteListProperty("L");
- Map<String, PollAccount> results = dao.findAllMappedByQuery(query,
- PollAccount.UID, String.class);
+ TopiaQuery query = createQueryFindParticipantsByList(filter,
+ participantProperty, listProperty);
+ Map<String, FavoriteParticipant> results = dao.findAllMappedByQuery(
+ query, FavoriteParticipant.EMAIL, String.class);
+
return results;
}
@Override
- protected int executeGetNbAccounts(TopiaContext transaction,
+ protected int executeGetNbFavoriteParticipants(TopiaContext transaction,
Filter filter) throws TopiaException {
+ throw new UnsupportedOperationException("Not supported yet.");
- PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
-
- TopiaQuery query = createQueryFindAccountsByList(dao, filter);
-
- int result = query.executeCount();
- return result;
+// PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+//
+// TopiaQuery query = createQueryFindAccountsByList(dao, filter);
+//
+// int result = query.executeCount();
+// return result;
}
- /**
- * Create a TopiaQuery to find all the accounts of a list with
- * {@code filter} constraints (order, limit indexes, uid).
- *
- * @param dao used to create the query
- * @param filter used to add constraint in the query
- * @return the TopiaQuery created
- * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid)
- */
- protected TopiaQuery createQueryFindAccountsByList(PollAccountDAO dao,
- Filter filter) {
-
- // Property for account to find
- PollAccountProperty accountProperty = new PollAccountProperty("A");
- // Property for list reference that contains the accounts
- PollAccountProperty listProperty = new PollAccountProperty("L");
-
- TopiaQuery query = dao.createQuery(accountProperty.name());
- query.addFrom(PollAccount.class, listProperty.name());
- query.addInElements(accountProperty.name(),
- listProperty.namePropertyChild());
- // query.add("A IN elements(L." + PollAccount.CHILD + ")");
-
- // Add constraints from filter, the listProperty is given to provide
- // the name of its UID property.
- filter.prepareQuery(query, listProperty);
-
- return query;
- }
-
}
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-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-28 08:47:44 UTC (rev 2977)
@@ -36,22 +36,30 @@
pollen.error.serviceUser.connect=
pollen.error.serviceUser.createDefaultAdmin=
pollen.error.serviceUser.createFavoriteList=
+pollen.error.serviceUser.createFavoriteParticipant=
pollen.error.serviceUser.createList=
pollen.error.serviceUser.createUpdateList=
pollen.error.serviceUser.createUpdateUser=
pollen.error.serviceUser.createUser=
+pollen.error.serviceUser.deleteFavoriteList=
+pollen.error.serviceUser.deleteFavoriteParticipant=
pollen.error.serviceUser.deleteList=
pollen.error.serviceUser.deleteUser=
pollen.error.serviceUser.getAccounts=
pollen.error.serviceUser.getFavoriteLists=
+pollen.error.serviceUser.getFavoriteParticipants=
pollen.error.serviceUser.getNbAccounts=
+pollen.error.serviceUser.getNbFavoriteParticipants=
pollen.error.serviceUser.getNbUsers=
pollen.error.serviceUser.getNewAccount=
+pollen.error.serviceUser.getNewFavoriteList=
+pollen.error.serviceUser.getNewFavoriteParticipant=
pollen.error.serviceUser.getNewList=
pollen.error.serviceUser.getNewPerson=
pollen.error.serviceUser.getNewUser=
pollen.error.serviceUser.getPerson=
pollen.error.serviceUser.getUsers=
+pollen.error.serviceUser.updateFavoriteParticipant=
pollen.error.serviceUser.updateUser=
pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
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-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-28 08:47:44 UTC (rev 2977)
@@ -35,22 +35,30 @@
pollen.error.serviceUser.connect=Impossible d'\u00E9tablir la connexion pour l'identifiant %1$s et le mot de passe encod\u00E9 %2$s
pollen.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut \: %1$s (%2$s)
pollen.error.serviceUser.createFavoriteList=
+pollen.error.serviceUser.createFavoriteParticipant=
pollen.error.serviceUser.createList=
pollen.error.serviceUser.createUpdateList=
pollen.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er l'utilisateur '%1$s' <%2$s> (admin \= %$3b)
pollen.error.serviceUser.createUser=
+pollen.error.serviceUser.deleteFavoriteList=
+pollen.error.serviceUser.deleteFavoriteParticipant=
pollen.error.serviceUser.deleteList=
pollen.error.serviceUser.deleteUser=
pollen.error.serviceUser.getAccounts=
pollen.error.serviceUser.getFavoriteLists=
+pollen.error.serviceUser.getFavoriteParticipants=
pollen.error.serviceUser.getNbAccounts=
+pollen.error.serviceUser.getNbFavoriteParticipants=
pollen.error.serviceUser.getNbUsers=
pollen.error.serviceUser.getNewAccount=
+pollen.error.serviceUser.getNewFavoriteList=
+pollen.error.serviceUser.getNewFavoriteParticipant=
pollen.error.serviceUser.getNewList=
pollen.error.serviceUser.getNewPerson=
pollen.error.serviceUser.getNewUser=Impossible d'instancier un nouvel utilisateur.
pollen.error.serviceUser.getPerson=
pollen.error.serviceUser.getUsers=
+pollen.error.serviceUser.updateFavoriteParticipant=
pollen.error.serviceUser.updateUser=
pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotesByPoll=
Modified: trunk/pollen-business/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-28 08:47:44 UTC (rev 2977)
@@ -7,4 +7,10 @@
org.chorem.pollen.entity.UserAccount.attribute.login.tagvalue.naturalId=true
org.chorem.pollen.entity.UserAccount.attribute.email.tagvalue.unique=true
-org.chorem.pollen.entity.PollAccount.attribute.uid.tagvalue.naturalId=true
\ No newline at end of file
+org.chorem.pollen.entity.PollAccount.attribute.uid.tagvalue.naturalId=true
+
+org.chorem.pollen.entity.FavoriteList.attribute.userAccount.tagvalue.naturalId=true
+org.chorem.pollen.entity.FavoriteList.attribute.name.tagvalue.naturalId=true
+
+org.chorem.pollen.entity.FavoriteParticipant.attribute.favoriteList.tagvalue.naturalId=true
+org.chorem.pollen.entity.FavoriteParticipant.attribute.email.tagvalue.naturalId=true
\ No newline at end of file
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/pom.xml
===================================================================
--- trunk/pollen-ui/pom.xml 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/pom.xml 2010-04-28 08:47:44 UTC (rev 2977)
@@ -174,9 +174,9 @@
</plugins>
</build>
- <repositories>
+ <!--<repositories>
- <!-- chenillekit Repository -->
+ chenillekit Repository
<repository>
<id>chenillekit</id>
<url>http://www.chenillekit.org/mvnrepo/release</url>
@@ -185,13 +185,13 @@
</snapshots>
</repository>
- <!-- Maven Java.net Repository -->
+ Maven Java.net Repository
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
- </repositories>
+ </repositories>-->
</project>
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -10,7 +10,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.PollenBusinessException;
import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
-import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.ui.base.PollenPage;
import org.chorem.pollen.ui.services.PollenManager;
@@ -44,7 +44,7 @@
/** Properties **/
@Property
- private PollAccount newFavoriteList;
+ private FavoriteList newFavoriteList;
/** Components injected **/
@InjectComponent
@@ -62,7 +62,8 @@
if (logger.isDebugEnabled()) {
logger.debug("User connected : " + page.getUserConnected());
}
- newFavoriteList = serviceUser.getNewList(page.getUserConnected());
+ newFavoriteList =
+ serviceUser.getNewFavoriteList(page.getUserConnected());
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -2,19 +2,20 @@
package org.chorem.pollen.ui.components;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.ValidationException;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteList;
+import org.chorem.pollen.entity.FavoriteParticipant;
import org.chorem.pollen.entity.PollAccount;
-import org.chorem.pollen.entity.PollAccountImpl;
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.ui.data.EvenOdd;
+import org.chorem.pollen.ui.data.FavoriteParticipantDataSource;
import org.slf4j.Logger;
/**
@@ -43,17 +44,19 @@
@Inject
private ServiceUser serviceUser;
- @Persist
@Property
- private PollAccount favoriteListSelected;
+ private FavoriteList favoriteListSelected;
private EvenOdd evenOdd;
+ @Persist
+ private FavoriteParticipantDataSource accounts;
+
@Property
- private PollAccount account;
+ private FavoriteParticipant account;
@Property
- private PollAccount newAccount;
+ private FavoriteParticipant newAccount;
@InjectComponent
private Zone updateZone;
@@ -73,32 +76,28 @@
return favoriteListSelected != null;
}
+ public FavoriteParticipantDataSource getAccounts() {
+ if (accounts == null) {
+ Filter filter = new Filter();
+ filter.setReference(favoriteListSelected);
+ accounts = new FavoriteParticipantDataSource(serviceUser, filter);
+ }
+ return accounts;
+ }
+
void onActionFromRemoveAccount(String UId) {
- PollAccount child = favoriteListSelected.getChildByUId(UId);
- favoriteListSelected.removeChild(child);
+ // NEED DELETE ACCOUNT FOR LIST
}
void onPrepareFromAddAccount() {
if (newAccount == null) {
- // TEMP
- newAccount = new PollAccountImpl();
+ newAccount =
+ serviceUser.getNewFavoriteParticipant(favoriteListSelected);
}
}
-// void onValidateFromEmail(String input) throws ValidationException {
-// String test = StringUtils.lowerCase(input);
-// for (PollAccount curr : favoriteListSelected.getChild()) {
-// if (test.equals(curr.getEmail())) {
-// throw new ValidationException("NOT ALLOWED");
-// }
-// }
-// }
-
Object onSuccessFromAddAccount() {
- favoriteListSelected.addChild(newAccount);
- if (logger.isDebugEnabled()) {
- logger.debug("Add account : " + newAccount);
- }
+ // NEED CREATE ACCOUNT FOR LIST
return updateZone.getBody();
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/AbstractMappedGridDataSource.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -26,6 +26,7 @@
package org.chorem.pollen.ui.data;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
@@ -55,8 +56,6 @@
private Map<K, E> mapResults;
- private List<E> listResults;
-
private int nbRows = -1;
private int nbRowsPerPage;
@@ -84,10 +83,7 @@
nbRowsPerPage = endIndex - startIndex + 1;
try {
mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints));
- listResults = new ArrayList<E>(mapResults.values());
- // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats
- //sortResults(sortConstraints);
} catch (PollenException eee) {
throw new TapestryException("", eee);
}
@@ -127,70 +123,17 @@
}
return filterOrder;
}
-
-// protected void sortResults(List<SortConstraint> sortConstraints) {
-//
-// for (SortConstraint constraint : sortConstraints)
-// {
-// final ColumnSort sort = constraint.getColumnSort();
-//
-// if (sort == ColumnSort.UNSORTED) continue;
-//
-// final PropertyConduit conduit = constraint.getPropertyModel().getConduit();
-//
-// final Comparator valueComparator = new Comparator<Comparable>()
-// {
-// public int compare(Comparable o1, Comparable o2)
-// {
-// // Simplify comparison, and handle case where both are nulls.
-//
-// if (o1 == o2) return 0;
-//
-// if (o2 == null) return 1;
-//
-// if (o1 == null) return -1;
-//
-// return o1.compareTo(o2);
-// }
-// };
-//
-// final Comparator rowComparator = new Comparator()
-// {
-// public int compare(Object row1, Object row2)
-// {
-// Comparable value1 = (Comparable) conduit.get(row1);
-// Comparable value2 = (Comparable) conduit.get(row2);
-//
-// return valueComparator.compare(value1, value2);
-// }
-// };
-//
-// final Comparator reverseComparator = new Comparator()
-// {
-// public int compare(Object o1, Object o2)
-// {
-// int modifier = sort == ColumnSort.ASCENDING ? 1 : -1;
-//
-// return modifier * rowComparator.compare(o1, o2);
-// }
-// };
-//
-// // We can freely sort this list because its just a copy.
-//
-// Collections.sort(listResults, reverseComparator);
-// }
-// }
-
+
@Override
public Object getRowValue(int index) {
index = index % nbRowsPerPage;
- if (index >= listResults.size()) {
+ if (index >= mapResults.size()) {
if (log.isErrorEnabled()) {
- log.error("Size error : " + index + " / " + listResults.size());
+ log.error("Size error : " + index + " / " + mapResults.size());
}
return null;
}
- return CollectionUtils.get(listResults, index);
+ return CollectionUtils.get(mapResults, index);
}
@Override
@@ -200,8 +143,8 @@
return mapResults.get(key);
}
- public List<E> values() {
- return listResults;
+ public Collection<E> values() {
+ return mapResults.values();
}
public boolean contains(K key) {
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -0,0 +1,55 @@
+
+package org.chorem.pollen.ui.data;
+
+import java.util.Map;
+import org.apache.tapestry5.grid.SortConstraint;
+import org.chorem.pollen.PollenException;
+import org.chorem.pollen.bean.Filter;
+import org.chorem.pollen.entity.FavoriteParticipant;
+import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.service.ServiceUser;
+
+/**
+ * UserAccountDataSource
+ *
+ * Created: 23 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class FavoriteParticipantDataSource extends
+ AbstractMappedGridDataSource<String, FavoriteParticipant> {
+
+ private ServiceUser service;
+
+ private Filter filter;
+
+ public FavoriteParticipantDataSource(ServiceUser service, Filter filter) {
+ this.service = service;
+ this.filter = filter;
+ }
+
+ @Override
+ protected Map<String, FavoriteParticipant> execute(
+ int startIndex, int endIndex, SortConstraint orderBy)
+ throws PollenException {
+ filter.setStartIndex(startIndex);
+ filter.setEndIndex(endIndex);
+ filter.setOrderBy(resolveOrderBy(orderBy));
+ return service.getFavoriteParticipants(filter);
+ }
+
+ @Override
+ protected int count() throws PollenException {
+ return service.getNbFavoriteParticipants(filter);
+ }
+
+ @Override
+ public Class<?> getRowType() {
+ return PollAccount.class;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/FavoriteParticipantDataSource.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
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-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -1092,12 +1092,16 @@
if (pollAccount == null) {
// Identification du votant
if (uri.getAccountUId() != null) {
- pollAccount = serviceUser.getPerson(uri.getAccountUId());
+ // pollAccount = serviceUser.getPerson(uri.getAccountUId());
+
+
// pollAccountId = pollAccount.getId();
}
if (pollAccount == null) {
// pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO();
+
+
// if (userExists) {
// if (user.getFirstName() != null && user.getLastName() != null) {
// pollAccount.setVotingId(
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-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-04-28 08:47:44 UTC (rev 2977)
@@ -22,18 +22,13 @@
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
-import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.FavoriteList;
import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.data.AddressBar;
-import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.services.PollenManager;
-import org.slf4j.Logger;
/**
* Classe de la page d'affichage des listes de votants favorites de
@@ -59,7 +54,7 @@
@Inject
private ServiceUser serviceUser;
- private List<PollAccount> favoriteLists;
+ private List<FavoriteList> favoriteLists;
@Override
public Border getBorder() {
@@ -80,7 +75,7 @@
return AddressBar.newBar().appendCurrent(title);
}
- public List<PollAccount> getFavoriteLists() {
+ public List<FavoriteList> getFavoriteLists() {
if (favoriteLists == null) {
favoriteLists = serviceUser.getFavoriteLists(getUserConnected());
}
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-28 08:47:44 UTC (rev 2977)
@@ -1,19 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <t:zone t:id="updateZone" show="show" update="show">
- <form t:type="form" t:id="selectListForm" action="tapestry">
- <div>
- ${message:listSelect-label}:
- <select t:id="listSelect" t:type="ck/beanSelect" t:list="source" t:value="favoriteListSelected"
- t:labelField="literal:name" t:valueField="literal:name" />
- <input t:type="submit" value="${message:pollen.ui.button.ok}"/>
- </div>
- </form>
+ <form t:type="form" t:id="selectListForm" action="tapestry">
+ <div>
+ ${message:listSelect-label}:
+ <select t:id="listSelect" t:type="ck/beanSelect" t:list="source" t:value="favoriteListSelected"
+ t:labelField="literal:name" t:valueField="literal:name" />
+ <input t:type="submit" value="${message:pollen.ui.button.ok}"/>
+ </div>
+ </form>
- <t:if test="canDisplayAccounts()">
+ <t:if test="canDisplayAccounts()">
+ <t:zone t:id="updateZone" show="show" update="show">
<!-- Display all Accounts child of favoriteListSelected -->
- <div t:type="grid" t:source="favoriteListSelected.child" t:row="account"
+ <div t:type="grid" t:source="accounts.values()" t:row="account"
t:include="name, email, weight" t:add="actions"
t:rowsPerPage="20" t:rowClass="prop:evenodd.next" t:inPlace="true">
<p:actionsCell>
@@ -40,6 +40,7 @@
<input t:type="textfield" t:id="weight" t:value="newAccount.weight" size="5"/>
</td>
<td class="functions">
+ <input t:type="hidden" value="newAccount.list" />
<input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addAccount}"/>
</td>
</tr>
@@ -48,16 +49,16 @@
</form>
<!-- Delete the favoriteListSelected -->
-<!-- <p>
- <a t:type="actionlink" t:id="deleteList">
- <img src="${asset:context:img/delete.png}" alt="Delete"/>${message:deleteList}
- </a>
- </p>-->
+ <!-- <p>
+ <a t:type="actionlink" t:id="deleteList">
+ <img src="${asset:context:img/delete.png}" alt="Delete"/>${message:deleteList}
+ </a>
+ </p>-->
- <p:else>
- ${message:pollen.ui.list.update.notSelected}
- </p:else>
- </t:if>
+ </t:zone>
- </t:zone>
+ <p:else>
+ ${message:pollen.ui.list.update.notSelected}
+ </p:else>
+ </t:if>
</body>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-27 16:29:41 UTC (rev 2976)
+++ trunk/pom.xml 2010-04-28 08:47:44 UTC (rev 2977)
@@ -134,7 +134,7 @@
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
- <version>1.0</version>
+ <version>0.9</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
1
0
Author: fdesbois
Date: 2010-04-27 18:29:41 +0200 (Tue, 27 Apr 2010)
New Revision: 2976
Log:
- Add FormatBinding to manage message format: in tml files
- Add EntityProperty to manage properties in TopiaQuery
- Use last ToPIA and EUGene snapshot
- Split page UserLists in two components : UserListsCreate and UserListsUpdate
- Improve filter to use EntityProperty and UID (for PollAccount or Poll)
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.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/ModificationValidation.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/UserLists.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties
trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml
trunk/pollen-ui/src/main/webapp/css/lists.css
trunk/pollen-ui/src/main/webapp/user/UserLists.tml
trunk/pom.xml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenBusinessException.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -46,7 +46,10 @@
/** Exception when password is not valid for some user **/
USER_WRONG_PASSWORD(n_("pollen.exception.user_wrong_password")),
/** Exception when stmp server is not available **/
- SMTP_NOT_AVAILABLE(n_("pollen.exception.smtp_not_available"));
+ SMTP_NOT_AVAILABLE(n_("pollen.exception.smtp_not_available")),
+ /** Exception when favorite list name is already defined for user **/
+ FAVORITE_LIST_NAME_EXIST(
+ n_("pollen.exception.favorite_list_name_exist"));
private String message;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/bean/Filter.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -4,6 +4,8 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.apache.commons.lang.StringUtils;
+import org.chorem.pollen.entity.EntityProperty;
+import org.chorem.pollen.entity.PropertyUid;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -13,10 +15,7 @@
* Created: 23 avr. 2010
*
* @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * @since 2.0
*/
public class Filter {
@@ -26,6 +25,8 @@
protected String orderBy;
+ protected String uid;
+
private PropertyChangeSupport propertyChangeSupport =
new PropertyChangeSupport(this);
@@ -35,6 +36,8 @@
public static final String PROPERTY_ORDER_BY = "orderBy";
+ public static final String PROP_UID = "uid";
+
/**
* Get the value of startIndex
*
@@ -96,6 +99,26 @@
}
/**
+ * Get the value of uid
+ *
+ * @return the value of uid
+ */
+ public String getUid() {
+ return uid;
+ }
+
+ /**
+ * Set the value of uid
+ *
+ * @param uid new value of uid
+ */
+ public void setUid(String uid) {
+ String oldUid = this.uid;
+ this.uid = uid;
+ propertyChangeSupport.firePropertyChange(PROP_UID, oldUid, uid);
+ }
+
+ /**
* Add PropertyChangeListener.
*
* @param listener
@@ -113,7 +136,26 @@
propertyChangeSupport.removePropertyChangeListener(listener);
}
+ /**
+ * Prepare a query with filter : adding startIndex and endIndex as limit
+ * and orderBy if defined.
+ *
+ * @param query
+ * @see #prepareQuery(TopiaQuery, PropertyUid)
+ */
public void prepareQuery(TopiaQuery query) {
+ prepareQuery(query, null);
+ }
+
+ /**
+ * Prepare a query with filter. The {@code property} is used
+ * to retrieve the name of UID property in case of filter using uid.
+ *
+ * @param query to prepare
+ * @param ordered if order is needed (using orderBy filter)
+ * @param property to provide UID property name (using uid filter)
+ */
+ public void prepareQuery(TopiaQuery query, PropertyUid property) {
// Add limits. Only startIndex do nothing.
// startIndex + endIndex provides the limit
if (startIndex != null && endIndex != null) {
@@ -123,9 +165,11 @@
} else if (endIndex != null) {
query.setMaxResults(endIndex);
}
- }
- public void prepareQueryWithOrder(TopiaQuery query) {
+ if (StringUtils.isNotEmpty(uid) && property != null) {
+ query.add(property.namePropertyUid(), uid);
+ }
+
// Add order to the query, splitted by comma and trimmed using
// {@link StringUtils#stripAll(String[])}
if (orderBy != null) {
@@ -136,8 +180,6 @@
} else {
query.addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE);
}
-
- prepareQuery(query);
}
}
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,80 @@
+
+package org.chorem.pollen.entity;
+
+import org.nuiton.topia.framework.*;
+
+/**
+ * EntityProperty is used to simplify property concatenation in TopiaQuery.
+ * The usage is simple, the EntityProperty need a mainAlias which represents
+ * the entity in a TopiaQuery. Then the {@link #nameProperty(String)}
+ * is called to retrieve the correct property name used for the query.
+ * Exemple :
+ * <pre>
+ * BoatDAO dao = AppDAOHelper.getBoatDAO(topiaContext);
+ *
+ * // Property used in the query
+ * EntityProperty boatProperty = new EntityProperty("B");
+ *
+ * // It's better to create the query with the property name
+ * TopiaQuery query = dao.createQuery(boatProperty.name());
+ *
+ * // The property NAME of the boat need to be find equals to "ULUBERLU"
+ * query.add(boatProperty.nameProperty(Boat.NAME), "ULUBERLU");
+ *
+ * // It's avoid doing this :
+ * query.add("B." + Boat.NAME, "ULUBERLU");
+ * </pre>
+ * This last exemple is a simple case but for a more complex query with more
+ * than one entity, it's obvious that concatenation using + is not a good
+ * practice.<br />
+ * You can also use this class as a superclass for each entity, ex :
+ * <pre>
+ * public class BoatProperty extends EntityProperty {
+ *
+ * public BoatProperty(String mainAlias) {
+ * super(mainAlias);
+ * }
+ *
+ * public String namePropertyName() {
+ * return nameProperty(Boat.NAME);
+ * }
+ * }
+ * </pre>
+ *
+ * Created: 14 avr. 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ */
+public class EntityProperty {
+
+ /** alias of the entity **/
+ protected String mainAlias;
+
+ public EntityProperty(String mainAlias) {
+ this.mainAlias = mainAlias;
+ }
+
+ /**
+ * Name the entity as a property for a TopiaQuery.
+ *
+ * @return the entity name used as a TopiaQuery property
+ */
+ public String name() {
+ return mainAlias;
+ }
+
+ /**
+ * Name a property from the Entity for a TopiaQuery.
+ *
+ * @param propertyName to named in the TopiaQuery
+ * @return the property name used as a TopiaQuery property
+ */
+ public String nameProperty(String propertyName) {
+ return TopiaQuery.getProperty(mainAlias, propertyName);
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/EntityProperty.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,27 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * PollAccountImpl
+ *
+ * Created: 26 avr. 2010
+ *
+ * @author fdesbois
+ */
+public class PollAccountImpl extends PollAccountAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public PollAccount getChildByUId(String UId) {
+ if (child != null) {
+ for (PollAccount account : child) {
+ if (account.getUid().equals(UId)) {
+ return account;
+ }
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,27 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * PollAccountProperty
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ * @since 2.0
+ */
+public class PollAccountProperty extends EntityProperty implements PropertyUid {
+
+ public PollAccountProperty(String mainAlias) {
+ super(mainAlias);
+ }
+
+ @Override
+ public String namePropertyUid() {
+ return nameProperty(PollAccount.UID);
+ }
+
+ public String namePropertyChild() {
+ return nameProperty(PollAccount.CHILD);
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollAccountProperty.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,15 @@
+
+package org.chorem.pollen.entity;
+
+/**
+ * PropertyUid
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ * @since 2.0
+ */
+public interface PropertyUid {
+
+ String namePropertyUid();
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PropertyUid.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -65,7 +65,7 @@
List<Object> errorArgs, Poll poll) throws TopiaException {
errorArgs.add(poll.getTitle());
- errorArgs.add(poll.getUId());
+ errorArgs.add(poll.getUid());
PollenDAOHelper.getPollDAO(transaction).create(poll);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -2,7 +2,6 @@
package org.chorem.pollen.service;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -14,6 +13,9 @@
import org.chorem.pollen.PollenException;
import org.chorem.pollen.bean.Filter;
import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.PollAccountDAO;
+import org.chorem.pollen.entity.PollAccountImpl;
+import org.chorem.pollen.entity.PollAccountProperty;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.entity.UserAccountDAO;
import org.chorem.pollen.entity.UserAccountImpl;
@@ -21,6 +23,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderBuilder;
import org.nuiton.util.beans.BinderProvider;
@@ -39,13 +42,32 @@
private Log log = LogFactory.getLog(ServiceUserImpl.class);
+ private static final String BINDER_CONTEXT_FAVORITE_LIST = "favoriteList";
+
private PollenContext context;
public void setContext(PollenContext context) {
this.context = context;
prepareUserAccountBinder();
+ prepareFavoriteListBinder();
}
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaException {
+ return context.beginTransaction();
+ }
+
+ @Override
+ protected void treateError(TopiaContext transaction, Exception eee,
+ String message, Object... args) throws PollenException {
+ context.treateError(transaction, eee, message, args);
+ }
+
+ @Override
+ protected void closeTransaction(TopiaContext transaction) {
+ context.closeTransaction(transaction);
+ }
+
protected void prepareUserAccountBinder() {
BinderBuilder builder = new BinderBuilder(UserAccount.class,
UserAccount.ADMIN,
@@ -54,6 +76,14 @@
BinderProvider.registerBinder(builder);
}
+ protected void prepareFavoriteListBinder() {
+ BinderBuilder builder = new BinderBuilder(PollAccount.class,
+ PollAccount.LIST,
+ PollAccount.NAME,
+ PollAccount.USER_ACCOUNT);
+ BinderProvider.registerBinder(builder, BINDER_CONTEXT_FAVORITE_LIST);
+ }
+
/**
* Copy {@code source} user account to {@code destination} one.
* The email is lower cased in the {@code destination} user account.
@@ -72,22 +102,6 @@
}
}
- @Override
- protected TopiaContext beginTransaction() throws TopiaException {
- return context.beginTransaction();
- }
-
- @Override
- protected void treateError(TopiaContext transaction, Exception eee,
- String message, Object... args) throws PollenException {
- context.treateError(transaction, eee, message, args);
- }
-
- @Override
- protected void closeTransaction(TopiaContext transaction) {
- context.closeTransaction(transaction);
- }
-
/**
* Check if the {@code login} and {@code password} correspond to an
* existing user.
@@ -203,7 +217,6 @@
// Check email not exist
checkEmailNotExist(dao, user.getEmail(), null);
-
// Execute create
UserAccount newUser = dao.create(user.getLogin());
@@ -263,7 +276,7 @@
UserAccountDAO dao = PollenDAOHelper.getUserAccountDAO(transaction);
TopiaQuery query = dao.createQuery();
- filter.prepareQueryWithOrder(query);
+ filter.prepareQuery(query);
Map<String, UserAccount> results = dao.findAllMappedByQuery(query,
UserAccount.LOGIN, String.class);
@@ -284,15 +297,42 @@
}
@Override
- protected PollAccount executeGetNewList(TopiaContext transaction)
- throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
+ protected PollAccount executeGetNewList(UserAccount user) {
+ PollAccount result = new PollAccountImpl();
+ result.setList(true);
+ result.setUserAccount(user);
+ return result;
}
@Override
- protected void executeCreateUpdateList(TopiaContext transaction,
- PollAccount list) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
+ protected void executeCreateFavoriteList(TopiaContext transaction,
+ PollAccount list) throws TopiaException, PollenBusinessException {
+
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+
+ // check favoriteList name exist for user
+ UserAccount user = list.getUserAccount();
+ int count = dao.createQuery().
+ add(PollAccount.LIST, true).
+ add(PollAccount.USER_ACCOUNT, user).
+ add(PollAccount.NAME, list.getName()).
+ executeCount();
+ // existing list found
+ if (count > 0) {
+ throw new PollenBusinessException(
+ PollenExceptionType.FAVORITE_LIST_NAME_EXIST,
+ list.getName(), user.getDisplayName());
+ }
+
+ // Create unique Id for the new List
+ String UId = context.createPollenUrlId();
+ PollAccount newList = dao.create(UId);
+ BinderProvider.getBinder(PollAccount.class,
+ BINDER_CONTEXT_FAVORITE_LIST).
+ copy(list, newList);
+ dao.update(newList);
+
+ transaction.commitTransaction();
}
@Override
@@ -303,14 +343,24 @@
@Override
protected List<PollAccount> executeGetFavoriteLists(
- TopiaContext transaction) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
+ TopiaContext transaction, UserAccount user) throws TopiaException {
+
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+
+ TopiaQuery query = dao.createQuery().
+ add(PollAccount.LIST, true).
+ add(PollAccount.USER_ACCOUNT, user);
+
+ List<PollAccount> results = dao.findAllByQuery(query);
+
+ return results;
}
@Override
- protected PollAccount executeGetNewPerson(TopiaContext transaction,
- UserAccount user) throws TopiaException {
- throw new UnsupportedOperationException("Not supported yet.");
+ protected PollAccount executeGetNewAccount(TopiaContext transaction)
+ throws TopiaException {
+ PollAccount result = new PollAccountImpl();
+ return result;
}
@Override
@@ -320,4 +370,60 @@
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
+ protected Map<String, PollAccount> executeGetAccounts(
+ TopiaContext transaction, Filter filter) throws TopiaException {
+
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+
+ TopiaQuery query = createQueryFindAccountsByList(dao, filter);
+
+ Map<String, PollAccount> results = dao.findAllMappedByQuery(query,
+ PollAccount.UID, String.class);
+
+ return results;
+ }
+
+ @Override
+ protected int executeGetNbAccounts(TopiaContext transaction,
+ Filter filter) throws TopiaException {
+
+ PollAccountDAO dao = PollenDAOHelper.getPollAccountDAO(transaction);
+
+ TopiaQuery query = createQueryFindAccountsByList(dao, filter);
+
+ int result = query.executeCount();
+ return result;
+ }
+
+ /**
+ * Create a TopiaQuery to find all the accounts of a list with
+ * {@code filter} constraints (order, limit indexes, uid).
+ *
+ * @param dao used to create the query
+ * @param filter used to add constraint in the query
+ * @return the TopiaQuery created
+ * @see Filter#prepareQuery(TopiaQuery, boolean, PropertyUid)
+ */
+ protected TopiaQuery createQueryFindAccountsByList(PollAccountDAO dao,
+ Filter filter) {
+
+ // Property for account to find
+ PollAccountProperty accountProperty = new PollAccountProperty("A");
+ // Property for list reference that contains the accounts
+ PollAccountProperty listProperty = new PollAccountProperty("L");
+
+ TopiaQuery query = dao.createQuery(accountProperty.name());
+ query.addFrom(PollAccount.class, listProperty.name());
+ query.addInElements(accountProperty.name(),
+ listProperty.namePropertyChild());
+ // query.add("A IN elements(L." + PollAccount.CHILD + ")");
+
+ // Add constraints from filter, the listProperty is given to provide
+ // the name of its UID property.
+ filter.prepareQuery(query, listProperty);
+
+ return query;
+ }
+
}
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-04-27 16:29:41 UTC (rev 2976)
@@ -35,13 +35,18 @@
pollen.error.serviceResults.importPoll=
pollen.error.serviceUser.connect=
pollen.error.serviceUser.createDefaultAdmin=
+pollen.error.serviceUser.createFavoriteList=
+pollen.error.serviceUser.createList=
pollen.error.serviceUser.createUpdateList=
pollen.error.serviceUser.createUpdateUser=
pollen.error.serviceUser.createUser=
pollen.error.serviceUser.deleteList=
pollen.error.serviceUser.deleteUser=
+pollen.error.serviceUser.getAccounts=
pollen.error.serviceUser.getFavoriteLists=
+pollen.error.serviceUser.getNbAccounts=
pollen.error.serviceUser.getNbUsers=
+pollen.error.serviceUser.getNewAccount=
pollen.error.serviceUser.getNewList=
pollen.error.serviceUser.getNewPerson=
pollen.error.serviceUser.getNewUser=
@@ -51,6 +56,7 @@
pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
+pollen.exception.favorite_list_name_exist=
pollen.exception.load_configuration=
pollen.exception.poll_not_exist=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
pollen.exception.smtp_not_available=
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-04-27 16:29:41 UTC (rev 2976)
@@ -34,13 +34,18 @@
pollen.error.serviceResults.importPoll=
pollen.error.serviceUser.connect=Impossible d'\u00E9tablir la connexion pour l'identifiant %1$s et le mot de passe encod\u00E9 %2$s
pollen.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut \: %1$s (%2$s)
+pollen.error.serviceUser.createFavoriteList=
+pollen.error.serviceUser.createList=
pollen.error.serviceUser.createUpdateList=
pollen.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er l'utilisateur '%1$s' <%2$s> (admin \= %$3b)
pollen.error.serviceUser.createUser=
pollen.error.serviceUser.deleteList=
pollen.error.serviceUser.deleteUser=
+pollen.error.serviceUser.getAccounts=
pollen.error.serviceUser.getFavoriteLists=
+pollen.error.serviceUser.getNbAccounts=
pollen.error.serviceUser.getNbUsers=
+pollen.error.serviceUser.getNewAccount=
pollen.error.serviceUser.getNewList=
pollen.error.serviceUser.getNewPerson=
pollen.error.serviceUser.getNewUser=Impossible d'instancier un nouvel utilisateur.
@@ -50,6 +55,7 @@
pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotesByPoll=
pollen.error.serviceVote.hasAlreadyVoted=
+pollen.exception.favorite_list_name_exist=La liste %1$s existe d\u00E9j\u00E0 pour l'utilisateur %2$s
pollen.exception.load_configuration=La configuration n'a pas \u00E9t\u00E9 charg\u00E9e correctement \! Veuillez v\u00E9rifier le d\u00E9marrage de l'application.
pollen.exception.poll_not_exist=Il n'y a pas de sondage \u00E0 cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le compl\u00E8tement dans le champ d'adresse de votre navigateur.
pollen.exception.smtp_not_available=Impossible d'envoyer un email \u00E0 %1$s. Serveur smtp indisponible pour l'envoi d'email, veuillez contacter un administrateur.
Modified: trunk/pollen-business/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-business/src/main/xmi/pollen.properties 2010-04-27 16:29:41 UTC (rev 2976)
@@ -5,4 +5,6 @@
model.tagvalue.exceptionClass=org.chorem.pollen.PollenException
org.chorem.pollen.entity.UserAccount.attribute.login.tagvalue.naturalId=true
-org.chorem.pollen.entity.UserAccount.attribute.email.tagvalue.unique=true
\ No newline at end of file
+org.chorem.pollen.entity.UserAccount.attribute.email.tagvalue.unique=true
+
+org.chorem.pollen.entity.PollAccount.attribute.uid.tagvalue.naturalId=true
\ No newline at end of file
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractPollenPage.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -3,7 +3,6 @@
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.ioc.annotations.Inject;
import org.chorem.pollen.entity.UserAccount;
import org.chorem.pollen.ui.components.Border;
@@ -58,6 +57,7 @@
*
* @return the UserAccount corresponding to connected user
*/
+ @Override
public UserAccount getUserConnected() {
return user;
}
@@ -76,6 +76,7 @@
*
* @return true if connected user is defined.
*/
+ @Override
public boolean isUserConnected() {
return userExists;
}
@@ -85,6 +86,7 @@
*
* @return true if the connected user is an admin.
*/
+ @Override
public boolean isAdminConnected() {
return isUserConnected() && user.getAdmin();
}
@@ -94,6 +96,7 @@
*
* @param message to display
*/
+ @Override
public void addInfo(String message) {
getBorder().addInfo(message);
}
@@ -104,6 +107,7 @@
*
* @param message to display
*/
+ @Override
public void addFatal(String message) {
getBorder().addFatal(message);
}
@@ -113,6 +117,7 @@
*
* @param message to display
*/
+ @Override
public void addError(String message) {
getBorder().addError(message);
}
@@ -122,6 +127,7 @@
*
* @return the current url of the page.
*/
+ @Override
public String getUrl() {
return getBorder().getServerPath();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/PollenPage.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -1,6 +1,8 @@
package org.chorem.pollen.ui.base;
+import org.chorem.pollen.entity.UserAccount;
+
/**
* PollenPage
*
@@ -23,4 +25,54 @@
* @return true for display allowed
*/
boolean canDisplayPage();
+
+ /**
+ * Retrieve connected user from session.
+ *
+ * @return the user currently connected.
+ */
+ public UserAccount getUserConnected();
+
+ /**
+ * Return true if a user is already connected to the application.
+ *
+ * @return true if connected user is defined.
+ */
+ public boolean isUserConnected();
+
+ /**
+ * Return true if the connected user is an admin.
+ *
+ * @return true if the connected user is an admin.
+ */
+ public boolean isAdminConnected();
+
+ /**
+ * Add an info {@code message} to display.
+ *
+ * @param message to display
+ */
+ public void addInfo(String message) ;
+
+ /**
+ * Add a fatal {@code message} to display. Only the fatal {@code message}
+ * will be displayed, not other elements in the page will be showed.
+ *
+ * @param message to display
+ */
+ public void addFatal(String message);
+
+ /**
+ * Add an error {@code message} to display.
+ *
+ * @param message to display
+ */
+ public void addError(String message);
+
+ /**
+ * Retrieve the current url of the page.
+ *
+ * @return the current url of the page.
+ */
+ public String getUrl();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -193,10 +193,6 @@
*/
void setupRender() {
- // URL du site
-// siteURL = "http://" + request.getHeader("host") +
-// request.getContextPath() + "/";
-
errorJs.addError(messages.get("errorJs"));
// Logo
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,96 @@
+
+package org.chorem.pollen.ui.components;
+
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.PollenBusinessException;
+import org.chorem.pollen.PollenBusinessException.PollenExceptionType;
+import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.ui.base.PollenPage;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.slf4j.Logger;
+
+/**
+ * UserListsCreate
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ */
+public class UserListsCreate {
+
+ /** Container **/
+ @InjectContainer
+ private PollenPage page;
+
+ /** Services injected **/
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private Messages messages;
+
+ @Inject
+ private PollenManager manager;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ /** Properties **/
+ @Property
+ private PollAccount newFavoriteList;
+
+ /** Components injected **/
+ @InjectComponent
+ private Field listName;
+
+ @InjectComponent
+ private Form createList;
+
+ void setupRender() {
+ createList.clearErrors();
+ }
+
+ void onPrepareFromCreateList() {
+ if (newFavoriteList == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("User connected : " + page.getUserConnected());
+ }
+ newFavoriteList = serviceUser.getNewList(page.getUserConnected());
+ }
+ }
+
+ void onValidateFormFromCreateList() {
+ try {
+ serviceUser.createFavoriteList(newFavoriteList);
+ } catch (PollenBusinessException eee) {
+ String message = manager.getErrorMessage(eee, messages, logger);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(message);
+ }
+ if (eee.getType().equals(
+ PollenExceptionType.FAVORITE_LIST_NAME_EXIST)) {
+ createList.recordError(listName, message);
+ } else {
+ createList.recordError(message);
+ }
+ }
+ }
+
+ Object onSuccessFromCreateList() {
+ page.addInfo(messages.format("pollen.ui.list.create.success",
+ newFavoriteList.getName()));
+ return page;
+ }
+
+ Object onFailureFromCreateList() {
+ return createList;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsCreate.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,104 @@
+
+package org.chorem.pollen.ui.components;
+
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.ValidationException;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Zone;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.entity.PollAccountImpl;
+import org.chorem.pollen.service.ServiceUser;
+import org.chorem.pollen.ui.data.EvenOdd;
+import org.slf4j.Logger;
+
+/**
+ * UserListsUpdate
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class UserListsUpdate {
+
+ @Parameter(required = true)
+ @Property
+ private List<PollAccount> source;
+
+ @Inject
+ private Logger logger;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Persist
+ @Property
+ private PollAccount favoriteListSelected;
+
+ private EvenOdd evenOdd;
+
+ @Property
+ private PollAccount account;
+
+ @Property
+ private PollAccount newAccount;
+
+ @InjectComponent
+ private Zone updateZone;
+
+ void setupRender() {
+ resources.discardPersistentFieldChanges();
+ }
+
+ public EvenOdd getEvenOdd() {
+ if (evenOdd == null) {
+ evenOdd = new EvenOdd();
+ }
+ return evenOdd;
+ }
+
+ public boolean canDisplayAccounts() {
+ return favoriteListSelected != null;
+ }
+
+ void onActionFromRemoveAccount(String UId) {
+ PollAccount child = favoriteListSelected.getChildByUId(UId);
+ favoriteListSelected.removeChild(child);
+ }
+
+ void onPrepareFromAddAccount() {
+ if (newAccount == null) {
+ // TEMP
+ newAccount = new PollAccountImpl();
+ }
+ }
+
+// void onValidateFromEmail(String input) throws ValidationException {
+// String test = StringUtils.lowerCase(input);
+// for (PollAccount curr : favoriteListSelected.getChild()) {
+// if (test.equals(curr.getEmail())) {
+// throw new ValidationException("NOT ALLOWED");
+// }
+// }
+// }
+
+ Object onSuccessFromAddAccount() {
+ favoriteListSelected.addChild(newAccount);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Add account : " + newAccount);
+ }
+ return updateZone.getBody();
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/UserListsUpdate.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -64,7 +64,7 @@
setTextType();
break;
case IMAGE:
- setImageType(poll.getUId());
+ setImageType(poll.getUid());
}
}
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -117,7 +117,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getUId() + ":" + creator.getUId();
+ return poll.getUid() + ":" + creator.getUid();
}
void onActivate() {
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -113,7 +113,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getUId() + ":" + creator.getUId();
+ return poll.getUid() + ":" + creator.getUid();
}
void onActivate() {
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -115,7 +115,7 @@
public String getAdminId() {
// FIXME : user PollUri
- return poll.getUId() + ":" + creator.getUId();
+ return poll.getUid() + ":" + creator.getUid();
}
void onActivate() {
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -490,7 +490,7 @@
userAllowed = true;
} else if (id.split(":", 2).length == 2) {
String creatorId = id.split(":", 2)[1];
- if (creatorId.equals(creator.getUId())) {
+ if (creatorId.equals(creator.getUid())) {
userAllowed = true;
}
}
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -1097,7 +1097,7 @@
}
if (pollAccount == null) {
- pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO();
+ // pollAccount = serviceUser.getNewPerson(getUserConnected());//new PollAccountDTO();
// if (userExists) {
// if (user.getFirstName() != null && user.getLastName() != null) {
// pollAccount.setVotingId(
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-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -16,29 +16,24 @@
package org.chorem.pollen.ui.pages.user;
+import java.util.List;
-import org.apache.commons.fileupload.FileUploadException;
import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.Retain;
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.corelib.components.Form;
-import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.BeanModelSource;
-import org.apache.tapestry5.upload.services.UploadedFile;
import org.chorem.pollen.entity.PollAccount;
+import org.chorem.pollen.service.ServiceUser;
import org.chorem.pollen.ui.base.AbstractPollenPage;
import org.chorem.pollen.ui.components.Border;
-import org.chorem.pollen.ui.components.FeedBack;
+import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.data.AddressBarItem;
+import org.chorem.pollen.ui.services.PollenManager;
+import org.slf4j.Logger;
/**
* Classe de la page d'affichage des listes de votants favorites de
@@ -46,6 +41,7 @@
* de s'identifier via un formulaire.
*
* @author rannou
+ * @author fdesbois <fdesbois(a)codelutin.com>
* @version $Id$
*/
@IncludeStylesheet("context:css/lists.css")
@@ -54,129 +50,151 @@
@InjectComponent
private Border border;
+ /** Page title from Messages **/
+ @Parameter(defaultPrefix = BindingConstants.MESSAGE,
+ value = "pollen.page.UserLists.title")
+ @Property
+ private String title;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ private List<PollAccount> favoriteLists;
+
@Override
public Border getBorder() {
return border;
}
- /** Affichage des messages pour l'utilisateur */
- @Component(id = "feedback")
- private FeedBack feedback;
+ @Override
+ public boolean isNeedAuthentification() {
+ return true;
+ }
- /**
- * Listes de favoris de l'utilisateur.
- */
-// @Property
-// private List<PersonListDTO> lists;
+ @Override
+ public boolean canDisplayPage() {
+ return isUserConnected();
+ }
+
+ public AddressBar getAddressBar() {
+ return AddressBar.newBar().appendCurrent(title);
+ }
+ public List<PollAccount> getFavoriteLists() {
+ if (favoriteLists == null) {
+ favoriteLists = serviceUser.getFavoriteLists(getUserConnected());
+ }
+ return favoriteLists;
+ }
+
+
+//
// /**
// * Liste de favoris sélectionnée.
// */
// @Persist
// @Property
// private PersonListDTO selectedList;
-//
+
// /**
// * Nouvelle liste de favoris.
// */
// @Property
// private PersonListDTO newList;
-
- /**
- * Compte courant (pour l'itération des votants de la liste).
- */
- @SuppressWarnings("unused")
- @Property
- private PollAccount account;
-
- /**
- * Nouveau compte.
- */
- @Property
- private PollAccount newAccount;
-
- /**
- * Fichier CSV contenant une liste de votants.
- */
- @Property
- private UploadedFile accountsFile;
-
- /**
- * URL de recherche LDAP pour une liste de votants.
- */
- @Property
- private String accountsUrl;
-
- /**
- * Zone à rafraîchir.
- */
- @InjectComponent
- private Zone listsZone;
-
- /**
- * Formulaire de création de liste.
- */
- @Component
- private Form createListForm;
-
- /**
- * Formulaire de création de compte.
- */
- @Component
- private Form createAccountForm;
-
- /**
- * Messages.
- */
- @Inject
- private Messages messages;
-
- /**
- * Objet servant à changer la couleur à chaque ligne de la liste.
- */
- @SuppressWarnings("unused")
- @Property
- private EvenOdd evenOdd;
-
- @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
- @Property
- private String title;
-
- @SuppressWarnings("unused")
- @Property
- private AddressBarItem[] address;
-
- /**
- * Sert à créer listModel.
- */
- @Inject
- private BeanModelSource beanModelSource;
-
- /**
- * Sert à passer les messages en paramètre de la création de listModel.
- */
- @Inject
- private ComponentResources componentResources;
-
- /**
- * Modèle pour l'affichage de la liste des favoris.
- */
- @SuppressWarnings("unchecked")
- @Property
- @Retain
- private BeanModel listModel;
-
- /** Injection des services */
+//
+// /**
+// * Compte courant (pour l'itération des votants de la liste).
+// */
+// @SuppressWarnings("unused")
+// @Property
+// private PollAccountDTO account;
+//
+// /**
+// * Nouveau compte.
+// */
+// @Property
+// private PollAccountDTO newAccount;
+//
+// /**
+// * Fichier CSV contenant une liste de votants.
+// */
+// @Property
+// private UploadedFile accountsFile;
+//
+// /**
+// * URL de recherche LDAP pour une liste de votants.
+// */
+// @Property
+// private String accountsUrl;
+//
+// /**
+// * Zone à rafraîchir.
+// */
+// @InjectComponent
+// private Zone listsZone;
+//
+// /**
+// * Formulaire de création de liste.
+// */
+// @Component
+// private Form createListForm;
+//
+// /**
+// * Formulaire de création de compte.
+// */
+// @Component
+// private Form createAccountForm;
+//
+// /**
+// * Messages.
+// */
// @Inject
+// private Messages messages;
+//
+// /**
+// * Objet servant à changer la couleur à chaque ligne de la liste.
+// */
+// @SuppressWarnings("unused")
+//
+// @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
+// @Property
+// private String title;
+//
+// @SuppressWarnings("unused")
+// @Property
+// private AddressBarItem[] address;
+//
+// /**
+// * Sert à créer listModel.
+// */
+// @Inject
+// private BeanModelSource beanModelSource;
+//
+// /**
+// * Sert à passer les messages en paramètre de la création de listModel.
+// */
+// @Inject
+// private ComponentResources componentResources;
+//
+// /**
+// * Modèle pour l'affichage de la liste des favoris.
+// */
+// @SuppressWarnings("unchecked")
+// @Property
+// @Retain
+// private BeanModel listModel;
+//
+// /** Injection des services */
+// @Inject
// private ServiceList serviceList;
// @Inject
// private ServicePollAccount servicePollAccount;
-
- /**
- * Méthode appelée à la création d'une liste.
- */
- Object onSuccessFromCreateListForm() {
//
+// /**
+// * Méthode appelée à la création d'une liste.
+// */
+// Object onSuccessFromCreateListForm() {
+//
// // Contrôle du nom de la liste
// for (PersonListDTO list : lists) {
// if (list.getName().equals(newList.getName())) {
@@ -226,14 +244,14 @@
// selectedList = list;
// }
// }
-
- return this;
- }
-
- /**
- * Méthode appelée à la suppression d'une liste.
- */
- Object onActionFromDeleteList() {
+//
+// return this;
+// }
+//
+// /**
+// * Méthode appelée à la suppression d'une liste.
+// */
+// Object onActionFromDeleteList() {
// if (selectedList != null) {
// for (PersonListDTO dto : lists) {
// if (dto.getId().equals(selectedList.getId())) {
@@ -248,15 +266,15 @@
// }
// }
// selectedList = null;
- return this;
- }
-
- /**
- * Méthode appelée à la création d'un compte.
- */
- Object onSuccessFromCreateAccountForm() {
- // TODO : use onValidateForm method : test return block, may be
- // a problem between failure and success
+// return this;
+// }
+//
+// /**
+// * Méthode appelée à la création d'un compte.
+// */
+// Object onSuccessFromCreateAccountForm() {
+// // 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",
@@ -270,67 +288,42 @@
//// selectedList = serviceList.findPersonListById(selectedList.getId());
// serviceList.createAccountInPersonList(selectedList, account);
// }
- return listsZone.getBody();
- }
-
- /**
- * Méthode appelée à la suppression d'un compte.
- */
- Object onActionFromDeleteAccount(String accountId) {
-// 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());
+// return listsZone.getBody();
+// }
+//
+// /**
+// * Méthode appelée à la suppression d'un compte.
+// */
+// Object onActionFromDeleteAccount(String accountId) {
+//// 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();
- }
-
- /**
- * Récupération des exceptions du champs d'upload de fichier.
- */
- Object onUploadException(FileUploadException ex) {
- createListForm.recordError("Upload exception: " + ex.getMessage());
- return this;
- }
-
+// return listsZone.getBody();
+// }
+//
+// /**
+// * Récupération des exceptions du champs d'upload de fichier.
+// */
+// Object onUploadException(FileUploadException ex) {
+// createListForm.recordError("Upload exception: " + ex.getMessage());
+// return this;
+// }
+//
// /** Retourne vrai s'il n'existe aucune liste */
// public boolean isListsNull() {
-// return lists == null || lists.size() == 0;
+// return CollectionUtils.isEmpty(lists);
// }
//
// /** Retourne vrai si la liste sélectionnée est vide */
// public boolean isSelectedListNull() {
// return selectedList == null;
// }
-
- /**
- * Méthode d'initialisation des listes de favoris.
- */
- void onActivate() {
- evenOdd = new EvenOdd();
-// if (userExists) {
-// lists = serviceList.findPersonListByUser(user.getId());
-// }
-// newList = new PersonListDTO();
-// newAccount = new PollAccountDTO();
- }
-
- /**
- * Initialisation de l'affichage
- */
- void setupRender() {
- address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
- new AddressBarItem(title, null) };
-
- listModel = beanModelSource.createDisplayModel(PollAccount.class,
- componentResources.getMessages());
- listModel.add("functions", null);
- listModel.include("votingId", "email", "functions");
- }
}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -77,7 +77,7 @@
// }
// }
// }
- return poll.getUId();
+ return poll.getUid();
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -13,10 +13,8 @@
*
* 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.services;
-import java.util.Locale;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
@@ -29,10 +27,11 @@
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.services.ApplicationStateContribution;
import org.apache.tapestry5.services.ApplicationStateCreator;
+import org.apache.tapestry5.services.BindingFactory;
+import org.apache.tapestry5.services.BindingSource;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.PollenContextImpl;
import org.chorem.pollen.entity.UserAccount;
-import org.chorem.pollen.entity.UserAccountImpl;
import org.chorem.pollen.service.ServiceEmail;
import org.chorem.pollen.service.ServiceEmailImpl;
import org.chorem.pollen.service.ServicePoll;
@@ -103,9 +102,9 @@
public static void contributeRegistryStartup(
OrderedConfiguration<Runnable> configuration,
ServiceUser serviceUser,
- PollenManager manager,
+ PollenManager manager,
RegistryShutdownHub shutdownHub) {
-
+
if (logger.isInfoEnabled()) {
logger.info("Execute contributeRegistryStartup");
}
@@ -186,10 +185,10 @@
configuration.add(
new CoercionTuple<String, PollUri>(
- String.class, PollUri.class, coercion1));
+ String.class, PollUri.class, coercion1));
configuration.add(
new CoercionTuple<PollUri, String>(
- PollUri.class, String.class, coercion2));
+ PollUri.class, String.class, coercion2));
}
/**
@@ -204,16 +203,13 @@
// .getComponentResources().getMessages();
// return new BackgroundWorkerImpl(messages, servicePoll, context);
// }
-
-
/**
* Used to instanciate SessionState UserAccount when session expires.
*
* @param configuration to add the ApplicationStateCreator.
* @param serviceUser to instantiate user
*/
- public void contributeApplicationStateManager(MappedConfiguration<Class<?>,
- ApplicationStateContribution> configuration,
+ public void contributeApplicationStateManager(MappedConfiguration<Class<?>, ApplicationStateContribution> configuration,
final ServiceUser serviceUser) {
if (logger.isInfoEnabled()) {
logger.info("Execute contributeApplicationStateManager");
@@ -221,13 +217,20 @@
ApplicationStateCreator<UserAccount> creator =
new ApplicationStateCreator<UserAccount>() {
- @Override
- public UserAccount create() {
- return serviceUser.getNewUser();
- }
- };
+ @Override
+ public UserAccount create() {
+ return serviceUser.getNewUser();
+ }
+ };
+
configuration.add(UserAccount.class,
new ApplicationStateContribution("session", creator));
}
+
+ public static void contributeBindingSource(
+ MappedConfiguration<String, BindingFactory> configuration,
+ BindingSource bindingSource) {
+ configuration.add("format", new FormatBindingFactory(bindingSource));
+ }
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,72 @@
+package org.chorem.pollen.ui.services;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tapestry5.Binding;
+import org.apache.tapestry5.internal.bindings.AbstractBinding;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.ioc.Messages;
+
+/**
+ * From <http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix>
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ */
+public class FormatBinding extends AbstractBinding {
+
+ private final Messages messages;
+ private final boolean invariant;
+ private final List<Binding> keyBindings;
+ private final List<Binding> valueBindings;
+
+ public FormatBinding(Location location, Messages messages, boolean invariant,
+ ArrayList<Binding> keyBindings, List<Binding> valueBindings) {
+ super(location);
+
+ this.messages = messages;
+ this.invariant = invariant;
+ this.keyBindings = keyBindings;
+ this.valueBindings = valueBindings;
+ }
+
+ public FormatBinding(Location location, Messages messages, boolean invariant, ArrayList<Binding> keyBindings) {
+ super(location);
+
+ this.messages = messages;
+ this.invariant = invariant;
+ this.keyBindings = keyBindings;
+ this.valueBindings = null;
+ }
+
+ @Override
+ public Object get() {
+ String key = "";
+ for (Binding keyBinding : keyBindings) {
+ key += keyBinding.get();
+ }
+
+ if (null == valueBindings) {
+ return messages.get(key);
+ }
+
+ List<Object> values = new ArrayList<Object>(valueBindings.size());
+ for (Binding valueBinding : valueBindings) {
+ values.add(valueBinding.get());
+ }
+
+ return messages.format(key, values.toArray());
+ }
+
+ @Override
+ public boolean isInvariant() {
+ return this.invariant;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<?> getBindingType() {
+ return String.class;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBinding.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,79 @@
+package org.chorem.pollen.ui.services;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.tapestry5.Binding;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.services.BindingFactory;
+import org.apache.tapestry5.services.BindingSource;
+
+/**
+ * From <http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix>
+ *
+ * Created: 27 avr. 2010
+ *
+ * @author fdesbois
+ */
+public class FormatBindingFactory
+ implements BindingFactory {
+
+ private static final String SEPARATOR = "=";
+ private static final String DELIMITER = ",";
+ private static final String KEY_PREFIX = BindingConstants.LITERAL;
+ private static final String VALUE_PREFIX = BindingConstants.PROP;
+ private final BindingSource bindingSource;
+
+ public FormatBindingFactory(BindingSource bindingSource) {
+ this.bindingSource = bindingSource;
+ }
+
+ @Override
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location) {
+ int separatorIndex = expression.indexOf(SEPARATOR);
+
+ if (-1 == separatorIndex) {
+ List<String> keys = Arrays.asList(expression.split(DELIMITER));
+
+ ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location);
+
+ boolean invariant = isInvariant(keyBindings);
+ return new FormatBinding(location, container.getMessages(), invariant, keyBindings);
+ }
+
+ List<String> keys = Arrays.asList(expression.substring(0, separatorIndex).split(DELIMITER));
+ ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location);
+
+ List<String> values = Arrays.asList(expression.substring(separatorIndex + 1).split(DELIMITER));
+ ArrayList<Binding> valueBindings = createBindings(description, container, component, VALUE_PREFIX, values,
+ location);
+
+ boolean invariant = isInvariant(keyBindings) && isInvariant(valueBindings);
+ return new FormatBinding(location, container.getMessages(), invariant, keyBindings, valueBindings);
+ }
+
+ private ArrayList<Binding> createBindings(String description, ComponentResources container,
+ ComponentResources component, String defaultPrefix,
+ List<String> expressions, Location location) {
+ ArrayList<Binding> bindings = new ArrayList<Binding>(expressions.size());
+
+ for (String expression : expressions) {
+ bindings.add(bindingSource.newBinding(description, container, component, defaultPrefix, expression, location));
+ }
+
+ return bindings;
+ }
+
+ private boolean isInvariant(ArrayList<Binding> bindings) {
+ for (Binding binding : bindings) {
+ if (!binding.isInvariant()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/FormatBindingFactory.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-04-27 16:29:41 UTC (rev 2976)
@@ -33,7 +33,6 @@
import org.chorem.pollen.PollenContext;
import org.chorem.pollen.PollenProperty;
import org.chorem.pollen.service.ServiceUser;
-import org.chorem.pollen.ui.base.PollenPage;
import org.nuiton.util.ApplicationConfig;
import org.slf4j.Logger;
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-04-27 16:29:41 UTC (rev 2976)
@@ -1,12 +1,16 @@
############################ PAGES #############################################
pollen.page.AdminUsers.title=Gestion des utilisateurs
+pollen.page.UserLists.title=Vos listes de votants
############################ EMAIL #############################################
pollen.email.userRegister.subject=[Pollen] Confirmation de cr\u00E9ation du compte %s
pollen.email.userRegister.content=Bienvenue %1$s. Vous venez de cr\u00E9er un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant : %2$s\nMot de passe : %3$s\n\nVous pouvez d\u00E8s maintenant g\u00E9rer vos sondages en vous identifiant sur le site : \n%4$s
############################ GLOBAL ############################################
-pollen.ui.help.title=Aide
+pollen.ui.tooltip.help=Aide
+pollen.ui.button.add=Ajouter
+pollen.ui.button.create=Cr\u00E9er
+pollen.ui.button.ok=Ok
############################ USER ##############################################
pollen.ui.user.register.autoConnection=Vous \u00EAtes maintenant connect\u00E9 avec l'identifiant %1$s.
@@ -15,26 +19,38 @@
pollen.ui.user.update.success=Modification enregistr\u00E9e avec succ\u00E8s.
pollen.ui.user.display.notConnected=Vous devez vous connecter pour acc\u00E9der \u00E0 cette page.
pollen.ui.user.display.notAllowed=Vous n'avez pas les droits n\u00E9cessaires pour acc\u00E9der \u00E0 cette page.
-pollen.ui.user.create=Ajouter
pollen.ui.user.create.title=Cr\u00E9er un nouvel utilisateur
pollen.ui.user.create.passwordGenerated=Le mot de passe du nouvel utilisateur a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9.
pollen.ui.user.create.passwordSameAsLogin=Le mot de passe du nouvel utilisateur est le m\u00EAme que son identifiant.
-pollen.ui.user.create.password.help=Si vous pr\u00E9cisez un email, un mot de passe sera g\u00E9n\u00E9r\u00E9 et envoy\u00E9 \u00E0 l'utilisateur. Sinon le mot de passe sera identique au login.
+pollen.ui.user.create.passwordHelp=Si vous pr\u00E9cisez un email, un mot de passe sera g\u00E9n\u00E9r\u00E9 et envoy\u00E9 \u00E0 l'utilisateur. Sinon le mot de passe sera identique au login.
pollen.ui.user.create.sendEmail=Un email a \u00E9t\u00E9 envoy\u00E9 au nouvel utilisateur %1$s \u00E0 l'adresse %2$s.
pollen.ui.user.create.emailFailedShowPassword=Le mot de passe g\u00E9n\u00E9r\u00E9 est le suivant : %1$s
pollen.ui.user.create.success=L'utilisateur %1$s a \u00E9t\u00E9 cr\u00E9\u00E9 avec succ\u00E8s.
+pollen.ui.user.nbUsers=%1$d utilisateurs existants.
pollen.ui.user.update.edit=Modifier cet utilisateur.
pollen.ui.user.update.save=Enregistrer les modifications.
pollen.ui.user.update.cancel=Annuler les changements.
pollen.ui.user.delete=Supprimer cet utilisateur.
pollen.ui.user.delete.confirmMessage=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer cet utilisateur ?
+pollen.ui.list.create.title=Cr\u00E9er une nouvelle liste
+pollen.ui.list.create.success=La liste %1$s a \u00E9t\u00E9 cr\u00E9\u00E9e avec succ\u00E8s.
+pollen.ui.list.update.notSelected=Aucune liste s\u00E9lectionn\u00E9e.
+pollen.ui.list.update.emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
+pollen.ui.list.update.addAccount=Ajouter un nouvel utilisateur \u00E0 la liste
# FORM:: user
firstName-label=Pr\u00E9nom
lastName-label=Nom
login-label=Identifiant
email-label=Email
+email-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
+email-regexp-message=Adresse email invalide.
+# FORM:: favorite list
+listSelect-label= Liste
+listName-label= Nom
+name-label= Nom
+
############################ CHOICE ############################################
pollen.ui.choice.delete.confirm=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer ce choix ?
pollen.ui.choice.delete.title=Supprimer ce choix
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+ <t:zone t:id="createZone" t:update="show">
+ <form t:type="form" t:id="createList" action="tapestry" t:zone="createZone">
+ <div id="createListFormDiv">
+ <t:errors/>
+ <fieldset>
+ <legend>${message:pollen.ui.list.create.title}</legend>
+ <div>
+ <label t:type="label" for="listName" />* :
+ <input t:type="textfield" t:id="listName" value="newFavoriteList.name" t:validate="required"/>
+ </div>
+ <!-- <div>
+ <t:label for="accountsFile" />
+ <input t:type="upload" t:id="accountsFile" />
+ <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsFile-help}" effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:help}"/>
+ </span>
+ </div>
+ <div>
+ <t:label for="accountsUrl" />
+ <t:textfield t:id="accountsUrl" t:value="accountsUrl" />
+ <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsUrl-help}" effect="appear">
+ <img src="${asset:context:img/help.png}" alt="${message:help}"/>
+ </span>
+ </div>-->
+ <div class="buttons">
+ <input t:type="submit" value="${message:pollen.ui.button.create}"/>
+ </div>
+ </fieldset>
+ </div>
+ </form>
+ </t:zone>
+</body>
Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsCreate.tml
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml (rev 0)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml 2010-04-27 16:29:41 UTC (rev 2976)
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<body xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+ <t:zone t:id="updateZone" show="show" update="show">
+
+ <form t:type="form" t:id="selectListForm" action="tapestry">
+ <div>
+ ${message:listSelect-label}:
+ <select t:id="listSelect" t:type="ck/beanSelect" t:list="source" t:value="favoriteListSelected"
+ t:labelField="literal:name" t:valueField="literal:name" />
+ <input t:type="submit" value="${message:pollen.ui.button.ok}"/>
+ </div>
+ </form>
+
+ <t:if test="canDisplayAccounts()">
+ <!-- Display all Accounts child of favoriteListSelected -->
+ <div t:type="grid" t:source="favoriteListSelected.child" t:row="account"
+ t:include="name, email, weight" t:add="actions"
+ t:rowsPerPage="20" t:rowClass="prop:evenodd.next" t:inPlace="true">
+ <p:actionsCell>
+ <a t:type="actionlink" t:id="removeAccount" t:context="account.UId">
+ <img src="${asset:context:img/delete.png}" alt="${message:pollen.ui.list.remove}"/>
+ </a>
+ </p:actionsCell>
+ <p:empty>
+ ${message:pollen.ui.list.update.emptyList}
+ </p:empty>
+ </div>
+
+ <!-- Add a new PollAccount to favoriteListSelected -->
+ <form t:type="form" t:id="addAccount" t:zone="updateZone" action="tapestry">
+ <table class="t-data-grid">
+ <tr>
+ <td class="votingId">
+ <input t:type="textfield" t:id="name" t:value="newAccount.name" t:validate="required" size="10"/>
+ </td>
+ <td class="email">
+ <input t:type="textfield" t:id="email" t:value="newAccount.email" t:validate="email" size="15"/>
+ </td>
+ <td class="weight">
+ <input t:type="textfield" t:id="weight" t:value="newAccount.weight" size="5"/>
+ </td>
+ <td class="functions">
+ <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.list.update.addAccount}"/>
+ </td>
+ </tr>
+ </table>
+ <t:errors/>
+ </form>
+
+ <!-- Delete the favoriteListSelected -->
+<!-- <p>
+ <a t:type="actionlink" t:id="deleteList">
+ <img src="${asset:context:img/delete.png}" alt="Delete"/>${message:deleteList}
+ </a>
+ </p>-->
+
+ <p:else>
+ ${message:pollen.ui.list.update.notSelected}
+ </p:else>
+ </t:if>
+
+ </t:zone>
+</body>
Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/UserListsUpdate.tml
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties 2010-04-27 16:29:41 UTC (rev 2976)
@@ -1,31 +1,31 @@
-title=Vos listes de votants
-accountExists=L'identifiant de vote %s existe d\u00E9j\u00E0 dans cette liste.
-listExists=La liste %s existe d\u00E9j\u00E0.
-invalidCsv=Le fichier %s n'est pas un fichier CSV.
-noAccountCsv=Le fichier %s ne contient aucune entr\u00E9e valide.
-noAccountLdap=L'URL %s ne permet pas d'obtenir d'entr\u00E9es valides.
-noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir acc\u00E9der \u00E0 vos listes de votants.\n Veuillez remplir le formulaire ci-dessous.
-noList=Aucune liste s\u00E9lectionn\u00E9e.
-emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
-listSelect-label=Liste
-listDeleted=La liste %s a \u00E9t\u00E9 supprim\u00E9e.
-listNotDeleted=Erreur lors de la suppression de la liste %s.
-
-#list
-votingId-label=Nom
-votingId-required-message=Vous devez fournir un nom.
-email-label=Em@il
-email-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
-email-regexp-message=Adresse email invalide.
-email-required-message=Vous devez fournir une adresse email.
-functions-label=Fonctions
-deleteList=Supprimer la liste
-
-#new list
-createListLegend=Cr\u00E9er une nouvelle liste
-listName-label=Nom *
-listName-required-message=Vous devez fournir un nom.
-accountsFile-label=Import CSV
-accountsFile-help=Vous pouvez importer une liste \u00E0 partir d'un fichier CSV contenant un votant par ligne (nom, email)
-accountsUrl-label=Import LDAP
-accountsUrl-help=Vous pouvez importer une liste en utilisant une URL de recherche LDAP (ldap[s]://<hostname>:<port>/<base_dn>?<attributes>?<scope>?<filter>) Les entr\u00E9es doivent contenir les attributs cn et mail
\ No newline at end of file
+#title=Vos listes de votants
+#accountExists=L'identifiant de vote %s existe d\u00E9j\u00E0 dans cette liste.
+#listExists=La liste %s existe d\u00E9j\u00E0.
+#invalidCsv=Le fichier %s n'est pas un fichier CSV.
+#noAccountCsv=Le fichier %s ne contient aucune entr\u00E9e valide.
+#noAccountLdap=L'URL %s ne permet pas d'obtenir d'entr\u00E9es valides.
+#noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir acc\u00E9der \u00E0 vos listes de votants.\n Veuillez remplir le formulaire ci-dessous.
+#noList=Aucune liste s\u00E9lectionn\u00E9e.
+#emptyList=Liste vide. Ajoutez des votants en saisissant leur nom et email.
+#listSelect-label=Liste
+#listDeleted=La liste %s a \u00E9t\u00E9 supprim\u00E9e.
+#listNotDeleted=Erreur lors de la suppression de la liste %s.
+#
+##list
+#votingId-label=Nom
+#votingId-required-message=Vous devez fournir un nom.
+#email-label=Em@il
+#email-regexp=^([a-zA-Z0-9_.+-])+(a)(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$
+#email-regexp-message=Adresse email invalide.
+#email-required-message=Vous devez fournir une adresse email.
+#functions-label=Fonctions
+#deleteList=Supprimer la liste
+#
+##new list
+#createListLegend=Cr\u00E9er une nouvelle liste
+#listName-label=Nom *
+#listName-required-message=Vous devez fournir un nom.
+#accountsFile-label=Import CSV
+#accountsFile-help=Vous pouvez importer une liste \u00E0 partir d'un fichier CSV contenant un votant par ligne (nom, email)
+#accountsUrl-label=Import LDAP
+#accountsUrl-help=Vous pouvez importer une liste en utilisant une URL de recherche LDAP (ldap[s]://<hostname>:<port>/<base_dn>?<attributes>?<scope>?<filter>) Les entr\u00E9es doivent contenir les attributs cn et mail
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/webapp/admin/AdminUsers.tml 2010-04-27 16:29:41 UTC (rev 2976)
@@ -3,7 +3,7 @@
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<h1 class="titleIndex">${title}</h1>
-
+ <p class="center"><strong>${format:pollen.ui.user.nbUsers=accounts.availableRows}</strong></p>
<t:zone t:id="usersZone" t:update="show">
<t:form t:id="usersForm" t:zone="usersZone">
<t:if t:test="accountEdited">
@@ -71,10 +71,10 @@
<input t:type="textfield" t:id="newLogin" value="newUser.login" t:validate="required" />
<label t:type="label" for="newEmail">${message:email-label}</label> :
<input t:type="textfield" t:id="newEmail" value="newUser.email" t:validate="regexp" />
- <span t:type="ck/Tooltip" title="message:pollen.ui.help.title" t:value="message:pollen.ui.user.create.password.help" t:effect="appear">
+ <span t:type="ck/Tooltip" title="message:pollen.ui.tooltip.help" t:value="message:pollen.ui.user.create.passwordHelp" t:effect="appear">
<img src="${asset:context:img/help.png}" alt="message:help"/>
</span>
- <input t:type="submit" value="${message:pollen.ui.user.create}" title="${message:pollen.ui.user.create.title}" />
+ <input t:type="submit" value="${message:pollen.ui.button.add}" title="${message:pollen.ui.user.create.title}" />
</p>
</form>
</t:zone>
Modified: trunk/pollen-ui/src/main/webapp/css/lists.css
===================================================================
--- trunk/pollen-ui/src/main/webapp/css/lists.css 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/webapp/css/lists.css 2010-04-27 16:29:41 UTC (rev 2976)
@@ -25,11 +25,11 @@
text-align: left;
}
-#createListFormDiv label {
+/*#createListFormDiv label {
display: block;
width: 80px;
float: left;
-}
+}*/
#createListForm div {
margin-bottom: 10px;
Modified: trunk/pollen-ui/src/main/webapp/user/UserLists.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-04-27 16:29:41 UTC (rev 2976)
@@ -1,110 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<t:border t:addressBar="addressBar" t:pageLogo="literal:Creation" t:pageTitle="prop:title"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-<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}</h1>
- <t:if test="userExists">
- <div id="listsDiv">
-
- <t:unless test="listsNull">
- <t:zone t:id="listsZone" show="show" update="show">
-
-
- <!-- Sélection de la liste -->
- <t:form id="selectListForm">
- <div>
- ${message:listSelect-label}:
- <select t:id="listSelect" t:type="ck/BeanSelect" t:list="lists" t:value="selectedList"
- t:labelField="literal:name" t:valueField="literal:name" />
- <t:submit t:id="submitListsForm" t:value="${message:ok}"/>
- </div>
- </t:form>
-
- <t:if test="selectedListNull">
- ${message:noList}
- <p:else>
-
+ <h1 class="titleCreation">${title}</h1>
+ <div id="listsDiv">
- <!-- Affichage de la liste -->
- <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">
- <img src="${asset:context:img/delete.png}" alt="${message:delete}"/>
- </t:actionlink>
- </p:functionsCell>
- <p:empty>
- ${message:emptyList}
- </p:empty>
- </t:grid>
-
- <!-- Création d'un compte -->
- <t:form t:id="createAccountForm" t:zone="listsZone">
- <table class="t-data-grid">
- <tr>
- <td class="votingId">
- <t:textfield t:id="votingId" t:value="newAccount.votingId" t:validate="required" size="10"/>
- </td>
- <td class="email">
- <t:textfield t:id="email" t:value="newAccount.email" t:validate="required,regexp" size="15"/>
- </td>
- <td class="functions">
- <t:submit t:id="submitCreateAccountForm" t:value="${message:add}"/>
- </td>
- </tr>
- </table>
- <t:errors/>
- </t:form>
-
- <!-- Suppression de la liste -->
- <t:actionlink t:id="deleteList">
- <img src="${asset:context:img/delete.png}"/>${message:deleteList}
- </t:actionlink>
-
- </p:else>
- </t:if>
-
- </t:zone>
- </t:unless>
-
-
- <!-- Création d'une liste -->
- <t:form t:id="createListForm">
- <div id="createListFormDiv">
- <t:errors/>
- <FieldSet>
- <legend>${message:createListLegend}</legend>
- <div>
- <t:label for="listName" />
- <t:textfield t:id="listName" t:value="newList.name" t:validate="required"/>
- </div>
- <div>
- <t:label for="accountsFile" />
- <input t:type="upload" t:id="accountsFile" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsFile-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div>
- <t:label for="accountsUrl" />
- <t:textfield t:id="accountsUrl" t:value="accountsUrl" />
- <span t:type="ck/Tooltip" title="${message:help}" value="${message:accountsUrl-help}" effect="appear">
- <img src="${asset:context:img/help.png}" alt="${message:help}"/>
- </span>
- </div>
- <div class="buttons">
- <t:submit t:id="submitCreateListForm" t:value="${message:create}"/>
- </div>
- </FieldSet>
- </div>
- </t:form>
-
+ <t:if test="favoriteLists">
+ <t:userListsUpdate t:source="favoriteLists" />
+ </t:if>
- </div>
- <p:else>
- <h4>${message:noUser}</h4>
- <t:LoginComponent />
- </p:else>
- </t:if>
+ <t:userListsCreate />
+
+ </div>
</t:border>
\ No newline at end of file
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-26 14:12:40 UTC (rev 2975)
+++ trunk/pom.xml 2010-04-27 16:29:41 UTC (rev 2976)
@@ -309,8 +309,8 @@
<!-- customized versions -->
<!--javadoc.version>2.4</javadoc.version-->
- <topia.version>2.3.3</topia.version>
- <eugene.version>2.0.1</eugene.version>
+ <topia.version>2.4-SNAPSHOT</topia.version>
+ <eugene.version>2.0.2-SNAPSHOT</eugene.version>
<i18n.version>1.2.1</i18n.version>
<tapestry.version>5.1.0.5</tapestry.version>
<nuiton-utils.version>1.2.2</nuiton-utils.version>
2
1