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
- 3260 discussions
r2739 - trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services
by nrannou@users.chorem.org 21 Aug '09
by nrannou@users.chorem.org 21 Aug '09
21 Aug '09
Author: nrannou
Date: 2009-08-21 15:46:11 +0200 (Fri, 21 Aug 2009)
New Revision: 2739
Modified:
trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java
trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java
Log:
modification des tests
Modified: trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java
===================================================================
--- trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java 2009-08-20 15:12:21 UTC (rev 2738)
+++ trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java 2009-08-21 13:46:11 UTC (rev 2739)
@@ -24,5 +24,18 @@
* @version $Id$
*/
public interface PollDTOCreator {
+
+ /**
+ * Création d'un sondage aléatoire.
+ *
+ * @return le sondage
+ */
public PollDTO createPoll();
+
+ /**
+ * Création d'un sondage de test.
+ *
+ * @return le sondage
+ */
+ public PollDTO createTestPoll();
}
\ No newline at end of file
Modified: trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java
===================================================================
--- trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java 2009-08-20 15:12:21 UTC (rev 2738)
+++ trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java 2009-08-21 13:46:11 UTC (rev 2739)
@@ -61,7 +61,7 @@
+ "typeVoteCounting=" + this.typeCount);
}
- PollDTO poll = new PollDTO("poll1");
+ PollDTO poll = new PollDTO("RandomPoll");
poll.setMaxChoiceNb(this.maxChoiceNb);
poll.setPollType(PollType.FREE);
poll.setVoteCounting(this.typeCount);
@@ -72,7 +72,7 @@
private List<PollChoiceDTO> createChoices() {
if (log.isDebugEnabled()) {
- log.debug("Création des choix : " + this.maxChoice);
+ log.debug("Création des choix : ");
}
List<PollChoiceDTO> choices = new ArrayList<PollChoiceDTO>();
for (int i = 1; i <= this.maxChoice; i++) {
@@ -180,4 +180,64 @@
return 1;
}
}
+
+ @Override
+ public PollDTO createTestPoll() {
+ if (log.isDebugEnabled()) {
+ log.debug("Création du sondage : typeVoteCounting=" + typeCount);
+ }
+
+ PollDTO poll = new PollDTO("TestPoll");
+ poll.setMaxChoiceNb(3);
+ poll.setPollType(PollType.FREE);
+ poll.setVoteCounting(typeCount);
+ poll.setChoices(createTestChoices());
+ poll.setVotingGroups(createTestGroups());
+ return poll;
+ }
+
+ private List<PollChoiceDTO> createTestChoices() {
+ int nbChoices = 3;
+ if (log.isDebugEnabled()) {
+ log.debug("Création des choix : " + nbChoices);
+ }
+ List<PollChoiceDTO> choices = new ArrayList<PollChoiceDTO>();
+ for (int i = 1; i <= nbChoices; i++) {
+ choices.add(new PollChoiceDTO(String.valueOf(i)));
+ if (log.isDebugEnabled()) {
+ log.debug("Choice : id=" + i);
+ }
+ }
+ return choices;
+ }
+
+ private List<VotingGroupDTO> createTestGroups() {
+ List<VotingGroupDTO> groups = new ArrayList<VotingGroupDTO>();
+ if (log.isDebugEnabled()) {
+ log.debug("Création des groupes : ");
+ }
+
+ //// groupe 1 : poids 1
+ VotingGroupDTO group = new VotingGroupDTO("group1", 1.0);
+ List<VotingPersonDTO> persons = new ArrayList<VotingPersonDTO>();
+
+ // person 1 : poids 1
+ VotingPersonDTO person1 = new VotingPersonDTO("person1", 1.0);
+ List<VoteToChoiceDTO> choices1 = new ArrayList<VoteToChoiceDTO>();
+ choices1.add(new VoteToChoiceDTO("1", 1.0));
+ person1.setChoices(choices1);
+ persons.add(person1);
+
+ // person 2 : poids 2
+ VotingPersonDTO person2 = new VotingPersonDTO("person2", 2.0);
+ List<VoteToChoiceDTO> choices2 = new ArrayList<VoteToChoiceDTO>();
+ choices2.add(new VoteToChoiceDTO("2", 1.0));
+ person2.setChoices(choices2);
+ persons.add(person2);
+
+ group.setVotingPersons(persons);
+ groups.add(group);
+
+ return groups;
+ }
}
\ No newline at end of file
1
0
r2738 - in trunk: pollen-business/doc pollen-votecounting/doc src/site/resources/schemas src/site/resources/schemas/business src/site/resources/schemas/votecounting src/site/rst/developper
by nrannou@users.chorem.org 20 Aug '09
by nrannou@users.chorem.org 20 Aug '09
20 Aug '09
Author: nrannou
Date: 2009-08-20 17:12:21 +0200 (Thu, 20 Aug 2009)
New Revision: 2738
Modified:
trunk/pollen-business/doc/PollenBusiness.zargo
trunk/pollen-business/doc/ServicePoll.zargo
trunk/pollen-business/doc/ServiceResults.zargo
trunk/pollen-business/doc/ServiceUser.zargo
trunk/pollen-votecounting/doc/exportXML.zargo
trunk/pollen-votecounting/doc/votecountingapi.zargo
trunk/src/site/resources/schemas/DC_Pollen.png
trunk/src/site/resources/schemas/DC_PreventRules.png
trunk/src/site/resources/schemas/business/DC_BusinessDTOs.png
trunk/src/site/resources/schemas/business/DC_ServicePoll.png
trunk/src/site/resources/schemas/business/DC_ServiceResults.png
trunk/src/site/resources/schemas/business/DC_ServiceUser.png
trunk/src/site/resources/schemas/votecounting/DC_ServiceExport.png
trunk/src/site/resources/schemas/votecounting/DC_ServiceExportImpl.png
trunk/src/site/resources/schemas/votecounting/DC_ServiceExportXML.png
trunk/src/site/resources/schemas/votecounting/DC_ServiceVoteCounting.png
trunk/src/site/resources/schemas/votecounting/DC_ServiceVoteCountingImpl.png
trunk/src/site/resources/schemas/votecounting/DC_VoteCountingDTOs.png
trunk/src/site/rst/developper/analyse.rst
Log:
mise ?\195?\160 jour de la doc
Modified: trunk/pollen-business/doc/PollenBusiness.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/doc/ServicePoll.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/doc/ServiceResults.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/doc/ServiceUser.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-votecounting/doc/exportXML.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-votecounting/doc/votecountingapi.zargo
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/DC_Pollen.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/DC_PreventRules.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/business/DC_BusinessDTOs.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/business/DC_ServicePoll.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/business/DC_ServiceResults.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/business/DC_ServiceUser.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/votecounting/DC_ServiceExport.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/votecounting/DC_ServiceExportImpl.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/votecounting/DC_ServiceExportXML.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/votecounting/DC_ServiceVoteCounting.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/votecounting/DC_ServiceVoteCountingImpl.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/resources/schemas/votecounting/DC_VoteCountingDTOs.png
===================================================================
(Binary files differ)
Modified: trunk/src/site/rst/developper/analyse.rst
===================================================================
--- trunk/src/site/rst/developper/analyse.rst 2009-08-20 13:00:52 UTC (rev 2737)
+++ trunk/src/site/rst/developper/analyse.rst 2009-08-20 15:12:21 UTC (rev 2738)
@@ -316,7 +316,9 @@
- method, Action à déclencher.
- scope, Contexte dans lequel l'action peut se déclencher.
- sensibility, Valeur provoquant le déclenchement de l'action.
-- repeated, Indique si l'action peut se déclencher de manière répétitive.
+- active, Indique si la règle est actuellement active
+- oneTime, Indique si l'action doit se déclencher une seule fois (la règle est désactivée après sa première exécution).
+- repeated, Indique si l'action peut se déclencher de manière répétitive (une action de sensibilité 2 est déclenché pour les valeurs 2, 4, 6, 8...).
.. image:: ../schemas/DC_PreventRules.png
:alt: Cycle de vie d'un sondage
1
0
20 Aug '09
Author: nrannou
Date: 2009-08-20 15:00:52 +0200 (Thu, 20 Aug 2009)
New Revision: 2737
Added:
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuth.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUser.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.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/ServiceAuthImplTest.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/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java
Log:
modification tests et logs
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuth.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuth.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuth.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -27,11 +27,21 @@
public interface ServiceAuth {
/**
- * Identification d'un utilisateur
+ * Identification d'un utilisateur. Vérification du couple login, password.
*
- * @param login loin de l'utilisateur qui s'authentifie
+ * @param login le login de l'utilisateur à identifié
* @param password le password entré par l'utilisateur
- * @return l'utilisateur dont le login est login
+ * @return vrai si l'utilisateur est identifié, false sinon
*/
- public UserDTO isLoginRight(String login, String password);
+ public boolean isLoginRight(String login, String password);
+
+ /**
+ * Identification d'un utilisateur. Récupération des informations de cet
+ * utilisateur.
+ *
+ * @param login le login de l'utilisateur à identifié
+ * @param password le password entré par l'utilisateur
+ * @return l'utilisateur identifié par le login
+ */
+ public UserDTO getUser(String login, String password);
}
\ No newline at end of file
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -46,8 +46,38 @@
}
@Override
- public UserDTO isLoginRight(String login, String password) {
+ public boolean isLoginRight(String login, String password) {
TopiaContext transaction = null;
+ boolean result = false;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
+
+ UserAccount userEntity = userDAO.findByLogin(login);
+ if (userEntity != null && password.equals(userEntity.getPassword())) {
+ result = true;
+ }
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ + ((userEntity == null) ? "null" : userEntity
+ .getLogin()));
+ }
+
+ return result;
+ } catch (TopiaException e) {
+ ContextUtil.doCatch(e, transaction);
+ return false;
+ }
+ }
+
+ @Override
+ public UserDTO getUser(String login, String password) {
+ TopiaContext transaction = null;
UserDTO result = null;
try {
transaction = rootContext.beginTransaction();
@@ -57,15 +87,13 @@
UserAccount userEntity = userDAO.findByLogin(login);
if (userEntity != null && password.equals(userEntity.getPassword())) {
result = converter.createUserDTO(userEntity);
- } else {
- result = null;
}
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getLogin()));
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -67,8 +67,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -126,8 +126,8 @@
}
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + choiceDTO.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + choiceDTO.getId());
}
return resu;
@@ -151,8 +151,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + choiceId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + choiceId);
}
return true;
@@ -181,8 +181,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -215,8 +215,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -252,8 +252,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceCommentImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -70,8 +70,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -125,8 +125,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + comment.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + comment.getId());
}
return true;
@@ -150,8 +150,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + commentId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + commentId);
}
return true;
@@ -180,8 +180,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -217,8 +217,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -91,8 +91,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -161,8 +161,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + votingList.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + votingList.getId());
}
return true;
@@ -186,8 +186,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + votingListId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + votingListId);
}
return true;
@@ -218,8 +218,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -249,8 +249,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -288,8 +288,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -326,8 +326,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -406,8 +406,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + personList.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + personList.getId());
}
return true;
@@ -431,8 +431,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + personListId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + personListId);
}
return true;
@@ -465,8 +465,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info(personListEntities.size()
+ if (log.isDebugEnabled()) {
+ log.debug(personListEntities.size()
+ " entities deleted for user: " + userId);
}
@@ -498,8 +498,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -529,8 +529,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -563,8 +563,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -602,8 +602,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -76,8 +76,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
} catch (TopiaException e) {
@@ -112,8 +112,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return pollAccountEntity;
@@ -170,8 +170,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + pollAccountId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + pollAccountId);
}
return true;
@@ -205,8 +205,8 @@
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + pollAccountDTO.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + pollAccountDTO.getId());
}
return resu;
@@ -237,8 +237,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -270,8 +270,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -303,8 +303,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -343,8 +343,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
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 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -70,11 +70,6 @@
Poll pollEntity = pollDAO.create();
- if (log.isDebugEnabled()) {
- log.debug("service " + pollDTO.getVoteCounting() + " "
- + pollDTO.getPollType());
- }
-
// Identifiant du sondage
String id = UUID.randomUUID().toString();
pollDTO.setPollId(id.replaceAll("-", ""));
@@ -84,18 +79,16 @@
// Création du pollAccount associé au sondage
ServicePollAccount spa = new ServicePollAccountImpl();
- if (log.isDebugEnabled()) {
- log.debug("userId : " + pollDTO.getUserId());
- }
PollAccount pollAccountEntity = spa.createPollAccount(pollDTO
.getCreatorId(), pollDTO.getCreatorEmail(), pollDTO
.getUserId());
+ pollEntity.setCreator(pollAccountEntity);
+
if (log.isDebugEnabled()) {
- log
- .debug("pollAccountEntity created: "
- + pollAccountEntity != null);
+ log.debug("userId: " + pollDTO.getUserId()
+ + ", pollAccountEntity created: "
+ + (pollAccountEntity != null));
}
- pollEntity.setCreator(pollAccountEntity);
topiaId = pollEntity.getTopiaId();
@@ -125,8 +118,8 @@
if (log.isDebugEnabled()) {
log.debug("creator after creation: " + pollEntity.getCreator());
}
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -157,8 +150,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + pollDTO.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + pollDTO.getId());
}
return true;
@@ -182,8 +175,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + pollId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + pollId);
}
return true;
@@ -212,8 +205,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -243,8 +236,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -273,8 +266,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -307,8 +300,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -344,8 +337,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -393,8 +386,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -434,8 +427,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -471,8 +464,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -504,8 +497,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + pollId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + pollId);
}
return true;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -68,8 +68,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -132,8 +132,8 @@
}
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + preventRuleDTO.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + preventRuleDTO.getId());
}
return resu;
@@ -159,8 +159,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + preventRuleId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + preventRuleId);
}
return true;
@@ -191,8 +191,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -231,8 +231,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUser.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUser.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUser.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -79,15 +79,6 @@
public List<UserDTO> selectUsers(Map<String, Object> properties);
/**
- * Ajout d'un compte à un utilisateur
- *
- * @param login identifiant de l'utilisateur
- * @param pollAccountId identifiant du compte à ajouter
- * @return true si le compte a été ajouté
- */
- public boolean addPollAccountToUser(String login, String pollAccountId);
-
- /**
* Mise à jour du mot de passe d'un utilisateur
*
* @param user l'utilisateur
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -23,8 +23,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.converters.DataUserConverter;
import org.chorem.pollen.business.dto.UserDTO;
-import org.chorem.pollen.business.persistence.PollAccount;
-import org.chorem.pollen.business.persistence.PollAccountDAO;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.UserAccountDAO;
@@ -59,7 +57,8 @@
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
if (userDAO.findByLogin(user.getLogin()) != null
- || userDAO.findByEmail(user.getEmail()) != null) {
+ || (!"".equals(user.getEmail()) && userDAO.findByEmail(user
+ .getEmail()) != null)) {
return null;
}
@@ -70,8 +69,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -95,8 +94,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + userEntity.getTopiaId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + userEntity.getTopiaId());
}
return true;
@@ -119,8 +118,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + userEntity.getTopiaId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + userEntity.getTopiaId());
}
return true;
@@ -149,8 +148,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entity found: "
+ ((result == null) ? "null" : result.getId()));
}
@@ -186,8 +185,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
@@ -215,8 +214,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + user.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + user.getId());
}
return true;
@@ -228,35 +227,6 @@
}
@Override
- public boolean addPollAccountToUser(String login, String pollAccountId) {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
-
- UserAccount userEntity = userDAO.findByLogin(login);
- PollAccountDAO pollAccountDAO = PollenModelDAOHelper
- .getPollAccountDAO(transaction);
- PollAccount pollAccountEntity = pollAccountDAO
- .findByTopiaId(pollAccountId);
- userEntity.addPollAccount(pollAccountEntity);
- userEntity.update();
- transaction.commitTransaction();
- transaction.closeContext();
-
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + userEntity.getTopiaId());
- }
-
- return true;
- } catch (TopiaException e) {
- ContextUtil.doCatch(e, transaction);
- return false;
- }
- }
-
- @Override
public boolean updatePasswordUser(UserDTO user, String newPassword) {
TopiaContext transaction = null;
try {
@@ -271,8 +241,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + user.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + user.getId());
}
return true;
@@ -295,6 +265,11 @@
}
transaction.closeContext();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entity exists for the login " + login + ": "
+ + userExists);
+ }
} catch (TopiaException e) {
ContextUtil.doCatch(e, transaction);
return true;
@@ -315,6 +290,11 @@
}
transaction.closeContext();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Entity exists for the email " + email + ": "
+ + userExists);
+ }
} catch (TopiaException e) {
ContextUtil.doCatch(e, transaction);
return true;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -92,8 +92,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity created: " + topiaId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity created: " + topiaId);
}
return topiaId;
@@ -118,8 +118,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity updated: " + voteDTO.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Entity updated: " + voteDTO.getId());
}
return true;
@@ -142,8 +142,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entity deleted: " + voteId);
+ if (log.isDebugEnabled()) {
+ log.debug("Entity deleted: " + voteId);
}
return true;
@@ -179,8 +179,8 @@
transaction.commitTransaction();
transaction.closeContext();
- if (log.isInfoEnabled()) {
- log.info("Entities found: "
+ if (log.isDebugEnabled()) {
+ log.debug("Entities found: "
+ ((results == null) ? "null" : results.size()));
}
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 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/business/PreventRuleManagerTest.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -61,7 +61,7 @@
@Test
public void testPrintAction() {
PreventRuleDTO preventRule = new PreventRuleDTO("test", 2, false,
- PreventRuleManager.PRINT_ACTION);
+ PreventRuleManager.NULL_ACTION);
manager = new PreventRuleManager(preventRule);
assertTrue(manager.execute());
@@ -82,7 +82,7 @@
@Test
public void testPrintActionRepeat() {
PreventRuleDTO preventRule = new PreventRuleDTO("test", 2, true,
- PreventRuleManager.PRINT_ACTION);
+ PreventRuleManager.NULL_ACTION);
manager = new PreventRuleManager(preventRule);
assertTrue(manager.execute());
@@ -100,7 +100,7 @@
@Test
public void testPrintActionOneTime() {
PreventRuleDTO preventRule = new PreventRuleDTO("test", 2, false,
- PreventRuleManager.PRINT_ACTION);
+ PreventRuleManager.NULL_ACTION);
preventRule.setOneTime(true);
manager = new PreventRuleManager(preventRule);
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceAuthImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceAuthImplTest.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceAuthImplTest.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -17,12 +17,11 @@
package org.chorem.pollen.business.services;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.chorem.pollen.business.dto.UserDTO;
-import org.chorem.pollen.business.services.ServiceAuthImpl;
-import org.chorem.pollen.business.services.ServiceUser;
-import org.chorem.pollen.business.services.ServiceUserImpl;
import org.chorem.pollen.business.utils.ContextUtil;
import org.junit.After;
import org.junit.AfterClass;
@@ -63,16 +62,34 @@
*/
@Test
public void testIsLoginRight() {
- String login = "testLogin";
- String password = "testPassword";
- UserDTO result1 = instance.isLoginRight(login, password);
+ String login = "login_isLoginRight";
+ String password = "password_isLoginRight";
+ boolean result1 = instance.isLoginRight(login, password);
+ assertFalse(result1);
+
+ UserDTO dto = new UserDTO();
+ dto.setLogin(login);
+ ServiceUser smu = new ServiceUserImpl();
+ smu.createUser(dto, password);
+ boolean result2 = instance.isLoginRight(login, password);
+ assertTrue(result2);
+ }
+
+ /**
+ * Test of getUser method, of class ServiceAuthImpl.
+ */
+ @Test
+ public void testGetUser() {
+ String login = "login_getUser";
+ String password = "password_getUser";
+ UserDTO result1 = instance.getUser(login, password);
assertNull(result1);
UserDTO dto = new UserDTO();
dto.setLogin(login);
ServiceUser smu = new ServiceUserImpl();
smu.createUser(dto, password);
- UserDTO result2 = instance.isLoginRight(login, password);
+ UserDTO result2 = instance.getUser(login, password);
assertEquals(login, result2.getLogin());
}
}
\ No newline at end of file
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 15:48:01 UTC (rev 2736)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -21,13 +21,13 @@
import java.util.Date;
import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.dto.PollAccountDTO;
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.dto.UserDTO;
-import org.chorem.pollen.business.services.ServicePollImpl;
-import org.chorem.pollen.business.services.ServiceUser;
-import org.chorem.pollen.business.services.ServiceUserImpl;
+import org.chorem.pollen.business.dto.VoteDTO;
import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
@@ -185,7 +185,8 @@
// création de l'utilisateur
UserDTO user = new UserDTO();
- user.setLogin("login");
+ user.setLogin("login_findPollsByUser");
+ user.setEmail("email_findPollsByUser");
ServiceUser su = new ServiceUserImpl();
String userId = su.createUser(user, "password");
@@ -201,6 +202,40 @@
}
/**
+ * Test of findParticipatedPolls method, of class ServicePollImpl.
+ */
+ @Test
+ public void testFindParticipatedPolls() {
+
+ // création de l'utilisateur
+ UserDTO user = new UserDTO();
+ user.setLogin("login_findParticipatedPolls");
+ user.setEmail("email_findParticipatedPolls");
+ ServiceUser su = new ServiceUserImpl();
+ String userId = su.createUser(user, "password");
+
+ // création du compte associé à l'utilisateur
+ PollAccountDTO account = new PollAccountDTO();
+ account.setUserId(userId);
+ ServicePollAccount spa = new ServicePollAccountImpl();
+ String accountId = spa.createPollAccount(account);
+
+ // création du sondage
+ PollDTO poll = new PollDTO();
+ poll.setTitle("Test_findParticipatedPolls");
+ String pollId = instance.createPoll(poll);
+
+ // création du vote
+ VoteDTO vote = new VoteDTO(accountId, pollId, null);
+ ServiceVote sv = new ServiceVoteImpl();
+ sv.createVote(vote, account);
+
+ // recherche des sondages de l'utilisateur
+ List<PollDTO> result = instance.findParticipatedPolls(userId);
+ assertEquals(result.size(), 1);
+ }
+
+ /**
* Test of findRunningPolls method, of class ServicePollImpl.
*/
@Test
Added: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -0,0 +1,181 @@
+/* *##% Pollen
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
+
+package org.chorem.pollen.business.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.chorem.pollen.business.dto.UserDTO;
+import org.chorem.pollen.business.utils.ContextUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests du service de gestion des utilisateurs.
+ *
+ * @author rannou
+ * @version $Id$
+ */
+public class ServiceUserImplTest {
+ private ServiceUserImpl instance;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ ContextUtil.getInstance().buildContext();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ ContextUtil.getInstance().getContext().clear(false);
+ }
+
+ @Before
+ public void setUp() {
+ instance = new ServiceUserImpl();
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of createUser method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testCreateUser() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_CreateUser");
+ String result = instance.createUser(user, "password");
+ assertTrue(result.length() > 0);
+ }
+
+ /**
+ * Test of updateUser method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testUpdateUser() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_UpdateUser");
+ String userId = instance.createUser(user, "password");
+ user.setId(userId);
+ user.setFirstName("firstName_UpdateUser");
+ boolean result = instance.updateUser(user);
+ assertTrue(result);
+ }
+
+ /**
+ * Test of deleteUser method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testDeleteUser() {
+
+ // delete with dto
+ UserDTO user = new UserDTO();
+ user.setLogin("login_DeleteUser");
+ user.setId(instance.createUser(user, "password"));
+ boolean result = instance.deleteUser(user);
+ assertTrue(result);
+
+ // delete with login
+ UserDTO user2 = new UserDTO();
+ user2.setLogin("login_DeleteUser");
+ String userId2 = instance.createUser(user2, "password");
+ boolean result2 = instance.deleteUser("login_DeleteUser");
+ assertTrue(result2);
+ }
+
+ /**
+ * Test of findUserById method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testFindUserById() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_FindUserById");
+ String userId = instance.createUser(user, "password");
+ UserDTO result = instance.findUserById(userId);
+ String resultId = result.getId();
+ assertEquals(userId, resultId);
+ }
+
+ /**
+ * Test of selectUsers method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testSelectUsers() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_SelectUsers");
+ String userId = instance.createUser(user, "password");
+ List<UserDTO> result = instance.selectUsers(null);
+ assertTrue(result.size() > 1);
+ }
+
+ /**
+ * Test of updatePasswordUser method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testUpdatePasswordUser() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_UpdatePasswordUser");
+ user.setId(instance.createUser(user, "password"));
+ instance.updatePasswordUser(user, "newPassword");
+
+ ServiceAuth sa = new ServiceAuthImpl();
+ UserDTO result = sa.getUser(user.getLogin(), "newPassword");
+ assertNotNull(result);
+ }
+
+ /**
+ * Test of isUserLoginExisting method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testIsUserLoginExisting() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_IsUserLoginExisting");
+ user.setEmail("email_IsUserLoginExisting");
+ String userId = instance.createUser(user, "password");
+
+ boolean result = instance
+ .isUserLoginExisting("login_IsUserLoginExisting");
+ boolean result2 = instance.isUserLoginExisting("login_False");
+ assertTrue(result);
+ assertFalse(result2);
+ }
+
+ /**
+ * Test of isUserEmailExisting method, of class ServiceUserImpl.
+ */
+ @Test
+ public void testIsUserEmailExisting() {
+ UserDTO user = new UserDTO();
+ user.setLogin("login_IsUserEmailExisting");
+ user.setEmail("email_IsUserEmailExisting");
+ String userId = instance.createUser(user, "password");
+
+ boolean result = instance
+ .isUserEmailExisting("email_IsUserEmailExisting");
+ boolean result2 = instance.isUserEmailExisting("email_False");
+ assertTrue(result);
+ assertFalse(result2);
+ }
+}
\ No newline at end of file
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Rev Revision"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -164,7 +164,7 @@
* @return la zone à mettre à jour
*/
Object onSuccessFromLoginForm() {
- UserDTO userDTO = serviceAuth.isLoginRight(login, MD5.encode(password));
+ UserDTO userDTO = serviceAuth.getUser(login, MD5.encode(password));
if (userDTO != null) {
user = userDTO;
feedback.addInfo(messages.get("loginOk"));
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -77,7 +77,7 @@
Object onSuccessFromLoginCompForm() {
// Récupération de l'utilisateur identifié
- UserDTO userDTO = serviceAuth.isLoginRight(loginComp, MD5
+ UserDTO userDTO = serviceAuth.getUser(loginComp, MD5
.encode(passwordComp));
if (userDTO != null) {
user = userDTO;
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -131,7 +131,7 @@
modify = true;
// L'utilisateur a renseigné le mauvais mot de passe
- if (serviceAuth.isLoginRight(newUser.getLogin(), MD5.encode(password)) == null) {
+ if (!serviceAuth.isLoginRight(newUser.getLogin(), MD5.encode(password))) {
myAccountForm.recordError(passwordField, messages
.get("badPassword"));
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2009-08-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -146,7 +146,7 @@
if (!registerForm.getHasErrors()) {
if (serviceUser.createUser(newUser, MD5.encode(password1)) != null) {
sendMailNotification();
- user = serviceAuth.isLoginRight(newUser.getLogin(), MD5
+ user = serviceAuth.getUser(newUser.getLogin(), MD5
.encode(password1));
return "Index";
}
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-19 15:48:01 UTC (rev 2736)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/votecounting/services/ServiceVoteCountingImpl.java 2009-08-20 13:00:52 UTC (rev 2737)
@@ -100,6 +100,11 @@
* @return resultat
*/
private VoteCountingResultDTO execute(PollDTO poll) {
+ if (log.isInfoEnabled()) {
+ log.info("Dépouillement (byGroup=" + isByGroup + ") du sondage "
+ + poll.getPollId());
+ }
+
// Création et remplissage du contexte
this.createContext(poll.getVoteCounting());
this.fillContext(poll);
@@ -120,8 +125,8 @@
resChoice.setValue(choice.getValue());
resChoice.setPercentage(Utils.calculatePercentage(choice, choices));
resChoice.setResult(this.isChoiceResult(choice));
- if (log.isInfoEnabled()) {
- log.info(choice + " _ result ? " + resChoice.isResult());
+ if (log.isDebugEnabled()) {
+ log.debug(choice + " _ result ? " + resChoice.isResult());
}
resChoices.add(resChoice);
}
@@ -165,8 +170,8 @@
* @param poll : Sondage
*/
private void fillContext(PollDTO poll) {
- if (log.isInfoEnabled()) {
- log.info("Ajout poll : " + poll.getPollId());
+ if (log.isDebugEnabled()) {
+ log.debug("Ajout poll : " + poll.getPollId());
}
for (Object o : poll.getChoices()) {
PollChoiceDTO choice = (PollChoiceDTO) o;
@@ -184,8 +189,8 @@
* @param group : groupe lié au sondage
*/
private void routeGroup(VotingGroupDTO group) {
- if (log.isInfoEnabled()) {
- log.info("Ajout group : " + group.getIdGroup() + " _ weight="
+ if (log.isDebugEnabled()) {
+ log.debug("Ajout group : " + group.getIdGroup() + " _ weight="
+ group.getWeight());
}
this.context.addGroup(group.getIdGroup(), group.getWeight());
@@ -202,8 +207,8 @@
* @param person : personne ayant voté
*/
private void routePerson(VotingPersonDTO person) {
- if (log.isInfoEnabled()) {
- log.info("Ajout person : " + person.getVotingId() + " _ weight="
+ if (log.isDebugEnabled()) {
+ log.debug("Ajout person : " + person.getVotingId() + " _ weight="
+ person.getWeight());
}
for (Object o : person.getChoices()) {
@@ -221,8 +226,8 @@
*/
private void addVoteToContext(VoteToChoiceDTO vote, double weight,
String votingID) {
- if (log.isInfoEnabled()) {
- log.info("Ajout vote : " + vote.getValue() + " _ choice="
+ if (log.isDebugEnabled()) {
+ log.debug("Ajout vote : " + vote.getValue() + " _ choice="
+ vote.getIdChoice());
}
this.context.getChoice(vote.getIdChoice())
1
0
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