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
July 2012
- 1 participants
- 16 discussions
r3576 - in trunk/pollen-services: . src/main/java/org/chorem/pollen/services src/main/java/org/chorem/pollen/services/exceptions src/main/java/org/chorem/pollen/services/impl src/main/resources/i18n src/test/java/org/chorem/pollen/services/impl
by tchemit@users.chorem.org 31 Jul '12
by tchemit@users.chorem.org 31 Jul '12
31 Jul '12
Author: tchemit
Date: 2012-07-31 18:17:34 +0200 (Tue, 31 Jul 2012)
New Revision: 3576
Url: http://chorem.org/repositories/revision/pollen/3576
Log:
refs #715: Import voting users list doesn't work (review and fix csv import + remove 3 classes :)
Removed:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteListImport.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportCSV.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportLDAP.java
Modified:
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListImportException.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/pom.xml 2012-07-31 16:17:34 UTC (rev 3576)
@@ -84,10 +84,6 @@
<artifactId>nuiton-utils</artifactId>
</dependency>
<dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-csv</artifactId>
- </dependency>
- <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
</dependency>
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteListImport.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteListImport.java 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/FavoriteListImport.java 2012-07-31 16:17:34 UTC (rev 3576)
@@ -1,57 +0,0 @@
-/*
- * #%L
- * Pollen :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.services;
-
-import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.services.exceptions.FavoriteListImportException;
-import org.chorem.pollen.services.impl.FavoriteListImportCSV;
-import org.chorem.pollen.services.impl.FavoriteListImportLDAP;
-
-import java.util.List;
-
-/**
- * Used to import a favorite List or a List of {@link PollAccount} from a given
- * source url (file, external service, ...)
- * <p/>
- * Created: 16/04/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- * @see FavoriteListImportLDAP
- * @see FavoriteListImportCSV
- * @since 1.3
- */
-public interface FavoriteListImport {
-
- /**
- * Execute the import from given {@code url}. This will returned the
- * successful list of {@link PollAccount} instanciated during import. No
- * database save is done here, only the extraction from an input url to
- * a list of entities to manage.
- *
- * @param url Url of the file or service that contains data to import
- * @return the List of PollAccount imported
- * @throws FavoriteListImportException for any import error
- */
- public List<PollAccount> execute(String url)
- throws FavoriteListImportException;
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListImportException.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListImportException.java 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/exceptions/FavoriteListImportException.java 2012-07-31 16:17:34 UTC (rev 3576)
@@ -22,8 +22,6 @@
*/
package org.chorem.pollen.services.exceptions;
-import org.chorem.pollen.services.FavoriteListImport;
-
import java.util.Locale;
import static org.nuiton.i18n.I18n._;
@@ -31,7 +29,7 @@
import static org.nuiton.i18n.I18n.n_;
/**
- * Exception during {@link FavoriteListImport#execute(String)} error. There is
+ * Exception during favorite list import. There is
* always a cause from librairies used for import.
*
* @author fdesbois <desbois(a)codelutin.com>
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportCSV.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportCSV.java 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportCSV.java 2012-07-31 16:17:34 UTC (rev 3576)
@@ -1,184 +0,0 @@
-/*
- * #%L
- * Pollen :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.services.impl;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.services.FavoriteListImport;
-import org.chorem.pollen.services.PollenServicePredicates;
-import org.chorem.pollen.services.PollenServiceSupport;
-import org.chorem.pollen.services.exceptions.FavoriteListImportException;
-import org.nuiton.util.StringUtil;
-import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportModel;
-import org.nuiton.util.csv.ImportRuntimeException;
-import org.nuiton.util.csv.ImportableColumn;
-import org.nuiton.util.csv.ModelBuilder;
-import org.nuiton.util.csv.ValueParser;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.Reader;
-import java.text.ParseException;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Implementation of {@link FavoriteListImport} as a service for CSV import.
- * Nuiton-CSV is used to manage the {@link Import} using a specific {@link
- * ImportModel} for pollen. Empty rows (no votingId or no email) are ignored.
- * <p/>
- * Created: 16/04/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- * @since 1.3
- */
-public class FavoriteListImportCSV extends PollenServiceSupport implements FavoriteListImport {
-
- private static final Log log = LogFactory.getLog(FavoriteListImportCSV.class);
-
- private static final ValueParser<String> EMAIL_PARSER = new ValueParser<String>() {
-
- @Override
- public String parse(String value) throws ParseException {
- if (value != null && !StringUtil.isEmail(value)) {
- throw new ParseException(_("pollen.error.email.invalid"), 0);
- }
- return value;
- }
- };
-
- protected class FavoriteListImportModel implements ImportModel<PollAccount> {
-
- @Override
- public char getSeparator() {
- return ',';
- }
-
- @Override
- public void pushCsvHeaderNames(List<String> headerNames) {
- }
-
- @Override
- public PollAccount newEmptyInstance() {
- return newInstance(getDAO(PollAccount.class));
- }
-
- @Override
- public Iterable<ImportableColumn<PollAccount, Object>> getColumnsForImport() {
- ModelBuilder modelBuilder = new ModelBuilder();
- modelBuilder.newMandatoryColumn(PollAccount.PROPERTY_VOTING_ID,
- PollAccount.PROPERTY_VOTING_ID);
- modelBuilder.newMandatoryColumn(PollAccount.PROPERTY_EMAIL,
- PollAccount.PROPERTY_EMAIL,
- EMAIL_PARSER);
- return modelBuilder.getColumnsForImport();
- }
- }
-
- @Override
- public List<PollAccount> execute(String url) throws FavoriteListImportException {
-
- List<PollAccount> results;
- Reader reader = null;
- try {
- reader = new FileReader(new File(url));
-
- Import<PollAccount> csvImport = Import.newImport(new FavoriteListImportModel(), reader);
-
- // Filter on empty account (without email or votingId)
- results = Lists.newArrayList(
- Iterables.filter(csvImport,
- PollenServicePredicates.POLL_ACCOUNT_NOT_EMPTY)
- );
-
- if (log.isInfoEnabled()) {
- log.info(results.size() + " comptes importés.");
- }
-
- } catch (FileNotFoundException ex) {
- throw new PollenTechnicalException(ex);
-
- } catch (ImportRuntimeException ex) {
- if (log.isDebugEnabled()) {
- log.debug("Error during CSV import", ex);
- }
- throw new FavoriteListImportException("CSV", ex);
-
- } finally {
- IOUtils.closeQuietly(reader);
- }
- return results;
- }
-
-// @Override
-// public List<PollAccount> execute(String url) throws FavoriteListImportException {
-//
-// List<PollAccount> results;
-// Reader reader = null;
-// try {
-// reader = new FileReader(new File(url));
-//
-// // Définition de la stratégie de mapping
-// ColumnPositionMappingStrategy<PollAccountImpl> strat =
-// new ColumnPositionMappingStrategy<PollAccountImpl>();
-//
-// String[] columns = new String[] {
-// PollAccount.PROPERTY_VOTING_ID,
-// PollAccount.PROPERTY_EMAIL
-// };
-//
-// strat.setType(PollAccountImpl.class);
-// strat.setColumnMapping(columns);
-//
-// // Parsing du fichier CSV
-// CsvToBean<PollAccountImpl> csv = new CsvToBean<PollAccountImpl>();
-// List<PollAccount> importedData = Lists.<PollAccount>newArrayList(csv.parse(strat, reader));
-//
-// // Suppression des comptes null
-// results = Lists.newArrayList(
-// Iterables.filter(importedData,
-// PollenServicePredicates.POLL_ACCOUNT_NOT_EMPTY)
-// );
-//
-// if (log.isInfoEnabled()) {
-// log.info(results.size() + " comptes importés.");
-// }
-//
-// } catch (Exception ex) {
-// log.warn("Error during CSV import", ex);
-// throw new FavoriteListImportException(ex);
-//
-// } finally {
-// IOUtils.closeQuietly(reader);
-// }
-// return results;
-// }
-}
Deleted: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportLDAP.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportLDAP.java 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteListImportLDAP.java 2012-07-31 16:17:34 UTC (rev 3576)
@@ -1,121 +0,0 @@
-/*
- * #%L
- * Pollen :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.pollen.services.impl;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.business.persistence.PollAccountDAO;
-import org.chorem.pollen.services.FavoriteListImport;
-import org.chorem.pollen.services.PollenServiceSupport;
-import org.chorem.pollen.services.exceptions.FavoriteListImportException;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InitialDirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * LDAP Import of {@link PollAccount}. The behavior is the same than the one
- * from pollen 1.2.x
- * <p/>
- * TODO-fdesbois-2012-04-17 : tests and documentation
- * <p/>
- * Created: 16/04/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- * @since 1.3
- */
-public class FavoriteListImportLDAP extends PollenServiceSupport implements FavoriteListImport {
-
- private static final Log log = LogFactory.getLog(FavoriteListImportLDAP.class);
-
- @Override
- public List<PollAccount> execute(String url) throws FavoriteListImportException {
-
- long start = System.nanoTime();
-
- List<PollAccount> results = Lists.newArrayList();
- try {
-
- // Initialisation du contexte
- Properties env = new Properties();
-// if (server != null) {
-// env.put(Context.INITIAL_CONTEXT_FACTORY,
-// "com.sun.jndi.ldap.LdapCtxFactory");
-// env.put(Context.PROVIDER_URL, "ldap://" + server + "/");
-// }
- DirContext ictx = new InitialDirContext(env);
-
- // Recherche en profondeur
- SearchControls control = new SearchControls();
- control.setSearchScope(SearchControls.SUBTREE_SCOPE);
-
- // Création des comptes avec les résultats de la recherche
- NamingEnumeration<SearchResult> e = ictx.search(url, null,
- control);
- while (e.hasMore()) {
- SearchResult r = e.next();
-
- if (log.isDebugEnabled()) {
- log.debug("Result: " + r.getName() + "(object: "
- + r.getClassName() + ")");
- }
-
- Attribute nameAttr = r.getAttributes().get("cn");
- Attribute emailAttr = r.getAttributes().get("mail");
-
- if (nameAttr != null) {
- PollAccountDAO dao = getDAO(PollAccount.class);
- PollAccount account = newInstance(dao);
- account.setVotingId(nameAttr.get().toString());
- account.setEmail(emailAttr.get().toString());
- results.add(account);
-
- if (log.isDebugEnabled()) {
- log.debug("New account - name: "
- + nameAttr.get().toString() + ", email: "
- + emailAttr.get().toString());
- }
- }
- }
- } catch (NamingException ex) {
- log.error("Exception de nommage lors de l'import depuis LDAP", ex);
- throw new FavoriteListImportException("LDAP", ex);
- }
-
- long duration = (System.nanoTime() - start) / 1000000000;
- if (log.isInfoEnabled()) {
- log.info(results.size() + " comptes importés en " + duration
- + " sec.");
- }
-
- return results;
- }
-}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-07-31 16:17:34 UTC (rev 3576)
@@ -23,7 +23,11 @@
package org.chorem.pollen.services.impl;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.business.persistence.PersonList;
import org.chorem.pollen.business.persistence.PersonListDAO;
@@ -33,6 +37,7 @@
import org.chorem.pollen.business.persistence.UserAccountDAO;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.FavoriteListAlreadyExistException;
+import org.chorem.pollen.services.exceptions.FavoriteListImportException;
import org.chorem.pollen.services.exceptions.FavoriteListNotFoundException;
import org.chorem.pollen.services.exceptions.FavoriteListNotOwnedByUserException;
import org.chorem.pollen.services.exceptions.ParticipantAlreadyFoundInListException;
@@ -41,11 +46,31 @@
import org.chorem.pollen.services.exceptions.UserNotFoundException;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaFilterPagerUtil;
+import org.nuiton.util.StringUtil;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+import static org.nuiton.i18n.I18n.l_;
+
public class FavoriteService extends PollenServiceSupport {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(FavoriteService.class);
+
public List<PersonList> getFavoriteLists(UserAccount user,
TopiaFilterPagerUtil.FilterPagerBean pager) {
@@ -338,6 +363,134 @@
}
}
+ public List<PollAccount> importFromCsvfile(String filename,
+ File file) throws FavoriteListImportException {
+
+ List<PollAccount> results = Lists.newArrayList();
+ Locale locale = getLocale();
+ PollAccountDAO dao = getDAO(PollAccount.class);
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(file));
+ String line;
+ int lineNumber = 0;
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ if (StringUtils.isBlank(line) || line.startsWith("#")) {
+
+ // comment line
+ continue;
+ }
+ lineNumber++;
+
+ int spaceIndex = line.indexOf(' ');
+ String email;
+ String votingId;
+ if (spaceIndex == -1) {
+ // only email
+ email = line;
+ votingId = line;
+ } else {
+ // email + votingId
+ email = line.substring(0, spaceIndex);
+ votingId = line.substring(spaceIndex);
+ }
+ email = email.trim();
+ votingId = votingId.trim();
+
+ if (!StringUtil.isEmail(email)) {
+
+ // email is not valid
+ String error = l_(locale, "pollen.error.import.invalid.email", lineNumber, email);
+ throw new FavoriteListImportException(filename, error, null);
+ }
+
+ PollAccount account = newInstance(dao);
+ account.setEmail(email);
+ account.setVotingId(votingId);
+ results.add(account);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info(results.size() + " comptes importés.");
+ }
+ reader.close();
+
+ } catch (FileNotFoundException ex) {
+ // should never happens ?
+ throw new PollenTechnicalException(ex);
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close reader", e);
+ }
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return results;
+ }
+
+ public List<PollAccount> importFromLDAP(String url) throws FavoriteListImportException {
+
+ long start = System.nanoTime();
+
+ List<PollAccount> results = Lists.newArrayList();
+ try {
+
+ // Initialisation du contexte
+ Properties env = new Properties();
+// if (server != null) {
+// env.put(Context.INITIAL_CONTEXT_FACTORY,
+// "com.sun.jndi.ldap.LdapCtxFactory");
+// env.put(Context.PROVIDER_URL, "ldap://" + server + "/");
+// }
+ DirContext ictx = new InitialDirContext(env);
+
+ // Recherche en profondeur
+ SearchControls control = new SearchControls();
+ control.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ // Création des comptes avec les résultats de la recherche
+ NamingEnumeration<SearchResult> e = ictx.search(url, null,
+ control);
+ while (e.hasMore()) {
+ SearchResult r = e.next();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Result: " + r.getName() + "(object: "
+ + r.getClassName() + ")");
+ }
+
+ Attribute nameAttr = r.getAttributes().get("cn");
+ Attribute emailAttr = r.getAttributes().get("mail");
+
+ if (nameAttr != null) {
+ PollAccountDAO dao = getDAO(PollAccount.class);
+ PollAccount account = newInstance(dao);
+ account.setVotingId(nameAttr.get().toString());
+ account.setEmail(emailAttr.get().toString());
+ results.add(account);
+
+ if (log.isDebugEnabled()) {
+ log.debug("New account - name: "
+ + nameAttr.get().toString() + ", email: "
+ + emailAttr.get().toString());
+ }
+ }
+ }
+ } catch (NamingException ex) {
+ log.error("Exception de nommage lors de l'import depuis LDAP", ex);
+ throw new FavoriteListImportException("LDAP", ex);
+ }
+
+ long duration = (System.nanoTime() - start) / 1000000000;
+ if (log.isInfoEnabled()) {
+ log.info(results.size() + " comptes importés en " + duration
+ + " sec.");
+ }
+
+ return results;
+ }
+
public PersonList newFavoriteList() {
PersonListDAO dao = getDAO(PersonList.class);
PersonList personList = newInstance(dao);
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-07-31 16:17:34 UTC (rev 3576)
@@ -25,8 +25,8 @@
pollen.email.voteEmail.subject=[Pollen] Vote reporting (%s)
pollen.email.votingEmail.content=A new poll has been created\: "%s".\nYou can participate with the identifier %s by following this link\: \n%s
pollen.email.votingEmail.subject=[Pollen] Invitation to vote (%s)
-pollen.error.email.invalid=The email doesn't have the good format
pollen.error.import=Error during %1$s import \: %2$s
+pollen.error.import.invalid.email=At line %s, Email format is not valid '%s'
pollen.feed.addChoiceContent=
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
@@ -47,5 +47,4 @@
pollen.security.error.poll.free.creatorId.can.not.vote=Using a creator Id does not allow you to vote.
pollen.security.error.poll.not.closed.and.results.not.continuous=The poll is not closed and results are not continuous
pollen.security.error.poll.not.free.and.access.not.granted=You can not access to this non free poll
-pollen.security.error.poll.not.running.can.not.vote=You can not vote (poll is finished or not began).
pollen.security.error.poll.result.private.and.access.not.granted=Results of the poll are private and you do not have credentials to see them
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-07-31 16:17:34 UTC (rev 3576)
@@ -25,8 +25,8 @@
pollen.email.voteEmail.subject=[Pollen] Notification de vote (%s)
pollen.email.votingEmail.content=Un nouveau sondage a été créé \: "%s".\nVous pouvez y participer avec l'identifiant %s à l'adresse suivante \: \n%s
pollen.email.votingEmail.subject=[Pollen] Invitation au vote (%s)
-pollen.error.email.invalid=Email non valide
pollen.error.import=Erreur pendant l'import %1$s \: %2$s
+pollen.error.import.invalid.email=A la ligne %s, le courriel n'est pas valide '%s'
pollen.feed.addChoiceContent=
pollen.feed.addChoiceTitle=
pollen.feed.addCommentContent=%s
@@ -47,5 +47,4 @@
pollen.security.error.poll.free.creatorId.can.not.vote=L'utlisation du creatorId ne permet de voter.
pollen.security.error.poll.not.closed.and.results.not.continuous=Vous n'avez pas accès aux résultats de ce sondage (résultats non continus et sondage non fermé)
pollen.security.error.poll.not.free.and.access.not.granted=Vous n'avez pas accès à ce sondage restreint
-pollen.security.error.poll.not.running.can.not.vote=Vous n'êtes pas autorisé à voter (sondage terminé ou pas encore commencé).
pollen.security.error.poll.result.private.and.access.not.granted=Vous n'avez pas accès aux résultats privés de ce sondage
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java 2012-07-31 14:19:29 UTC (rev 3575)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/services/impl/FavoriteServiceTest.java 2012-07-31 16:17:34 UTC (rev 3576)
@@ -22,13 +22,19 @@
*/
package org.chorem.pollen.services.impl;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.commons.io.FileUtils;
+import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.services.AbstractPollenServiceTest;
+import org.chorem.pollen.services.exceptions.FavoriteListImportException;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import java.io.File;
+import java.util.List;
+
/**
* Tests the {@link FavoriteService}.
*
@@ -38,8 +44,6 @@
@Ignore
public class FavoriteServiceTest extends AbstractPollenServiceTest {
- /** Logger. */
- private static final Log log = LogFactory.getLog(FavoriteServiceTest.class);
@Override
@Before
@@ -105,4 +109,77 @@
}
+ @Test(expected = PollenTechnicalException.class)
+ public void executeImportCsvFileNotFound() throws Exception {
+
+ File importFile = getCsvImportFile();
+
+ FavoriteService service = newService(FavoriteService.class);
+
+ service.importFromCsvfile(importFile.getName(), importFile);
+ }
+
+ @Test(expected = FavoriteListImportException.class)
+ public void executeImportCsvInvalidEmail() throws Exception {
+
+ FavoriteService service = newService(FavoriteService.class);
+
+ File importFile = getCsvImportFile();
+
+ String importContent = "badEmail@ voterId";
+
+ FileUtils.write(importFile, importContent);
+
+ service.importFromCsvfile(importFile.getName(), importFile);
+ }
+
+ @Test
+ public void executeImportCsvEmptyContent() throws Exception {
+
+ FavoriteService service = newService(FavoriteService.class);
+
+ File importFile = getCsvImportFile();
+
+ String importContent = "";
+ FileUtils.write(importFile, importContent);
+
+ List<PollAccount> importedAccount = service.importFromCsvfile(importFile.getName(), importFile);
+
+ Assert.assertNotNull(importedAccount);
+ Assert.assertTrue(importedAccount.isEmpty());
+ }
+
+ @Test
+ public void executeImportCsv() throws Exception {
+
+ FavoriteService service = newService(FavoriteService.class);
+
+ File importFile = getCsvImportFile();
+
+ String importContent = "myemail(a)mydomain.uk voterId \n\t\t myemail2(a)mydomain.uk\r\r\n#Comment\n\n ";
+ FileUtils.write(importFile, importContent);
+
+ List<PollAccount> importedAccount = service.importFromCsvfile(importFile.getName(), importFile);
+
+ Assert.assertNotNull(importedAccount);
+ Assert.assertEquals(2, importedAccount.size());
+ assertPollAccount(importedAccount.get(0), "myemail(a)mydomain.uk", "voterId");
+ assertPollAccount(importedAccount.get(1), "myemail2(a)mydomain.uk", "myemail2(a)mydomain.uk");
+ }
+
+ protected void assertPollAccount(PollAccount pollAccount,
+ String expectedEmail,
+ String expectedVotingId) {
+ Assert.assertNotNull(pollAccount);
+ Assert.assertEquals(expectedEmail, pollAccount.getEmail());
+ Assert.assertEquals(expectedVotingId, pollAccount.getVotingId());
+
+ }
+
+ protected File getCsvImportFile() {
+ File temporaryDirectory = fakeContext.getConfiguration().getTemporaryDirectory();
+ File importFile = new File(temporaryDirectory, "import.csv");
+ return importFile;
+ }
+
}
1
0
r3575 - trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin
by tchemit@users.chorem.org 31 Jul '12
by tchemit@users.chorem.org 31 Jul '12
31 Jul '12
Author: tchemit
Date: 2012-07-31 16:19:29 +0200 (Tue, 31 Jul 2012)
New Revision: 3575
Url: http://chorem.org/repositories/revision/pollen/3575
Log:
fixes #722: Can not delete a user
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp 2012-07-31 12:52:15 UTC (rev 3574)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp 2012-07-31 14:19:29 UTC (rev 3575)
@@ -30,7 +30,7 @@
<fieldset class="ui-widget-content ui-corner-all">
<s:hidden key="redirectUrl" label=''/>
- <s:hidden key="userId" value='%{#user.topiaId}' label=''/>
+ <s:hidden key="userId" value='%{user.topiaId}' label=''/>
<s:text name="pollen.information.confirmDeleteUser"/>
<div align="center" style="padding-top: 1em;">
1
0
r3574 - trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl
by tchemit@users.chorem.org 31 Jul '12
by tchemit@users.chorem.org 31 Jul '12
31 Jul '12
Author: tchemit
Date: 2012-07-31 14:52:15 +0200 (Tue, 31 Jul 2012)
New Revision: 3574
Url: http://chorem.org/repositories/revision/pollen/3574
Log:
fixes #721: Can't change my account profile
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-07-31 10:54:49 UTC (rev 3573)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-07-31 12:52:15 UTC (rev 3574)
@@ -23,6 +23,7 @@
package org.chorem.pollen.services.impl;
import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -177,7 +178,8 @@
// In case of email change, check if an other user has not already
// the new email
// existing user found
- if (dao.isUserExist(user)) {
+ if (ObjectUtils.notEqual(user.getEmail(), userToUpdate.getEmail())
+ && dao.isUserExist(user)) {
throw new UserEmailAlreadyUsedException();
}
1
0
Author: tchemit
Date: 2012-07-31 12:54:49 +0200 (Tue, 31 Jul 2012)
New Revision: 3573
Url: http://chorem.org/repositories/revision/pollen/3573
Log:
refs #590: Refactor votecounting module (javadoc + some improvments)
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceIdAble.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java
trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java
trunk/pollen-votecounting-api/src/test/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategyProviderTest.java
trunk/pollen-votecounting-strategy-borda/src/main/java/org/chorem/pollen/votecounting/strategy/BordaStrategy.java
trunk/pollen-votecounting-strategy-condorcet/src/main/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategy.java
trunk/pollen-votecounting-strategy-coombs/src/main/java/org/chorem/pollen/votecounting/strategy/CoombsStrategy.java
trunk/pollen-votecounting-strategy-instant-runoff/src/main/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategy.java
trunk/pollen-votecounting-strategy-normal/src/main/java/org/chorem/pollen/votecounting/strategy/NormalStrategy.java
trunk/pollen-votecounting-strategy-number/src/main/java/org/chorem/pollen/votecounting/strategy/NumberStrategy.java
trunk/pollen-votecounting-strategy-percentage/src/main/java/org/chorem/pollen/votecounting/strategy/PercentageStrategy.java
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -439,7 +439,7 @@
public String getChoiceFragment() {
VoteCountingStrategy strategy = getVoteCountingStrategy(poll);
String result =
- "displayVote_" + strategy.getRenderType().name() + ".jsp";
+ "displayVote_" + strategy.getVoteValueEditorType().name() + ".jsp";
return result;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -102,7 +102,7 @@
int nbVotes = 0;
int totalValues = 0;
- VoteCountingStrategy voteCountingStrategy =
+ VoteCountingStrategy strategy =
getVoteCountingStrategy(getPoll());
boolean voteValid = true;
@@ -111,7 +111,7 @@
Integer value = voteToChoice.getVoteValue();
// check if vote is null ?
- boolean voteNull = voteCountingStrategy.isVoteValueNull(value);
+ boolean voteNull = strategy.isVoteValueNull(value);
if (voteNull) {
// null vote, can skip his validation
@@ -119,7 +119,7 @@
}
// check if vote value is valid ?
- boolean valid = voteCountingStrategy.isVoteValueValid(value);
+ boolean valid = strategy.isVoteValueValid(value);
if (valid) {
@@ -130,31 +130,11 @@
// not a valid vote value, mark it and skip other fields validation
String validMessage =
- voteCountingStrategy.getVoteValueNotValidMessage();
- addFieldError("vote.choices", _(validMessage));
+ strategy.getVoteValueNotValidMessage(getLocale());
+ addFieldError("vote.choices", validMessage);
voteValid = false;
break;
}
-
-// // XXX-fdesbois-2012-04-11 : for a VoteCountingType#NUMBER the difference between 0 and null value could be important
-// if (isCondorcetVoteCounting()) {
-// if (value > 0) {
-//
-// // for condorcet vote, must be strictly greater than 0
-// // see http://chorem.org/issues/574
-// // see http://chorem.org/issues/576
-// nbVotes++;
-// totalValues += value;
-// } else {
-//
-// addFieldError("vote.choices",
-// _("pollen.error.vote.invalidCondorcetVoteValue"));
-// }
-// // for other vote type, value must be > 0
-// } else if (value != 0) {
-// nbVotes++;
-// totalValues += value;
-// }
}
if (voteValid) {
@@ -166,20 +146,15 @@
}
// check that total vote value is ok
- if (!voteCountingStrategy.isTotalVoteValueValid(totalValues)) {
+ if (!strategy.isTotalVoteValueValid(totalValues)) {
// not valid
- String errorMessage = voteCountingStrategy.getTotalVoteValueNotValidMessage();
- addFieldError("vote.choices", _(errorMessage));
+ String errorMessage = strategy.getTotalVoteValueNotValidMessage(getLocale());
+ addFieldError("vote.choices", errorMessage);
}
}
-// // check for percentage that the sum of all values equals 100
-// if (isPercentageVoteCounting() && totalValues != 100) {
-// addFieldError("vote.choices", _("pollen.error.vote.percentage"));
-// }
}
- // @InputConfig(methodName = PREPARE_VOTE_PAGE)
@Override
public String execute() throws Exception {
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceIdAble.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceIdAble.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceIdAble.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -25,7 +25,7 @@
import com.google.common.base.Function;
/**
- * To mark any object with identify a choice via the {@link #getChoiceId()}
+ * To mark any object that identify a choice via the {@link #getChoiceId()}
* method.
*
* @author tchemit <chemit(a)codelutin.com>
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/ChoiceScore.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -59,13 +59,14 @@
}
public void addScoreValue(double scoreToAdd) {
+ BigDecimal newScoreValue;
if (scoreValue == null) {
- setScoreValue(BigDecimal.valueOf(scoreToAdd));
+ newScoreValue = BigDecimal.valueOf(scoreToAdd);
} else {
- setScoreValue(scoreValue.add(BigDecimal.valueOf(scoreToAdd)));
+ newScoreValue = scoreValue.add(BigDecimal.valueOf(scoreToAdd));
}
-
+ setScoreValue(newScoreValue);
}
public void setScoreValue(BigDecimal scoreValue) {
@@ -74,15 +75,18 @@
@Override
public int compareTo(ChoiceScore o) {
- BigDecimal v1 = scoreValue;
- BigDecimal v2 = o.scoreValue;
- if (v1 == null) {
- v1 = new BigDecimal(-1);
- }
- if (v2 == null) {
- v2 = new BigDecimal(-1);
- }
- int i = v1.subtract(v2).intValue();
- return i;
+ int i1 = scoreValue == null ? -1 : scoreValue.intValue();
+ int i2 = o.scoreValue == null ? -1 : o.scoreValue.intValue();
+ return i1 - i2;
+// BigDecimal v1 = scoreValue;
+// BigDecimal v2 = o.scoreValue;
+// if (v1 == null) {
+// v1 = new BigDecimal(-1);
+// }
+// if (v2 == null) {
+// v2 = new BigDecimal(-1);
+// }
+// int i = v1.subtract(v2).intValue();
+// return i;
}
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -56,7 +56,11 @@
GroupOfVoter result = new GroupOfVoter();
result.setVoterId(voterId);
result.setWeight(weight);
- result.setVoteForChoices(voteForChoices);
+ if (voters != null) {
+ for (VoteForChoice voteForChoice : voteForChoices) {
+ result.addVoteForChoice(voteForChoice);
+ }
+ }
result.setVoters(voters);
return result;
}
@@ -102,11 +106,6 @@
getVoteForChoices().add(voteForChoice);
}
- @Override
- public void setVoteForChoices(Set<VoteForChoice> voteForChoices) {
- this.voteForChoices = voteForChoices;
- }
-
public void setVoters(Set<Voter> voters) {
this.voters = voters;
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/SimpleVoter.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -49,7 +49,11 @@
SimpleVoter result = new SimpleVoter();
result.setVoterId(voterId);
result.setWeight(weight);
- result.setVoteForChoices(voteForChoices);
+ if (voteForChoices != null) {
+ for (VoteForChoice voteForChoice : voteForChoices) {
+ result.addVoteForChoice(voteForChoice);
+ }
+ }
return result;
}
@@ -86,9 +90,4 @@
this.weight = weight;
}
- @Override
- public void setVoteForChoices(Set<VoteForChoice> voteForChoices) {
- this.voteForChoices = voteForChoices;
- }
-
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/Voter.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -25,25 +25,52 @@
import java.util.Set;
/**
- * A voter (says a physical person which votes on a poll).
+ * A voter (can be a physical voter or a group of voters).
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.5
*/
public interface Voter {
+ /**
+ * Gets the voter unique id.
+ *
+ * @return the unique id of the voter.
+ */
String getVoterId();
+ /**
+ * Gets the weight of the voter.
+ *
+ * @return the weight to apply for this voter.
+ */
double getWeight();
+ /**
+ * Gets all the vote for choices registred for this voter.
+ *
+ * @return all the vote values registred for this voter
+ */
+ Set<VoteForChoice> getVoteForChoices();
+
+ /**
+ * Register a new vote value for this voter.
+ *
+ * @param voteForChoice new vote value to register for this voter
+ */
void addVoteForChoice(VoteForChoice voteForChoice);
- Set<VoteForChoice> getVoteForChoices();
-
+ /**
+ * Sets the voter id.
+ *
+ * @param voterId the new voter id to set
+ */
void setVoterId(String voterId);
+ /**
+ * Sets the voter weight.
+ *
+ * @param weight the new weight to set
+ */
void setWeight(double weight);
-
- void setVoteForChoices(Set<VoteForChoice> voteForChoices);
-
}
Modified: trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java
===================================================================
--- trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -66,25 +66,94 @@
*/
VoteCountingResult votecount(Set<Voter> voter);
+ /**
+ * Get the value to display for a given vote value in the vote page.
+ *
+ * @param voteValue the vote value to display
+ * @return the string representation of a vote value
+ */
String getDisplayVoteValue(Integer voteValue);
+ /**
+ * Test if the given value is a vote value (says users has filled it).
+ *
+ * @param voteValue the vote value to test
+ * @return {@code true} if the given value is persisted.
+ */
boolean isChoiceInVote(Integer voteValue);
+ /**
+ * Get the vote counting strategy name to display in UI.
+ *
+ * @param locale the locale used to render the strategy name
+ * @return the localized vote counting strategy name
+ */
String getStrategyName(Locale locale);
+ /**
+ * Get the vote counting strategy help to display in UI.
+ *
+ * @param locale the locale used to render the strategy name
+ * @return the localized vote counting strategy help
+ */
String getStrategyHelp(Locale locale);
+ /**
+ * Tests if the given vote value is valid.
+ *
+ * @param voteValue the vote value to test
+ * @return {@code true} if the given vote value is valid, {@code false}
+ * otherwise.
+ */
boolean isVoteValueValid(Integer voteValue);
- String getVoteValueNotValidMessage();
+ /**
+ * If a vote value is not valid, gets the localized message of the error.
+ *
+ * @param locale the locale used to render the error message
+ * @return the localized validation message
+ */
+ String getVoteValueNotValidMessage(Locale locale);
+ /**
+ * Tests if the total values of a vote is valid.
+ *
+ * @param totalValues the given total values
+ * @return {@code true} if the total values of a vote is valid,
+ * {@code false} otherwhise.
+ */
boolean isTotalVoteValueValid(int totalValues);
- String getTotalVoteValueNotValidMessage();
+ /**
+ * If the total values of a vote is not valid, gets the localized error
+ * message.
+ *
+ * @param locale the locale used to render the error message
+ * @return the localized validation message
+ */
+ String getTotalVoteValueNotValidMessage(Locale locale);
+ /**
+ * Tests if a given vote value is null or not.
+ *
+ * @param value the vote value to test
+ * @return {@code true} if the given vote value is null (or considered as
+ * null), {@code false} otherwise.
+ */
boolean isVoteValueNull(Integer value);
- ChoiceToVoteRenderType getRenderType();
+ /**
+ * Gets the type of editor used to render a vote value.
+ *
+ * @return the type of editor used to render a vote value.
+ * @see ChoiceToVoteRenderType
+ */
+ ChoiceToVoteRenderType getVoteValueEditorType();
+ /**
+ * @return {@code true} if display results by choice.
+ * @deprecated since 1.5 (result will be offered by the strategy it-self).
+ */
+ @Deprecated
boolean isDisplayResultsByChoice();
}
Modified: trunk/pollen-votecounting-api/src/test/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategyProviderTest.java
===================================================================
--- trunk/pollen-votecounting-api/src/test/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategyProviderTest.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-api/src/test/java/org/chorem/pollen/votecounting/strategy/VoteCountingStrategyProviderTest.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -36,7 +36,6 @@
protected static VoteCountingStrategyProvider provider;
-
@BeforeClass
public static void beforeClass() throws Exception {
provider = new VoteCountingStrategyProvider();
Modified: trunk/pollen-votecounting-strategy-borda/src/main/java/org/chorem/pollen/votecounting/strategy/BordaStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-borda/src/main/java/org/chorem/pollen/votecounting/strategy/BordaStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-borda/src/main/java/org/chorem/pollen/votecounting/strategy/BordaStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -30,9 +30,11 @@
import org.chorem.pollen.votecounting.model.Voter;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import static org.nuiton.i18n.I18n.l_;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -64,14 +66,14 @@
}
@Override
- public String getTotalVoteValueNotValidMessage() {
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
// no validation on total value, so no message
return null;
}
@Override
- public String getVoteValueNotValidMessage() {
- return n_("pollen.error.vote.invalidBordaVoteValue");
+ public String getVoteValueNotValidMessage(Locale locale) {
+ return l_(locale, "pollen.error.vote.invalidBordaVoteValue");
}
@Override
@@ -80,7 +82,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.TEXTFIELD;
}
Modified: trunk/pollen-votecounting-strategy-condorcet/src/main/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-condorcet/src/main/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-condorcet/src/main/java/org/chorem/pollen/votecounting/strategy/CondorcetStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -37,9 +37,11 @@
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import static org.nuiton.i18n.I18n.l_;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -71,14 +73,14 @@
}
@Override
- public String getTotalVoteValueNotValidMessage() {
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
// no validation on total value, so no message
return null;
}
@Override
- public String getVoteValueNotValidMessage() {
- return n_("pollen.error.vote.invalidCondorcetVoteValue");
+ public String getVoteValueNotValidMessage(Locale locale) {
+ return l_(locale, "pollen.error.vote.invalidCondorcetVoteValue");
}
@Override
@@ -87,7 +89,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.TEXTFIELD;
}
Modified: trunk/pollen-votecounting-strategy-coombs/src/main/java/org/chorem/pollen/votecounting/strategy/CoombsStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-coombs/src/main/java/org/chorem/pollen/votecounting/strategy/CoombsStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-coombs/src/main/java/org/chorem/pollen/votecounting/strategy/CoombsStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -36,10 +36,12 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
+import static org.nuiton.i18n.I18n.l_;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -71,14 +73,14 @@
}
@Override
- public String getTotalVoteValueNotValidMessage() {
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
// no validation on total value, so no message
return null;
}
@Override
- public String getVoteValueNotValidMessage() {
- return n_("pollen.error.vote.invalidCoombsVoteValue");
+ public String getVoteValueNotValidMessage(Locale locale) {
+ return l_(locale, "pollen.error.vote.invalidCoombsVoteValue");
}
@Override
@@ -87,7 +89,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.TEXTFIELD;
}
Modified: trunk/pollen-votecounting-strategy-instant-runoff/src/main/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-instant-runoff/src/main/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-instant-runoff/src/main/java/org/chorem/pollen/votecounting/strategy/InstantRunoffStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -35,10 +35,12 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
+import static org.nuiton.i18n.I18n.l_;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -72,14 +74,14 @@
}
@Override
- public String getTotalVoteValueNotValidMessage() {
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
// no validation on total value, so no message
return null;
}
@Override
- public String getVoteValueNotValidMessage() {
- return n_("pollen.error.vote.invalidInstantRunoffVoteValue");
+ public String getVoteValueNotValidMessage(Locale locale) {
+ return l_(locale, "pollen.error.vote.invalidInstantRunoffVoteValue");
}
@Override
@@ -88,7 +90,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.TEXTFIELD;
}
Modified: trunk/pollen-votecounting-strategy-normal/src/main/java/org/chorem/pollen/votecounting/strategy/NormalStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-normal/src/main/java/org/chorem/pollen/votecounting/strategy/NormalStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-normal/src/main/java/org/chorem/pollen/votecounting/strategy/NormalStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -28,6 +28,7 @@
import org.chorem.pollen.votecounting.model.VoteForChoice;
import org.chorem.pollen.votecounting.model.Voter;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -89,7 +90,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.CHECKBOX;
}
@@ -111,13 +112,13 @@
}
@Override
- public String getVoteValueNotValidMessage() {
+ public String getVoteValueNotValidMessage(Locale locale) {
// no validation on not null vote value, so no message
return null;
}
@Override
- public String getTotalVoteValueNotValidMessage() {
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
// no validation on total values, so no message
return null;
}
Modified: trunk/pollen-votecounting-strategy-number/src/main/java/org/chorem/pollen/votecounting/strategy/NumberStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-number/src/main/java/org/chorem/pollen/votecounting/strategy/NumberStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-number/src/main/java/org/chorem/pollen/votecounting/strategy/NumberStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -28,6 +28,7 @@
import org.chorem.pollen.votecounting.model.VoteForChoice;
import org.chorem.pollen.votecounting.model.Voter;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -89,7 +90,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.TEXTFIELD;
}
@@ -111,13 +112,13 @@
}
@Override
- public String getTotalVoteValueNotValidMessage() {
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
// no validation on total values, so no message
return null;
}
@Override
- public String getVoteValueNotValidMessage() {
+ public String getVoteValueNotValidMessage(Locale locale) {
// no validation on not null vote value, so no message
return null;
}
Modified: trunk/pollen-votecounting-strategy-percentage/src/main/java/org/chorem/pollen/votecounting/strategy/PercentageStrategy.java
===================================================================
--- trunk/pollen-votecounting-strategy-percentage/src/main/java/org/chorem/pollen/votecounting/strategy/PercentageStrategy.java 2012-07-31 07:16:34 UTC (rev 3572)
+++ trunk/pollen-votecounting-strategy-percentage/src/main/java/org/chorem/pollen/votecounting/strategy/PercentageStrategy.java 2012-07-31 10:54:49 UTC (rev 3573)
@@ -28,9 +28,11 @@
import org.chorem.pollen.votecounting.model.VoteForChoice;
import org.chorem.pollen.votecounting.model.Voter;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import static org.nuiton.i18n.I18n.l_;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -89,7 +91,7 @@
}
@Override
- public ChoiceToVoteRenderType getRenderType() {
+ public ChoiceToVoteRenderType getVoteValueEditorType() {
return ChoiceToVoteRenderType.TEXTFIELD;
}
@@ -110,14 +112,14 @@
}
@Override
- public String getVoteValueNotValidMessage() {
+ public String getVoteValueNotValidMessage(Locale locale) {
// no validation on not null vote value, so no message
return null;
}
@Override
- public String getTotalVoteValueNotValidMessage() {
- return n_("pollen.error.vote.percentage");
+ public String getTotalVoteValueNotValidMessage(Locale locale) {
+ return l_(locale, "pollen.error.vote.percentage");
}
public void addVoterChoices(Voter voter,
1
0
Author: tchemit
Date: 2012-07-31 09:16:34 +0200 (Tue, 31 Jul 2012)
New Revision: 3572
Url: http://chorem.org/repositories/revision/pollen/3572
Log:
fixes #720: Updates to nuiton-utils 2.5.2 + fix developer and contributors time zone in pom
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-07-07 19:41:27 UTC (rev 3571)
+++ trunk/pom.xml 2012-07-31 07:16:34 UTC (rev 3572)
@@ -46,7 +46,7 @@
<email>chatellier at codelutin.com</email>
<organization>CodeLutin</organization>
<organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>developer</role>
</roles>
@@ -57,7 +57,7 @@
<email>chemit at codelutin.com</email>
<organization>Code Lutin</organization>
<organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>lead</role>
<role>developer</role>
@@ -69,7 +69,7 @@
<email>couteau at codelutin.com</email>
<organization>Code Lutin</organization>
<organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>developer</role>
<role>technical writer</role>
@@ -81,7 +81,7 @@
<email>desbois at codelutin.com</email>
<organization>Code Lutin</organization>
<organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>developer</role>
</roles>
@@ -92,7 +92,7 @@
<email>morin at codelutin.com</email>
<organization>Code Lutin</organization>
<organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>developer</role>
</roles>
@@ -105,7 +105,7 @@
<email>nemawan(a)hotmail.com</email>
<organization>ALMA - Code Lutin</organization>
<organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Chef de Projet</role>
<role>Analyste</role>
@@ -117,7 +117,7 @@
<email>tpoulit(a)gmail.com</email>
<organization>ALMA - Code Lutin</organization>
<organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Analyste</role>
<role>Développeur</role>
@@ -128,7 +128,7 @@
<email>benouna66(a)gmail.com</email>
<organization>ALMA - Code Lutin</organization>
<organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Analyste</role>
<role>Développeur</role>
@@ -139,7 +139,7 @@
<email>zhykos(a)gmail.com</email>
<organization>ALMA - Code Lutin</organization>
<organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Architecte</role>
<role>Développeur</role>
@@ -150,7 +150,7 @@
<email>eddahbi(a)gmail.com</email>
<organization>ALMA - Code Lutin</organization>
<organizationUrl>http:/alma.univ-nantes.fr</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Architecte</role>
<role>Développeur</role>
@@ -161,7 +161,7 @@
<email>rannou at codelutin.com</email>
<organization>Code Lutin</organization>
<organizationUrl>http://www.codelutin.com/</organizationUrl>
- <timezone>+1</timezone>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Concepteur</role>
<role>Développeur</role>
@@ -183,7 +183,7 @@
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<nuitonWebVersion>1.11</nuitonWebVersion>
- <nuitonUtilsVersion>2.5</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.5.2</nuitonUtilsVersion>
<h2Version>1.3.167</h2Version>
<postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
<struts2Version>2.3.4</struts2Version>
1
0
Author: tchemit
Date: 2012-07-07 21:41:27 +0200 (Sat, 07 Jul 2012)
New Revision: 3571
Url: http://chorem.org/repositories/revision/pollen/3571
Log:
updates to mavenpom 3.3.4
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-06-26 07:36:22 UTC (rev 3570)
+++ trunk/pom.xml 2012-07-07 19:41:27 UTC (rev 3571)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.3.4-SNAPSHOT</version>
+ <version>3.3.4</version>
</parent>
<groupId>org.chorem</groupId>
1
0