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
August 2009
- 4 participants
- 37 discussions
Author: nrannou
Date: 2009-08-19 17:48:01 +0200 (Wed, 19 Aug 2009)
New Revision: 2736
Modified:
trunk/README.txt
trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PreventRuleDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/business/PreventRuleManagerTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.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/BackgroundWorkerImpl.java
trunk/pollen-ui/src/main/resources/pollen.properties
trunk/todo.txt
Log:
correction recherche de sondages en cours + mails de rappel
Modified: trunk/README.txt
===================================================================
--- trunk/README.txt 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/README.txt 2009-08-19 15:48:01 UTC (rev 2736)
@@ -39,6 +39,9 @@
# Répertoire des flux de syndication (Atom)
feedDir=/tmp/pollen/feeds
+
+ # Adresse du site (utilisée pour les emails de rappel)
+ siteUrl=http://www.site.org/pollen/
Pour une base PostgreSQL on aura :
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -33,6 +33,8 @@
*/
public class PreventRuleManager {
+ /** Représente l'action qui ne fait rien. */
+ public static final String NULL_ACTION = "nullAction";
/** Représente l'action qui écrit sur la sortie standard. */
public static final String PRINT_ACTION = "printAction";
/** Représente l'action qui envoi un email de notification. */
@@ -103,6 +105,20 @@
* @return true si la méthode à été exécutée, false sinon.
*/
public boolean execute(String scope, Integer value, Object data) {
+
+ // Si la règle n'est pas active, on ne fait rien
+ if (!preventRule.isActive()) {
+ log.debug("Règle non active");
+ return false;
+ }
+
+ // Si la règle est à exécution unique, on la désactive
+ if (preventRule.isOneTime()) {
+ log.debug("Règle à exécution unique : désactivation");
+ preventRule.setActive(false);
+ }
+
+ // Si la règle est répétitive (exécution tous les n), on met à jour la valeur
if (value != null && preventRule.isRepeated()
&& preventRule.getSensibility() != 0) {
value = value % preventRule.getSensibility()
@@ -133,6 +149,13 @@
}
/**
+ * Action qui ne fait rien.
+ */
+ public static void nullAction(Object data) {
+ // ne fait rien
+ }
+
+ /**
* Action qui écrit sur la sortie standard.
*/
public static void printAction(Object data) {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -46,6 +46,8 @@
PreventRule ePreventRule) throws TopiaException {
ePreventRule.setScope(preventRuleDTO.getScope());
ePreventRule.setSensibility(preventRuleDTO.getSensibility());
+ ePreventRule.setActive(preventRuleDTO.isActive());
+ ePreventRule.setOneTime(preventRuleDTO.isOneTime());
ePreventRule.setRepeated(preventRuleDTO.isRepeated());
ePreventRule.setMethod(preventRuleDTO.getMethod());
@@ -68,6 +70,8 @@
preventRuleDTO.setId(preventRule.getTopiaId());
preventRuleDTO.setScope(preventRule.getScope());
preventRuleDTO.setSensibility(preventRule.getSensibility());
+ preventRuleDTO.setActive(preventRule.getActive());
+ preventRuleDTO.setOneTime(preventRule.getOneTime());
preventRuleDTO.setRepeated(preventRule.getRepeated());
preventRuleDTO.setMethod(preventRule.getMethod());
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PreventRuleDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PreventRuleDTO.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PreventRuleDTO.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -35,6 +35,10 @@
private int sensibility = 0;
+ private boolean active = true;
+
+ private boolean oneTime = false;
+
private boolean repeated = false;
private String method = "";
@@ -97,6 +101,22 @@
this.sensibility = sensibility;
}
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isOneTime() {
+ return oneTime;
+ }
+
+ public void setOneTime(boolean oneTime) {
+ this.oneTime = oneTime;
+ }
+
public boolean isRepeated() {
return repeated;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -418,12 +418,14 @@
pollEntities = transaction
.find("from "
+ Poll.class.getName()
- + " as poll where poll.endDate is not null and poll.endDate > current_timestamp()");
+ + " as poll where (poll.endDate is not null and poll.endDate > current_timestamp())"
+ + " and (poll.beginDate is null or poll.beginDate < current_timestamp())");
} else {
pollEntities = transaction
.find("from "
+ Poll.class.getName()
- + " as poll where poll.endDate is null or poll.endDate > current_timestamp()");
+ + " as poll where (poll.endDate is null or poll.endDate > current_timestamp())"
+ + " and (poll.beginDate is null or poll.beginDate < current_timestamp())");
}
converter.setTransaction(transaction);
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/business/PreventRuleManagerTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/business/PreventRuleManagerTest.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/business/PreventRuleManagerTest.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -92,4 +92,24 @@
assertFalse(manager.execute(1));
assertFalse(manager.execute(5));
}
+
+ /**
+ * Test of execute method, of class PreventRuleManager. Using PRINT_ACTION
+ * oneTime execution.
+ */
+ @Test
+ public void testPrintActionOneTime() {
+ PreventRuleDTO preventRule = new PreventRuleDTO("test", 2, false,
+ PreventRuleManager.PRINT_ACTION);
+ preventRule.setOneTime(true);
+ manager = new PreventRuleManager(preventRule);
+
+ assertTrue(manager.execute(2));
+ assertFalse(manager.execute(2));
+
+ preventRule.setActive(true);
+
+ assertTrue(manager.execute(2));
+ assertFalse(manager.execute(2));
+ }
}
\ No newline at end of file
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -68,7 +68,7 @@
}
/**
- * Test of createChoice method, of class ChoiceImpl.
+ * Test of createChoice method, of class ServiceChoiceImpl.
*/
@Test
public void testCreateChoice() {
@@ -85,7 +85,7 @@
}
/**
- * Test of createChoices method, of class ChoiceImpl.
+ * Test of createChoices method, of class ServiceChoiceImpl.
*/
@Test
public void testCreateChoices() {
@@ -101,7 +101,7 @@
}
/**
- * Test of updateChoice method, of class ChoiceImpl.
+ * Test of updateChoice method, of class ServiceChoiceImpl.
*/
@Test
public void testUpdateChoice() {
@@ -117,7 +117,7 @@
}
/**
- * Test of deleteChoice method, of class ChoiceImpl.
+ * Test of deleteChoice method, of class ServiceChoiceImpl.
*/
@Test
public void testDeleteChoice() {
@@ -132,7 +132,7 @@
}
/**
- * Test of findChoiceById method, of class ChoiceImpl.
+ * Test of findChoiceById method, of class ServiceChoiceImpl.
*/
@Test
public void testFindChoiceById() {
@@ -147,7 +147,7 @@
}
/**
- * Test of selectChoices method, of class ChoiceImpl.
+ * Test of selectChoices method, of class ServiceChoiceImpl.
*/
@Test
public void testSelectChoices() {
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -224,6 +224,12 @@
poll3.setEndDate(new Date(now.getTime() - 100000));
instance.createPoll(poll3);
+ // sondage pas commencé
+ PollDTO poll4 = new PollDTO();
+ poll4.setTitle("Test_findRunningPolls4");
+ poll4.setBeginDate(new Date(now.getTime() + 100000));
+ instance.createPoll(poll4);
+
List<PollDTO> result1 = instance.findRunningPolls(true);
List<PollDTO> result2 = instance.findRunningPolls(false);
assertTrue(result2.size() > result1.size());
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -52,10 +52,8 @@
* <pre>
* Utilisation :
* <t:chart width="210" height="190" values="choice" title="title" type="1"/>
- *
* - choice est une liste de chaînes représentant les labels et leur valeurs respectives. ({"val1", "20", "val2", "10"}...)
* - type est le type de représentation du diagramme (1:PIE, 2:PIE3D...)
- *
* Pour généraliser à d'autres types de graphes il faudrait passer un JFreeChart :
* Persist Parameter(required=true)
* private JFreeChart _chart;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -36,7 +36,6 @@
* <pre>
* Utilisation :
* <t:feedback t:id="feedback"/>
- *
* @Component(id = "feedback") private FeedBack feedback;
* feedback.addInfo("message d'info");
* feedback.addError("message d'erreur");
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -43,7 +43,6 @@
* <pre>
* Utilisation :
* <t:image src="/img/image.png" />
- *
* Pour afficher une image statique il est préférable d'utiliser :
* <img src="${asset:context:img}/image.png" />
* </pre>
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 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -20,6 +20,7 @@
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.EagerLoad;
@@ -28,6 +29,7 @@
import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.apache.tapestry5.ioc.services.SymbolProvider;
+import org.apache.tapestry5.services.ComponentSource;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestHandler;
@@ -71,10 +73,6 @@
binder.bind(ServicePollAccount.class);
binder.bind(ServiceResults.class);
binder.bind(ServiceVote.class);
-
- // UI specific services
- //binder.bind(Configuration.class);
- //binder.bind(BackgroundWorker.class).eagerLoad();
}
public static void contributeApplicationDefaults(
@@ -161,14 +159,14 @@
* This is the BackgroundWorker service definition. It build the service
* giving a Messages object for localization in the service.
*/
- /*@EagerLoad
+ @EagerLoad
public static BackgroundWorker buildBackgroundWorker(
ComponentSource componentSource, Configuration configuration,
ServicePoll servicePoll) {
Messages messages = componentSource.getPage("LocalMessages")
.getComponentResources().getMessages();
return new BackgroundWorkerImpl(messages, configuration, servicePoll);
- }*/
+ }
/**
* Make configuration from a Properties file available as symbols.
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
@@ -32,6 +32,8 @@
import org.chorem.pollen.business.dto.PreventRuleDTO;
import org.chorem.pollen.business.dto.VotingListDTO;
import org.chorem.pollen.business.services.ServicePoll;
+import org.chorem.pollen.business.services.ServicePreventRule;
+import org.chorem.pollen.business.services.ServicePreventRuleImpl;
/**
* Implémentation du service BackgroundWorker.
@@ -74,7 +76,13 @@
* Lancement des tâches en arrière-plan.
*/
public void executeTasks() {
- timer.schedule(new MailingTask(), 10000, 10000);
+ if ("".equals(conf.getProperty("siteUrl"))) {
+ log
+ .warn("No property siteUrl. Reminder emails would not contain it");
+ }
+
+ // Exécution de la tâche toutes les 10 min
+ timer.schedule(new MailingTask(), 600000, 600000);
}
/**
@@ -97,6 +105,8 @@
// Parcours des preventRules de chaque sondage
// envoi d'un email si endDate-nowDate <= preventRuleSensibility
if (poll.getEndDate() != null) {
+
+ // timeValue = endDate-nowDate
Long timeValue = poll.getEndDate().getTime()
- now.getTime();
@@ -107,9 +117,6 @@
}
// envoi des mails avec une sensibilité de l'ordre de l'heure
- if (log.isInfoEnabled()) {
- log.info("Sending reminder emails...");
- }
sendMailNotification(poll, timeValue / 3600000);
}
}
@@ -130,21 +137,37 @@
data.put("from", conf.getProperty("email_from"));
// Mails aux votants
- for (VotingListDTO list : poll.getVotingListDTOs()) {
- for (PollAccountDTO account : list.getPollAccountDTOs()) {
- if (account.getEmail() != null) {
- data.put("to", account.getEmail());
- data.put("title", messages.format("reminderEmail_subject",
- poll.getTitle()));
- data.put("msg", messages.format("reminderEmail_msg", poll
- .getTitle(), account.getVotingId(), voteURL));
+ for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) {
+ if (rule.isActive()) {
+ Boolean hasRun = false;
+ PreventRuleManager manager = new PreventRuleManager(rule);
+ for (VotingListDTO list : poll.getVotingListDTOs()) {
+ for (PollAccountDTO account : list.getPollAccountDTOs()) {
+ if (account.getEmail() != null) {
+ String accountVoteURL = voteURL + ":"
+ + account.getAccountId();
- for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) {
- PreventRuleManager manager = new PreventRuleManager(
- rule);
- manager.execute("rappel", timeValue.intValue(), data);
+ data.put("to", account.getEmail());
+ data.put("title", messages.format(
+ "reminderEmail_subject", poll.getTitle()));
+ data.put("msg", messages.format(
+ "reminderEmail_msg", poll.getTitle(),
+ account.getVotingId(), accountVoteURL));
+
+ // Exécution de la règle avec une valeur +1
+ // Sensibilité de 2h : 2h05 KO, 1h55 OK
+ hasRun = manager.execute("rappel", timeValue
+ .intValue() + 1, data);
+ }
}
}
+
+ // désactivation de la règle de rappel pour éviter qu'elle soit réexécutée
+ if (hasRun) {
+ rule.setActive(false);
+ ServicePreventRule spr = new ServicePreventRuleImpl();
+ spr.updatePreventRule(rule);
+ }
}
}
}
Modified: trunk/pollen-ui/src/main/resources/pollen.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/pollen.properties 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/pollen-ui/src/main/resources/pollen.properties 2009-08-19 15:48:01 UTC (rev 2736)
@@ -46,8 +46,8 @@
## Répertoire des flux de syndication (Atom)
feedDir=/tmp/pollen/feeds
-## Adresse du site
-siteUrl=http://localhost:8090/pollen-ui/
+## Adresse du site (utilisée pour les emails de rappel)
+siteUrl=
## Version de l'application
version=${project.version}
\ No newline at end of file
Modified: trunk/todo.txt
===================================================================
--- trunk/todo.txt 2009-08-19 08:50:33 UTC (rev 2735)
+++ trunk/todo.txt 2009-08-19 15:48:01 UTC (rev 2736)
@@ -1,6 +1,5 @@
TODO
-envoi emails de rappel
amélioration des tests
1
0
r2735 - trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration
by nrannou@users.chorem.org 19 Aug '09
by nrannou@users.chorem.org 19 Aug '09
19 Aug '09
Author: nrannou
Date: 2009-08-19 10:50:33 +0200 (Wed, 19 Aug 2009)
New Revision: 2735
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
Log:
correction detection dialect
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 16:37:56 UTC (rev 2734)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-19 08:50:33 UTC (rev 2735)
@@ -23,6 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.dialect.PostgreSQLDialect;
import org.nuiton.topia.migration.DatabaseManager;
import org.nuiton.topia.migration.callback.MigrationCallbackHandler;
import org.nuiton.util.VersionUtil;
@@ -83,7 +85,7 @@
String[] sqls = null;
// Script de migration
- if ("org.hibernate.dialect.PostgreSQLDialect".equals(dialect)) {
+ if (dialect instanceof PostgreSQLDialect) {
sqls = new String[] {
"alter table useraccount rename langage to language;",
"alter table pollaccount add accountid varchar;",
@@ -93,7 +95,7 @@
"alter table vote add anonymous boolean default false;",
"alter table preventrule add active boolean default true;",
"alter table preventrule add onetime boolean default false;", };
- } else if ("org.hibernate.dialect.H2Dialect".equals(dialect)) {
+ } else if (dialect instanceof H2Dialect) {
sqls = new String[] {
"alter table useraccount alter column langage rename to language;",
"alter table pollaccount add accountid varchar;",
1
0
r2734 - in trunk: . pollen-business/src/main/java/org/chorem/pollen/business/migration
by nrannou@users.chorem.org 18 Aug '09
by nrannou@users.chorem.org 18 Aug '09
18 Aug '09
Author: nrannou
Date: 2009-08-18 18:37:56 +0200 (Tue, 18 Aug 2009)
New Revision: 2734
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
trunk/pom.xml
Log:
migration : utilisation du dialect
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 14:15:45 UTC (rev 2733)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 16:37:56 UTC (rev 2734)
@@ -19,8 +19,10 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.dialect.Dialect;
import org.nuiton.topia.migration.DatabaseManager;
import org.nuiton.topia.migration.callback.MigrationCallbackHandler;
import org.nuiton.util.VersionUtil;
@@ -47,6 +49,8 @@
+ ", version de l'application : " + applicationVersion);
}
+ Dialect dialect = dbManager.getDbConfiguration().buildSettings()
+ .getDialect();
MigrationChoice result = MigrationChoice.NO_MIGRATION;
// ouverture d'une connexion direct JDBC sur la base
@@ -56,7 +60,7 @@
conn.setAutoCommit(false);
if (VersionUtil.valueOf(dbVersion).before(
VersionUtil.valueOf("1.1"))) {
- migrateTo1_1(conn);
+ migrateTo1_1(conn, dialect);
}
conn.commit();
result = MigrationChoice.CUSTOM_MIGRATION;
@@ -73,15 +77,13 @@
}
/** Migration de la version 0 à 1.1 */
- private void migrateTo1_1(Connection conn) throws SQLException {
+ private void migrateTo1_1(Connection conn, Dialect dialect)
+ throws SQLException {
log.info("Migrate to version 1_1");
String[] sqls = null;
- // Récupération du nom de la base de données
- String product = conn.getMetaData().getDatabaseProductName();
-
// Script de migration
- if ("PostgreSQL".equals(product)) {
+ if ("org.hibernate.dialect.PostgreSQLDialect".equals(dialect)) {
sqls = new String[] {
"alter table useraccount rename langage to language;",
"alter table pollaccount add accountid varchar;",
@@ -91,7 +93,7 @@
"alter table vote add anonymous boolean default false;",
"alter table preventrule add active boolean default true;",
"alter table preventrule add onetime boolean default false;", };
- } else if ("H2".equals(product)) {
+ } else if ("org.hibernate.dialect.H2Dialect".equals(dialect)) {
sqls = new String[] {
"alter table useraccount alter column langage rename to language;",
"alter table pollaccount add accountid varchar;",
@@ -104,8 +106,8 @@
} else {
if (log.isErrorEnabled()) {
log
- .error("Migration non prise en charge pour ce type de base : "
- + product);
+ .error("Migration non prise en charge pour ce type de dialect : "
+ + dialect);
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-18 14:15:45 UTC (rev 2733)
+++ trunk/pom.xml 2009-08-18 16:37:56 UTC (rev 2734)
@@ -268,7 +268,7 @@
<!-- customized versions -->
<javadoc.version>2.4</javadoc.version>
- <topia.version>2.2.0-rc-3</topia.version>
+ <topia.version>2.2.0-rc-5-SNAPSHOT</topia.version>
<eugene.version>1.0.0-rc-7</eugene.version>
<tapestry.version>5.1.0.5</tapestry.version>
1
0
r2733 - trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration
by nrannou@users.chorem.org 18 Aug '09
by nrannou@users.chorem.org 18 Aug '09
18 Aug '09
Author: nrannou
Date: 2009-08-18 16:15:45 +0200 (Tue, 18 Aug 2009)
New Revision: 2733
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
Log:
migration
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 12:26:50 UTC (rev 2732)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 14:15:45 UTC (rev 2733)
@@ -19,11 +19,8 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-import java.util.Properties;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.migration.DatabaseManager;
import org.nuiton.topia.migration.callback.MigrationCallbackHandler;
import org.nuiton.util.VersionUtil;
@@ -59,7 +56,7 @@
conn.setAutoCommit(false);
if (VersionUtil.valueOf(dbVersion).before(
VersionUtil.valueOf("1.1"))) {
- migrateTo1_1_test(conn);
+ migrateTo1_1(conn);
}
conn.commit();
result = MigrationChoice.CUSTOM_MIGRATION;
@@ -75,17 +72,16 @@
return result;
}
- /** Migration de la version de test (0 to 1.1) */
- private void migrateTo1_1_test(Connection conn) throws SQLException {
- log.info("Migrate to version 1_1_test");
+ /** Migration de la version 0 à 1.1 */
+ private void migrateTo1_1(Connection conn) throws SQLException {
+ log.info("Migrate to version 1_1");
String[] sqls = null;
- // Récupération du dialect Hibernate
- Properties conf = ContextUtil.getInstance().getConf();
- String dialect = conf.getProperty("hibernate.dialect");
+ // Récupération du nom de la base de données
+ String product = conn.getMetaData().getDatabaseProductName();
// Script de migration
- if ("org.hibernate.dialect.PostgreSQLDialect".equals(dialect)) {
+ if ("PostgreSQL".equals(product)) {
sqls = new String[] {
"alter table useraccount rename langage to language;",
"alter table pollaccount add accountid varchar;",
@@ -95,11 +91,11 @@
"alter table vote add anonymous boolean default false;",
"alter table preventrule add active boolean default true;",
"alter table preventrule add onetime boolean default false;", };
- } else if ("org.hibernate.dialect.H2Dialect".equals(dialect)) {
+ } else if ("H2".equals(product)) {
sqls = new String[] {
"alter table useraccount alter column langage rename to language;",
"alter table pollaccount add accountid varchar;",
- "update pollaccount set accountid=call hash('sha256', topiaid, 1000);",
+ "update pollaccount set accountid=hash('sha256', stringtoutf8(topiaid), 1000);",
"alter table persontolist drop column hasvoted;",
"alter table persontolist add hasvoted boolean default false;",
"alter table vote add anonymous boolean default false;",
@@ -108,8 +104,8 @@
} else {
if (log.isErrorEnabled()) {
log
- .error("Migration non prise en charge pour ce type de dialect : "
- + dialect);
+ .error("Migration non prise en charge pour ce type de base : "
+ + product);
}
}
1
0
Author: nrannou
Date: 2009-08-18 14:26:50 +0200 (Tue, 18 Aug 2009)
New Revision: 2732
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollAccountConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVotingListConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollAccountDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePreventRuleImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ConfigurationImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenShutdown.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java
trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/ServiceVoteCountingImplTest.java
Log:
formattage du code
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -31,7 +31,8 @@
*
* @author tcicognani
* @author rannou
- * @version $Id$
+ * @version $Id: DataPersonListConverter.java 2615 2009-07-01 13:47:45Z nrannou
+ * $
*/
public class DataPersonListConverter extends DataConverter {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollAccountConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollAccountConverter.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollAccountConverter.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -33,7 +33,8 @@
* Gestion de la conversion des dtos pollAccount en entité et vice-versa.
*
* @author kmorin
- * @version $Id$
+ * @version $Id: DataPollAccountConverter.java 2652 2009-07-17 08:10:26Z nrannou
+ * $
*/
public class DataPollAccountConverter extends DataConverter {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPreventRuleConverter.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -31,7 +31,8 @@
* Gestion de la conversion des dtos règle en entité et vice-versa.
*
* @author rannou
- * @version $Id$
+ * @version $Id: DataPreventRuleConverter.java 2615 2009-07-01 13:47:45Z nrannou
+ * $
*/
public class DataPreventRuleConverter extends DataConverter {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVotingListConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVotingListConverter.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVotingListConverter.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -39,7 +39,8 @@
* Gestion de la conversion des dtos VotingList en entité et vice-versa.
*
* @author enema
- * @version $Id$
+ * @version $Id: DataVotingListConverter.java 2650 2009-07-16 12:57:46Z nrannou
+ * $
*/
public class DataVotingListConverter extends DataConverter {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollAccountDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollAccountDTO.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollAccountDTO.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -30,7 +30,7 @@
public class PollAccountDTO implements Serializable {
private String id = "";
-
+
private String accountId = "";
private String votingId = "";
@@ -74,7 +74,7 @@
public void setId(String id) {
this.id = id;
}
-
+
public String getAccountId() {
return accountId;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -34,7 +34,7 @@
private double weight = 0;
private String comment = "";
-
+
private boolean anonymous = false;
private String pollAccountId = "";
@@ -81,7 +81,7 @@
public void setComment(String comment) {
this.comment = comment;
}
-
+
public boolean isAnonymous() {
return anonymous;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -107,7 +107,8 @@
"alter table preventrule add onetime boolean default false;", };
} else {
if (log.isErrorEnabled()) {
- log.error("Migration non prise en charge pour ce type de dialect : "
+ log
+ .error("Migration non prise en charge pour ce type de dialect : "
+ dialect);
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -83,7 +83,7 @@
* @return un compte
*/
public PollAccountDTO findPollAccountById(String pollAccountId);
-
+
/**
* Récupération du compte à partir de son identifiant.
*
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePreventRuleImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePreventRuleImplTest.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePreventRuleImplTest.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -36,7 +36,8 @@
* Tests de la gestion des règles de notification.
*
* @author rannou
- * @version $Id$
+ * @version $Id: ServicePreventRuleImplTest.java 2649 2009-07-15 16:30:23Z
+ * nrannou $
*/
public class ServicePreventRuleImplTest {
private ServicePreventRuleImpl instance;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Chart.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -52,10 +52,10 @@
* <pre>
* Utilisation :
* <t:chart width="210" height="190" values="choice" title="title" type="1"/>
- *
+ *
* - choice est une liste de chaînes représentant les labels et leur valeurs respectives. ({"val1", "20", "val2", "10"}...)
* - type est le type de représentation du diagramme (1:PIE, 2:PIE3D...)
- *
+ *
* Pour généraliser à d'autres types de graphes il faudrait passer un JFreeChart :
* Persist Parameter(required=true)
* private JFreeChart _chart;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -36,9 +36,8 @@
* <pre>
* Utilisation :
* <t:feedback t:id="feedback"/>
- *
- * @Component(id = "feedback") private FeedBack feedback;
*
+ * @Component(id = "feedback") private FeedBack feedback;
* feedback.addInfo("message d'info");
* feedback.addError("message d'erreur");
* </pre>
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -57,7 +57,7 @@
/** Type MIME du fichier */
@Parameter
private String _type;
-
+
@Inject
private Logger logger;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -57,7 +57,7 @@
@Parameter
private String _title;
-
+
@Inject
private Logger logger;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -43,7 +43,7 @@
* <pre>
* Utilisation :
* <t:image src="/img/image.png" />
- *
+ *
* Pour afficher une image statique il est préférable d'utiliser :
* <img src="${asset:context:img}/image.png" />
* </pre>
@@ -68,7 +68,7 @@
/** Hauteur de l'image */
@Parameter
private int _height;
-
+
@Inject
private Logger logger;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ConfigurationImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ConfigurationImpl.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ConfigurationImpl.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -35,7 +35,7 @@
public ConfigurationImpl(Properties conf) {
this.conf = conf;
}
-
+
public ConfigurationImpl(String filename) {
conf = PropertiesLoader.loadPropertiesFile(filename);
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenShutdown.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenShutdown.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenShutdown.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -22,7 +22,7 @@
/**
* Service de gestion de l'arrêt du serveur. Ce service exécute une action à la
* fermeture du registre Tapestry.
- *
+ *
* @author rannou
* @version $Id$
*/
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/dto/VotingGroupDTO.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -29,7 +29,7 @@
public class VotingGroupDTO implements ListBehavior<VotingPersonDTO> {
private String name;
-
+
private double weight;
private String idGroup;
@@ -46,7 +46,7 @@
public List<VotingPersonDTO> list() {
return votingPersons;
}
-
+
public String getName() {
return name;
}
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -41,7 +41,8 @@
* Implémentation du service de dépouillement.
*
* @author fdesbois
- * @version $Id$
+ * @version $Id: ServiceVoteCountingImpl.java 2697 2009-08-11 09:39:09Z nrannou
+ * $
*/
public class ServiceVoteCountingImpl implements ServiceVoteCounting {
/**
@@ -57,7 +58,8 @@
*/
private Context context;
/** log. */
- private static final Log log = LogFactory.getLog(ServiceVoteCountingImpl.class);
+ private static final Log log = LogFactory
+ .getLog(ServiceVoteCountingImpl.class);
/**
* Constructeur
@@ -183,8 +185,8 @@
*/
private void routeGroup(VotingGroupDTO group) {
if (log.isInfoEnabled()) {
- log.info("Ajout group : " + group.getIdGroup()
- + " _ weight=" + group.getWeight());
+ log.info("Ajout group : " + group.getIdGroup() + " _ weight="
+ + group.getWeight());
}
this.context.addGroup(group.getIdGroup(), group.getWeight());
for (Object o : group.getVotingPersons()) {
@@ -201,8 +203,8 @@
*/
private void routePerson(VotingPersonDTO person) {
if (log.isInfoEnabled()) {
- log.info("Ajout person : " + person.getVotingId()
- + " _ weight=" + person.getWeight());
+ log.info("Ajout person : " + person.getVotingId() + " _ weight="
+ + person.getWeight());
}
for (Object o : person.getChoices()) {
VoteToChoiceDTO vote = (VoteToChoiceDTO) o;
@@ -220,8 +222,8 @@
private void addVoteToContext(VoteToChoiceDTO vote, double weight,
String votingID) {
if (log.isInfoEnabled()) {
- log.info("Ajout vote : " + vote.getValue()
- + " _ choice=" + vote.getIdChoice());
+ log.info("Ajout vote : " + vote.getValue() + " _ choice="
+ + vote.getIdChoice());
}
this.context.getChoice(vote.getIdChoice())
.getGroup(this.currentIdGroup).addVote(vote.getValue(), weight,
Modified: trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/ServiceVoteCountingImplTest.java
===================================================================
--- trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/ServiceVoteCountingImplTest.java 2009-08-18 12:22:46 UTC (rev 2731)
+++ trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/ServiceVoteCountingImplTest.java 2009-08-18 12:26:50 UTC (rev 2732)
@@ -27,7 +27,8 @@
/**
* Tests des dépouillements.
*
- * @version $Id$
+ * @version $Id: ServiceVoteCountingImplTest.java 2649 2009-07-15 16:30:23Z
+ * nrannou $
*/
public class ServiceVoteCountingImplTest {
1
0
Author: nrannou
Date: 2009-08-18 14:22:46 +0200 (Tue, 18 Aug 2009)
New Revision: 2731
Modified:
trunk/README.txt
trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/EnumController.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/MailUtil.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/PropertiesLoader.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/filters/PollenExceptionsFilter.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/utils/FeedUtil.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java
trunk/pollen-ui/src/main/resources/pollen.properties
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java
Log:
correction votant null et migration d'une nouvelle base
Modified: trunk/README.txt
===================================================================
--- trunk/README.txt 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/README.txt 2009-08-18 12:22:46 UTC (rev 2731)
@@ -18,7 +18,6 @@
/etc/pollen.properties et de le remplir avec les propriétés suivantes :
# Configuration de la base de données
- hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.username=username
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/business/PreventRuleManager.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -125,7 +125,8 @@
return false;
}
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Erreur lors de l'appel de la méthode "
+ + preventRule.getMethod(), e);
return false;
}
return true;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/EnumController.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/EnumController.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/EnumController.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -22,6 +22,7 @@
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.chorem.pollen.business.persistence.Result;
import org.chorem.pollen.business.persistence.VoteCountingDAO;
+import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
@@ -47,8 +48,8 @@
.getChoiceTypeDAO(transaction);
ePoll.setChoiceType(dao.findByName(type.name()));
}
- } catch (TopiaException tex) {
- tex.printStackTrace();
+ } catch (TopiaException e) {
+ ContextUtil.doCatch(e, transaction);
}
}
@@ -59,8 +60,8 @@
.getPollTypeDAO(transaction);
ePoll.setPollType(dao.findByName(type.name()));
}
- } catch (TopiaException tex) {
- tex.printStackTrace();
+ } catch (TopiaException e) {
+ ContextUtil.doCatch(e, transaction);
}
}
@@ -71,8 +72,8 @@
.getVoteCountingDAO(transaction);
ePoll.setVoteCounting(dao.findByName(type.name()));
}
- } catch (TopiaException tex) {
- tex.printStackTrace();
+ } catch (TopiaException e) {
+ ContextUtil.doCatch(e, transaction);
}
}
@@ -83,8 +84,8 @@
.getVoteCountingDAO(transaction);
eResult.setVoteCounting(dao.findByName(type.name()));
}
- } catch (TopiaException tex) {
- tex.printStackTrace();
+ } catch (TopiaException e) {
+ ContextUtil.doCatch(e, transaction);
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/migration/PollenMigrationCallbackHandler.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -19,8 +19,11 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+import java.util.Properties;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.migration.DatabaseManager;
import org.nuiton.topia.migration.callback.MigrationCallbackHandler;
import org.nuiton.util.VersionUtil;
@@ -56,7 +59,7 @@
conn.setAutoCommit(false);
if (VersionUtil.valueOf(dbVersion).before(
VersionUtil.valueOf("1.1"))) {
- //migrateTo1_1_test(conn);
+ migrateTo1_1_test(conn);
}
conn.commit();
result = MigrationChoice.CUSTOM_MIGRATION;
@@ -75,16 +78,41 @@
/** Migration de la version de test (0 to 1.1) */
private void migrateTo1_1_test(Connection conn) throws SQLException {
log.info("Migrate to version 1_1_test");
+ String[] sqls = null;
- String[] sqls = new String[] {
- "alter table useraccount rename langage to language;",
- "alter table pollaccount add accountid varchar;",
- "update pollaccount set accountid=md5(topiaid);",
- "alter table persontolist drop column hasvoted;",
- "alter table persontolist add hasvoted boolean default false;",
- "alter table vote add anonymous boolean default false;",
- "alter table preventrule add active boolean default true;",
- "alter table preventrule add onetime boolean default false;", };
+ // Récupération du dialect Hibernate
+ Properties conf = ContextUtil.getInstance().getConf();
+ String dialect = conf.getProperty("hibernate.dialect");
+
+ // Script de migration
+ if ("org.hibernate.dialect.PostgreSQLDialect".equals(dialect)) {
+ sqls = new String[] {
+ "alter table useraccount rename langage to language;",
+ "alter table pollaccount add accountid varchar;",
+ "update pollaccount set accountid=md5(topiaid);",
+ "alter table persontolist drop column hasvoted;",
+ "alter table persontolist add hasvoted boolean default false;",
+ "alter table vote add anonymous boolean default false;",
+ "alter table preventrule add active boolean default true;",
+ "alter table preventrule add onetime boolean default false;", };
+ } else if ("org.hibernate.dialect.H2Dialect".equals(dialect)) {
+ sqls = new String[] {
+ "alter table useraccount alter column langage rename to language;",
+ "alter table pollaccount add accountid varchar;",
+ "update pollaccount set accountid=call hash('sha256', topiaid, 1000);",
+ "alter table persontolist drop column hasvoted;",
+ "alter table persontolist add hasvoted boolean default false;",
+ "alter table vote add anonymous boolean default false;",
+ "alter table preventrule add active boolean default true;",
+ "alter table preventrule add onetime boolean default false;", };
+ } else {
+ if (log.isErrorEnabled()) {
+ log.error("Migration non prise en charge pour ce type de dialect : "
+ + dialect);
+ }
+ }
+
+ // Exécution de la migration
for (String sql : sqls) {
log.info("try " + sql);
PreparedStatement sta = conn.prepareStatement(sql);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -26,6 +26,7 @@
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.UserAccountDAO;
import org.chorem.pollen.business.persistence.VoteCountingDAO;
+import org.hibernate.exception.SQLGrammarException;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -67,6 +68,15 @@
}
/**
+ * Retourne la configuration de la base de données.
+ *
+ * @return la configuration
+ */
+ public Properties getConf() {
+ return conf;
+ }
+
+ /**
* Construction du contexte global
*/
public void buildContext() {
@@ -78,7 +88,7 @@
context = TopiaContextFactory.getContext(conf);
} catch (TopiaNotFoundException e) {
if (log.isErrorEnabled()) {
- log.error("Erreur lors de la construction du contexte");
+ log.error("Erreur lors de la construction du contexte", e);
}
e.printStackTrace();
}
@@ -97,7 +107,7 @@
context.closeContext();
} catch (TopiaException e) {
if (log.isErrorEnabled()) {
- log.error("Erreur lors de la fermeture du contexte");
+ log.error("Erreur lors de la fermeture du contexte", e);
}
e.printStackTrace();
}
@@ -130,8 +140,23 @@
// Construction du contexte global
buildContext();
- // Initialisation de la base de données
- initDB();
+ // Initialisation de la base de données. Si elle n'existe pas on la crée
+ // FIXME Il ne faudrait pas se baser sur l'exception SQLGrammarException pour détecter que la base n'existe pas
+ try {
+ initDB();
+ } catch (TopiaException e) {
+ log.error("Base de données inexistante");
+ if (e.getCause() instanceof SQLGrammarException) {
+ log.info("Création de la base de données...");
+ try {
+ context.createSchema();
+ log.info("Base de données créée");
+ initDB();
+ } catch (TopiaException ex) {
+ log.error("Échec lors de la création de la base", ex);
+ }
+ }
+ }
}
/**
@@ -139,39 +164,35 @@
*
* @throws TopiaException
*/
- protected void initDB() {
+ protected void initDB() throws TopiaException {
TopiaContext transaction = null;
- try {
- transaction = context.beginTransaction();
+ transaction = context.beginTransaction();
- // Chargement des types de choix dans la table choiceType
- ChoiceTypeDAO choiceTypeDAO = PollenModelDAOHelper
- .getChoiceTypeDAO(transaction);
- loadDB("choiceType", choiceTypeDAO);
- transaction.commitTransaction();
+ // Chargement des types de choix dans la table choiceType
+ ChoiceTypeDAO choiceTypeDAO = PollenModelDAOHelper
+ .getChoiceTypeDAO(transaction);
+ loadDB("choiceType", choiceTypeDAO);
+ transaction.commitTransaction();
- // Chargement des types de sondage dans la table pollType
- PollTypeDAO pollTypeDAO = PollenModelDAOHelper
- .getPollTypeDAO(transaction);
- loadDB("pollType", pollTypeDAO);
- transaction.commitTransaction();
+ // Chargement des types de sondage dans la table pollType
+ PollTypeDAO pollTypeDAO = PollenModelDAOHelper
+ .getPollTypeDAO(transaction);
+ loadDB("pollType", pollTypeDAO);
+ transaction.commitTransaction();
- // Chargement des types de dépouillement dans la table voteCounting
- VoteCountingDAO voteCountingDAO = PollenModelDAOHelper
- .getVoteCountingDAO(transaction);
- loadDB("voteCounting", voteCountingDAO);
- transaction.commitTransaction();
+ // Chargement des types de dépouillement dans la table voteCounting
+ VoteCountingDAO voteCountingDAO = PollenModelDAOHelper
+ .getVoteCountingDAO(transaction);
+ loadDB("voteCounting", voteCountingDAO);
+ transaction.commitTransaction();
- // Chargement de l'utilisateur par défaut
- UserAccountDAO userAccountDAO = PollenModelDAOHelper
- .getUserAccountDAO(transaction);
- loadAdmin(userAccountDAO);
- transaction.commitTransaction();
+ // Chargement de l'utilisateur par défaut
+ UserAccountDAO userAccountDAO = PollenModelDAOHelper
+ .getUserAccountDAO(transaction);
+ loadAdmin(userAccountDAO);
+ transaction.commitTransaction();
- transaction.closeContext();
- } catch (TopiaException e) {
- doCatch(e, transaction);
- }
+ transaction.closeContext();
}
/**
@@ -232,24 +253,23 @@
transaction.rollbackTransaction();
} catch (TopiaException ex) {
if (log.isErrorEnabled()) {
- log.error("Échec lors du rollback de la transaction : "
- + ex.getMessage());
+ log.error("Échec lors du rollback de la transaction", ex);
}
} finally {
try {
transaction.closeContext();
} catch (TopiaException ex) {
if (log.isErrorEnabled()) {
- log.error("Échec lors de la fermeture de la transaction : "
- + ex.getMessage());
+ log.error(
+ "Échec lors de la fermeture de la transaction",
+ ex);
}
}
}
}
if (log.isErrorEnabled()) {
- log.error("Échec lors du déroulement de la transaction : "
- + e.getMessage());
+ log.error("Échec lors du déroulement de la transaction", e);
}
}
}
\ No newline at end of file
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/MailUtil.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/MailUtil.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/MailUtil.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -55,7 +55,7 @@
email.setCharset("UTF-8");
email.send();
} catch (EmailException e) {
- e.printStackTrace();
+ log.error("Erreur à l'envoi d'email", e);
}
if (log.isInfoEnabled()) {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/PropertiesLoader.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/PropertiesLoader.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/PropertiesLoader.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -57,12 +57,11 @@
if (log.isDebugEnabled()) {
log.debug("Propriétés: " + conf);
}
- } catch (Exception ex) {
+ } catch (Exception e) {
if (log.isErrorEnabled()) {
log.error("Lecture impossible du fichier de propriétés : "
- + filename);
+ + filename, e);
}
- ex.printStackTrace();
}
return conf;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -32,6 +32,7 @@
import org.apache.tapestry5.corelib.base.AbstractLink;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Response;
+import org.slf4j.Logger;
/**
* Composant qui affiche un lien vers un fichier dynamique.
@@ -56,6 +57,9 @@
/** Type MIME du fichier */
@Parameter
private String _type;
+
+ @Inject
+ private Logger logger;
@Inject
private ComponentResources _resources;
@@ -80,7 +84,7 @@
try {
stream = new FileInputStream(file);
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ logger.error("Fichier inexistant : " + file.getAbsolutePath(), e);
}
if (!_resources.isBound("type")) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/HeadLink.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -30,6 +30,7 @@
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Response;
+import org.slf4j.Logger;
/**
* Composant générant une balise d'entête Link à partir d'un fichier dynamique.
@@ -56,6 +57,9 @@
@Parameter
private String _title;
+
+ @Inject
+ private Logger logger;
@Inject
private ComponentResources _resources;
@@ -83,7 +87,7 @@
try {
stream = new FileInputStream(file);
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ logger.error("Fichier inexistant : " + file.getAbsolutePath(), e);
}
return new FileStreamResponse(stream, type);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -32,6 +32,7 @@
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Response;
+import org.slf4j.Logger;
/**
* Composant qui affiche une image.
@@ -67,6 +68,9 @@
/** Hauteur de l'image */
@Parameter
private int _height;
+
+ @Inject
+ private Logger logger;
@Inject
private ComponentResources _resources;
@@ -95,7 +99,7 @@
try {
stream = new FileInputStream(file);
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ logger.error("Fichier inexistant : " + file.getAbsolutePath(), e);
}
MimetypesFileTypeMap mimes = new MimetypesFileTypeMap();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/filters/PollenExceptionsFilter.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/filters/PollenExceptionsFilter.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/filters/PollenExceptionsFilter.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -50,7 +50,7 @@
} catch (Exception e) {
if (log.isDebugEnabled()) {
- log.debug("Exception capturée : " + e.getClass() + ": " + e.getMessage());
+ log.debug("Exception capturée", e);
}
// si la connexion est fermée, reconnexion et affichage d'un message
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 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -209,8 +209,8 @@
/** Liste des choix */
private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>();
-
- /** Identifiant du compte correspondant à l'adresse forgée */
+
+ /** Identifiant du compte correspondant à l'adresse forgée */
private String pollAccountId;
/** Compte du votant */
@@ -454,7 +454,8 @@
}
// si le votant du vote correspond au votant actuel (pollAccountId)
- if (pollAccountId.equals(account.getId())) {
+ if (pollAccountId != null
+ && pollAccountId.equals(account.getId())) {
modifAllowed = true;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/FeedUtil.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/FeedUtil.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/FeedUtil.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -93,7 +93,7 @@
}
} catch (Exception e) {
if (log.isErrorEnabled()) {
- log.error("Feed error: " + e.getMessage());
+ log.error("Feed creation error", e);
}
e.printStackTrace();
}
@@ -174,7 +174,7 @@
}
} catch (Exception e) {
if (log.isErrorEnabled()) {
- log.error("Feed error: " + e.getMessage());
+ log.error("Feed feeding error", e);
}
e.printStackTrace();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -116,7 +116,7 @@
try {
ImageIO.write(thumbImage, "jpg", thumbCopied);
} catch (IOException e) {
- e.printStackTrace();
+ log.error("Erreur à l'enregistrement de la miniature", e);
}
if (log.isDebugEnabled()) {
log.debug("Thumbnail created: " + thumbCopied.getName() + " (size="
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -110,8 +110,7 @@
}
}
} catch (javax.naming.NamingException e) {
- log.error("Exception de nommage lors de l'import depuis LDAP : "
- + e.getMessage());
+ log.error("Exception de nommage lors de l'import depuis LDAP", e);
}
long duration = (System.nanoTime() - start) / 1000000000;
Modified: trunk/pollen-ui/src/main/resources/pollen.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/pollen.properties 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-ui/src/main/resources/pollen.properties 2009-08-18 12:22:46 UTC (rev 2731)
@@ -1,5 +1,5 @@
## Configuration de la base de données
-hibernate.hbm2ddl.auto=update
+#hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.username=sa
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/business/Context.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -19,6 +19,9 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* Contexte du dépouillement du sondage (PATTERN STRATEGY).
*
@@ -26,6 +29,10 @@
* @version $Id$
*/
public class Context {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(Context.class);
+
/**
* Booléen permettant de savoir si la méthode doit calculer la valeur des
* choix en fonction des groupes
@@ -115,6 +122,7 @@
try {
method.executeMethod(choices, groupCounting);
} catch (Exception e) {
+ log.error("L'exécution du dépouillement a échoué", e);
return false;
}
this.results.clear();
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2009-08-18 07:49:38 UTC (rev 2730)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceExportImpl.java 2009-08-18 12:22:46 UTC (rev 2731)
@@ -96,8 +96,7 @@
// Création d'un nouveau document JDOM avec le fichier XML en argument
document = sxb.build(new File(filePath));
} catch (Exception e) {
- log.error("Erreur lors de l'analyse du document : " + filePath
- + ". " + e.getMessage());
+ log.error("Erreur lors de l'analyse du document : " + filePath, e);
}
// Initialisation d'un nouvel élément racine
@@ -364,7 +363,7 @@
sortie.output(document, new FileOutputStream(file));
} catch (java.io.IOException e) {
log.error("Erreur lors de l'enregistrement du document : "
- + filePath + ". " + e.getMessage());
+ + filePath, e);
}
}
1
0
r2730 - in trunk: . pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll pollen-ui/src/main/java/org/chorem/pollen/ui/utils
by nrannou@users.nuiton.org 18 Aug '09
by nrannou@users.nuiton.org 18 Aug '09
18 Aug '09
Author: nrannou
Date: 2009-08-18 09:49:38 +0200 (Tue, 18 Aug 2009)
New Revision: 2730
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/utils/PasswordGenerator.java
trunk/todo.txt
Log:
modification d'un vote par url forg?\195?\169e
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 2009-08-17 15:02:38 UTC (rev 2729)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2009-08-18 07:49:38 UTC (rev 2730)
@@ -209,7 +209,11 @@
/** Liste des choix */
private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>();
+
+ /** Identifiant du compte correspondant à l'adresse forgée */
+ private String pollAccountId;
+ /** Compte du votant */
@Property
private PollAccountDTO pollAccount;
@@ -444,12 +448,15 @@
// si le votant du vote correspond au votingId
if (account.getVotingId().equals(votingId)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("vote account: " + account.getId());
+ logger.debug("voting account: " + pollAccountId);
+ }
- // si le votant du vote correspond au votant actuel (pollAccount)
- // TODO autoriser la modification au pollAccount actuel
- /*if (account.getId().equals(pollAccount.getId())) {
+ // si le votant du vote correspond au votant actuel (pollAccountId)
+ if (pollAccountId.equals(account.getId())) {
modifAllowed = true;
- }*/
+ }
// si l'utilisateur du vote correspond à l'utilisateur actuel (user)
if (userExists && user.getId().length() > 0) {
@@ -952,6 +959,7 @@
String accountId = id.split(":", 2)[1];
pollAccount = servicePollAccount
.findPollAccountByAccountId(accountId);
+ pollAccountId = pollAccount.getId();
}
if (pollAccount == null) {
pollAccount = new PollAccountDTO();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java 2009-08-17 15:02:38 UTC (rev 2729)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/PasswordGenerator.java 2009-08-18 07:49:38 UTC (rev 2730)
@@ -46,7 +46,6 @@
c = 'A' + (int) (Math.random() * 26);
break;
default:
- System.out.println("carTypeError");
break;
}
chars[i] = (char) c;
Modified: trunk/todo.txt
===================================================================
--- trunk/todo.txt 2009-08-17 15:02:38 UTC (rev 2729)
+++ trunk/todo.txt 2009-08-18 07:49:38 UTC (rev 2730)
@@ -1,7 +1,6 @@
TODO
envoi emails de rappel
-modification d'un vote par url forgée (sondage restreint)
amélioration des tests
1
0