Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
Author: fdesbois
Date: 2010-03-23 12:15:12 +0100 (Tue, 23 Mar 2010)
New Revision: 2955
Log:
Last commit for 1.3 snapshot : very unstable version...
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java
trunk/pollen-ui/src/main/webapp/ErrorPage.tml
Removed:
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.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/DataPollConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.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/services/ServiceAuthImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.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/ServicePoll.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
trunk/pollen-business/src/main/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/ServiceResultsImpl.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/ServiceVote.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/xmi/pollen.zargo
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java
trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/VoteCountingType.java
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -224,7 +224,7 @@
BinderProvider.getBinder(
PollAccount.class, PollAccountDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
- dto.setAccountId(entity.getAccountId());
+ dto.setAccountUId(entity.getAccountId());
return dto;
}
@@ -275,7 +275,7 @@
dto.setVotingListId(list.getTopiaId());
// vote for a person (pollAccount)
} else {/*if (account != null) { must have a pollaccount */
- dto.setPollAccountId(account.getTopiaId());
+ //dto.setPollAccountId(account.getTopiaId());
dto.setName(account.getVotingId());
// if (account.getUserAccount() != null) {
// dto.setUserId(account.getUserAccount().getTopiaId());
@@ -285,10 +285,12 @@
// Choices for voteValues
for (VoteToChoice choice : entity.getChoiceVoteToChoice()) {
- ChoiceDTO choiceDTO =
- convert(choice.getChoice(), new ChoiceDTO());
- choiceDTO.setValue(choice.getVoteValue());
- dto.addChoice(choiceDTO);
+// ChoiceDTO choiceDTO =
+// convert(choice.getChoice(), new ChoiceDTO());
+// choiceDTO.setValue(choice.getVoteValue());
+// dto.addChoice(choiceDTO);
+ dto.setChoiceValue(choice.getChoice().getTopiaId(),
+ choice.getVoteValue());
}
return dto;
}
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollAccountConverter.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -108,7 +108,7 @@
public PollAccountDTO createPollAccountDTO(PollAccount ePollAccount) {
PollAccountDTO dto = new PollAccountDTO();
dto.setId(ePollAccount.getTopiaId());
- dto.setAccountId(ePollAccount.getAccountId());
+ dto.setAccountUId(ePollAccount.getAccountId());
dto.setEmail(ePollAccount.getEmail());
dto.setVotingId(ePollAccount.getVotingId());
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -33,8 +33,6 @@
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PreventRule;
-import org.chorem.pollen.business.services.ServiceChoice;
-import org.chorem.pollen.business.services.ServiceChoiceImpl;
import org.chorem.pollen.business.services.ServicePreventRule;
import org.chorem.pollen.business.services.ServicePreventRuleImpl;
import org.nuiton.topia.TopiaException;
@@ -134,50 +132,50 @@
}
return results;
}
+
+// /**
+// * Persistance des choix d'une entité sondage à partir d'un DTO.
+// *
+// * @param pollDTO le dto sondage
+// * @param ePoll l'entité sondage
+// * @deprecated use dao managment instead
+// */
+// @Deprecated
+// public void persistChoices(PollDTO pollDTO, Poll ePoll, PollenContextImplementor context)
+// throws TopiaException, PollenBusinessException {
+//
+// // mise à jour ou création des choix
+// ServiceChoice sChoice = new ServiceChoiceImpl(context);
+// for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
+// boolean updated = sChoice.updateChoice(choiceDTO);
+// if (!updated) {
+// choiceDTO.setId(sChoice.createChoice(choiceDTO));
+// }
+//
+// if (log.isDebugEnabled()) {
+// log.debug("Choice " + choiceDTO.getName() + " ("
+// + choiceDTO.getId() + ") updated: " + updated);
+// }
+// }
+//
+// // suppression des choix
+// boolean validChoice = false;
+// Iterator<Choice> itChoice = ePoll.getChoice().iterator();
+// while (itChoice.hasNext()) {
+// Choice currentChoice = itChoice.next();
+// for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
+// if (currentChoice.getTopiaId().equals(choiceDTO.getId())) {
+// validChoice = true;
+// }
+// }
+// if (!validChoice) {
+// sChoice.deleteChoice(currentChoice.getTopiaId());
+// }
+// validChoice = false;
+// }
+// }
/**
- * Persistance des choix d'une entité sondage à partir d'un DTO.
- *
- * @param pollDTO le dto sondage
- * @param ePoll l'entité sondage
- * @deprecated use dao managment instead
- */
- @Deprecated
- public void persistChoices(PollDTO pollDTO, Poll ePoll, PollenContextImplementor context)
- throws TopiaException, PollenBusinessException {
-
- // mise à jour ou création des choix
- ServiceChoice sChoice = new ServiceChoiceImpl(context);
- for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
- boolean updated = sChoice.updateChoice(choiceDTO);
- if (!updated) {
- choiceDTO.setId(sChoice.createChoice(choiceDTO));
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Choice " + choiceDTO.getName() + " ("
- + choiceDTO.getId() + ") updated: " + updated);
- }
- }
-
- // suppression des choix
- boolean validChoice = false;
- Iterator<Choice> itChoice = ePoll.getChoice().iterator();
- while (itChoice.hasNext()) {
- Choice currentChoice = itChoice.next();
- for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
- if (currentChoice.getTopiaId().equals(choiceDTO.getId())) {
- validChoice = true;
- }
- }
- if (!validChoice) {
- sChoice.deleteChoice(currentChoice.getTopiaId());
- }
- validChoice = false;
- }
- }
-
- /**
* Persistance des règles de notification d'une entité sondage à partir d'un
* DTO.
*
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -20,6 +20,7 @@
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.dto.VoteDTO;
import org.chorem.pollen.business.persistence.Choice;
@@ -113,11 +114,14 @@
if (eVote.getChoiceVoteToChoice() != null) {
DataChoiceConverter choiceConverter = new DataChoiceConverter();
for (VoteToChoice voteToChoice : eVote.getChoiceVoteToChoice()) {
- if (voteToChoice.getChoice() != null) {
- ChoiceDTO choiceDTO = choiceConverter
- .createChoiceDTO(voteToChoice.getChoice());
- choiceDTO.setValue(voteToChoice.getVoteValue());
- voteDTO.getChoiceDTOs().add(choiceDTO);
+ Choice choice = voteToChoice.getChoice();
+ if (choice != null) {
+// ChoiceDTO choiceDTO = choiceConverter
+// .createChoiceDTO(voteToChoice.getChoice());
+// choiceDTO.setValue(voteToChoice.getVoteValue());
+// voteDTO.getChoiceDTOs().add(choiceDTO);
+ voteDTO.setChoiceValue(choice.getTopiaId(),
+ voteToChoice.getVoteValue());
}
}
}
@@ -148,16 +152,46 @@
*
* @param voteDTO Le dto vote.
* @param eVote L'entité vote.
+ * @throws TopiaException
+ * @deprecated must copy this code in serviceVote
*/
+ @Deprecated
public void populateChoiceVote(VoteDTO voteDTO, Vote eVote)
throws TopiaException {
+//
+// for (ChoiceDTO choiceDTO : voteDTO.getChoiceDTOs()) {
+// choiceDTO.setVoteId(eVote.getTopiaId());
+// }
+//
+// eVote.setChoiceVoteToChoice(this.getVoteToChoices(voteDTO
+// .getChoiceDTOs()));
- for (ChoiceDTO choiceDTO : voteDTO.getChoiceDTOs()) {
- choiceDTO.setVoteId(eVote.getTopiaId());
+ VoteToChoiceDAO dao =
+ PollenModelDAOHelper.getVoteToChoiceDAO(super.transaction);
+
+ ChoiceDAO choiceDAO = PollenModelDAOHelper.getChoiceDAO(super.transaction);
+
+ for (Map.Entry<String, Integer> choiceValue :
+ voteDTO.getChoiceValues().entrySet()) {
+
+ // Find existing choice
+ Choice choice = choiceDAO.findByTopiaId(choiceValue.getKey());
+
+ // Find existing vote
+ VoteToChoice voteToChoice = dao.findByProperties(
+ VoteToChoice.CHOICE, choice,
+ VoteToChoice.VOTE, eVote);
+
+ // Create new vote if needed
+ if (voteToChoice == null) {
+ voteToChoice = dao.create(
+ VoteToChoice.CHOICE, choice,
+ VoteToChoice.VOTE, eVote);
+ }
+ // Update vote value
+ voteToChoice.setVoteValue(choiceValue.getValue());
}
- eVote.setChoiceVoteToChoice(this.getVoteToChoices(voteDTO
- .getChoiceDTOs()));
}
/**
@@ -166,6 +200,7 @@
* @param choiceDTOs La liste des dtos choix
* @return la liste d'entités VoteToChoice
*/
+ @Deprecated
private List<VoteToChoice> getVoteToChoices(List<ChoiceDTO> choiceDTOs)
throws TopiaException {
List<VoteToChoice> liste = new ArrayList<VoteToChoice>();
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollAccountDTO.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -29,20 +29,32 @@
*/
public class PollAccountDTO implements Serializable {
- private String id = "";
+ private String id;
- private String accountId = "";
+ /** UId of the account used in urls **/
+ private String accountUId;
- private String votingId = "";
+ /** Name of the account **/
+ private String votingId;
- private String userId = "";
+ /** TopiaId of the user linked with the account **/
+ private String userId;
- private String email = "";
+ /** Email of the account **/
+ private String email;
- private Double weight = 1.;
+ /** Weight of the account (already defined in the vote) **/
+ private Double weight;
- private Boolean hasVoted = false;
+ /**
+ * Determine if the account has already voted (used for vote page)
+ * Seems not necessary to manage vote, no constraint define on changing
+ * existing vote if it's the correct user or account.
+ **/
+ private Boolean hasVoted;
+
+
private String votingListId = "";
private String personListId = "";
@@ -53,10 +65,12 @@
}
+ @Deprecated
public PollAccountDTO(String id) {
this.id = id;
}
+ @Deprecated
public PollAccountDTO(String votingId, String email, String personListId,
String votingListId, String userId) {
super();
@@ -75,12 +89,12 @@
this.id = id;
}
- public String getAccountId() {
- return accountId;
+ public String getAccountUId() {
+ return accountUId;
}
- public void setAccountId(String accountId) {
- this.accountId = accountId;
+ public void setAccountUId(String accountUId) {
+ this.accountUId = accountUId;
}
public String getVotingId() {
@@ -107,10 +121,12 @@
this.email = email;
}
+ @Deprecated
public Double getWeight() {
return weight;
}
+ @Deprecated
public void setWeight(Double weight) {
this.weight = weight;
}
@@ -127,26 +143,32 @@
this.hasVoted = hasVoted;
}
+ @Deprecated
public String getVotingListId() {
return votingListId;
}
+ @Deprecated
public void setVotingListId(String votingListId) {
this.votingListId = votingListId;
}
+ @Deprecated
public String getPersonListId() {
return personListId;
}
+ @Deprecated
public void setPersonListId(String personListId) {
this.personListId = personListId;
}
+ @Deprecated
public List<VoteDTO> getVoteDTOs() {
return voteDTOs;
}
+ @Deprecated
public void setVoteDTOs(List<VoteDTO> voteDTOs) {
this.voteDTOs = voteDTOs;
}
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -17,8 +17,8 @@
package org.chorem.pollen.business.dto;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
/**
* Classe DTO représentant un vote.
@@ -43,8 +43,8 @@
/** the vote is anonymous or not **/
private Boolean anonymous = false;
- /** topiaId of the account who has voted**/
- private String pollAccountId = "";
+ /** account who has voted : only defined if anonymous = false **/
+ private String pollAccountId;
/** QUICK FIX to have pollAccount votingId **/
private String name;
@@ -62,17 +62,20 @@
private String votingListId = "";
/** choices made by this vote **/
- private List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
+// private List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
+ private Map<String, Integer> choiceValues;
public VoteDTO() {
}
+ @Deprecated
public VoteDTO(String id) {
this.id = id;
}
- public VoteDTO(String pollAccountId, String pollId, String votingListId) {
- this.pollAccountId = pollAccountId;
+ @Deprecated
+ public VoteDTO(String accountUId, String pollId, String votingListId) {
+// this.accountUId = accountUId;
this.pollId = pollId;
this.votingListId = votingListId;
}
@@ -93,10 +96,12 @@
this.weight = weight;
}
+ @Deprecated
public String getComment() {
return comment;
}
+ @Deprecated
public void setComment(String comment) {
this.comment = comment;
}
@@ -121,26 +126,32 @@
this.pollAccountId = pollAccountId;
}
+ @Deprecated
public String getName() {
return name;
}
+ @Deprecated
public void setName(String name) {
this.name = name;
}
+ @Deprecated
public String getUserId() {
return userId;
}
+ @Deprecated
public void setUserId(String userId) {
this.userId = userId;
}
+ @Deprecated
public String getPollId() {
return pollId;
}
+ @Deprecated
public void setPollId(String pollId) {
this.pollId = pollId;
}
@@ -153,19 +164,34 @@
this.votingListId = votingListId;
}
- public List<ChoiceDTO> getChoiceDTOs() {
- return choiceDTOs;
+ public void setChoiceValue(String choiceId, Integer value) {
+ getChoiceValues().put(choiceId, value);
}
- public void setChoiceDTOs(List<ChoiceDTO> choiceDTOs) {
- this.choiceDTOs = choiceDTOs;
+ public Integer getChoiceValue(String choiceId) {
+ return getChoiceValues().get(choiceId);
}
- public void addChoice(ChoiceDTO choice) {
- if (choiceDTOs == null) {
- choiceDTOs = new ArrayList<ChoiceDTO>();
+ public Map<String, Integer> getChoiceValues() {
+ if (choiceValues == null) {
+ choiceValues = new HashMap<String, Integer>();
}
- choiceDTOs.add(choice);
+ return choiceValues;
}
+// public List<ChoiceDTO> getChoiceDTOs() {
+// return choiceDTOs;
+// }
+//
+// public void setChoiceDTOs(List<ChoiceDTO> choiceDTOs) {
+// this.choiceDTOs = choiceDTOs;
+// }
+//
+// public void addChoice(ChoiceDTO choice) {
+// if (choiceDTOs == null) {
+// choiceDTOs = new ArrayList<ChoiceDTO>();
+// }
+// choiceDTOs.add(choice);
+// }
+
}
\ 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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -18,7 +18,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataUserConverter;
import org.chorem.pollen.business.dto.UserDTO;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -36,7 +36,9 @@
*
* @param choice le dto choix
* @return l'identifiant du choix
+ * @deprecated only used for tests or internal
*/
+ @Deprecated
public String createChoice(ChoiceDTO choice);
/**
@@ -44,7 +46,9 @@
*
* @param choiceDTO
* @return true si le choix a été mise à jours
+ * @deprecated only used for tests or internal
*/
+ @Deprecated
public boolean updateChoice(ChoiceDTO choiceDTO);
/**
@@ -62,7 +66,9 @@
*
* @param choiceId l'identifiant du choix
* @return le choix
+ * @deprecated only used for tests or internal
*/
+ @Deprecated
public ChoiceDTO findChoiceById(String choiceId);
/**
@@ -71,7 +77,9 @@
* @param choiceName le nom du choix
* @param pollId l'identifiant du sondage
* @return les choix
+ * @deprecated never used
*/
+ @Deprecated
public List<ChoiceDTO> findChoicesByName(String choiceName, String pollId);
/**
@@ -79,6 +87,8 @@
*
* @param properties filtre sur les champs de la table choix
* @return les choix du sondage
+ * @deprecated only used for tests
*/
+ @Deprecated
public List<ChoiceDTO> selectChoices(Map<String, Object> properties);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPersonListConverter;
import org.chorem.pollen.business.converters.DataVotingListConverter;
@@ -61,8 +62,8 @@
public ServiceListImpl(PollenContextImplementor context) {
this.context = context;
- context.getConverter().preparePollAccountConverters();
- context.getConverter().prepareVotingListConverters();
+ this.context.getConverter().preparePollAccountConverters();
+ this.context.getConverter().prepareVotingListConverters();
}
@Override
@@ -204,7 +205,7 @@
// Update change in dtos
account.setId(eAccount.getTopiaId());
- account.setAccountId(eAccount.getAccountId());
+ account.setAccountUId(eAccount.getAccountId());
personList.addPollAccount(account);
} catch (Exception eee) {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -158,5 +158,7 @@
public ChoiceDTO getNewHiddenChoice(ChoiceDTO choice, String votingId);
+ public void createChoice(PollDTO poll, ChoiceDTO choice);
+
public void deleteChoice(PollDTO poll, String choiceId);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -58,7 +58,9 @@
*
* @param pollAccountId le compte a creer
* @return true si le compte a été supprimer
+ * @deprecated never used
*/
+ @Deprecated
public boolean deletePollAccount(String pollAccountId);
/**
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -22,7 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPollAccountConverter;
import org.chorem.pollen.business.dto.PollAccountDTO;
@@ -105,7 +105,7 @@
// Identifiants du compte
String id = UUID.randomUUID().toString();
- pollAccount.setAccountId(id.replaceAll("-", ""));
+ pollAccount.setAccountUId(id.replaceAll("-", ""));
pollAccount.setId(entity.getTopiaId());
converter.populatePollAccountEntity(pollAccount, entity);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -25,6 +25,7 @@
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.converters.DataPollConverter;
import org.chorem.pollen.business.converters.DataVotingListConverter;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -51,7 +52,6 @@
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
-import org.chorem.pollen.business.PollenContextImpl;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.common.PollType;
@@ -82,13 +82,13 @@
public ServicePollImpl(PollenContextImplementor context) {
this.context = context;
- context.getConverter().preparePollConverters();
- context.getConverter().prepareChoiceConverters();
- context.getConverter().prepareVotingListConverters();
- context.getConverter().preparePollAccountConverters();
- context.getConverter().preparePreventRuleConverters();
- context.getConverter().prepareVoteConverters();
- context.getConverter().prepareCommentConverters();
+ this.context.getConverter().preparePollConverters();
+ this.context.getConverter().prepareChoiceConverters();
+ this.context.getConverter().prepareVotingListConverters();
+ this.context.getConverter().preparePollAccountConverters();
+ this.context.getConverter().preparePreventRuleConverters();
+ this.context.getConverter().prepareVoteConverters();
+ this.context.getConverter().prepareCommentConverters();
}
@Override
@@ -803,13 +803,51 @@
choice.getName() + "#" + votingId);
hiddenChoice.setHidden(true);
hiddenChoice.setValue(choice.getValue()); // ??
- hiddenChoice.setPollUId(choice.getPollUId());
- hiddenChoice.setVoteId(choice.getVoteId()); // ??
+// hiddenChoice.setPollUId(choice.getPollUId());
+// hiddenChoice.setVoteId(choice.getVoteId()); // ??
hiddenChoice.setValidate(false);
return hiddenChoice;
}
@Override
+ public void createChoice(PollDTO poll, ChoiceDTO choice) {
+ TopiaContext transaction = null;
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("P:[ createChoice ] : pollUId = " + poll.getPollUId() +
+ " _ choiceName = " + choice.getName() +
+ " _ choiceDescription = " + choice.getDescription());
+ }
+ transaction = context.getRootContext().beginTransaction();
+
+ // Get the poll entity corresponding
+ Poll ePoll = PollenModelDAOHelper.getPollDAO(transaction).
+ findByTopiaId(poll.getId());
+
+ // Create the new choice entity
+ ChoiceDAO dao = PollenModelDAOHelper.getChoiceDAO(transaction);
+ Choice eChoice = context.getConverter().convert(choice,
+ dao.create());
+
+ // Add the choice in the Poll
+ ePoll.addChoice(eChoice);
+
+ transaction.commitTransaction();
+
+ // Update changes in dtos
+ choice.setId(eChoice.getTopiaId());
+ poll.addChoice(choice);
+
+ } catch (Exception eee) {
+ context.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.createChoice"),
+ poll.getTitle(), poll.getId());
+ } finally {
+ context.doFinally(transaction);
+ }
+ }
+
+ @Override
public void deleteChoice(PollDTO poll, String choiceId) {
TopiaContext transaction = null;
try {
@@ -819,7 +857,7 @@
}
transaction = context.getRootContext().beginTransaction();
- // Find the comment
+ // Find the choice
ChoiceDAO dao = PollenModelDAOHelper.getChoiceDAO(transaction);
Choice eChoice = dao.findByTopiaId(choiceId);
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -22,7 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPreventRuleConverter;
import org.chorem.pollen.business.dto.PreventRuleDTO;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataResultConverter;
import org.chorem.pollen.business.converters.DataVoteCountingConverter;
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataUserConverter;
import org.chorem.pollen.business.dto.UserDTO;
@@ -30,7 +31,6 @@
import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.business.utils.MD5;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaQuery;
import static org.nuiton.i18n.I18n.n_;
/**
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -90,4 +90,6 @@
*/
public List<VoteDTO> selectVotes(Map<String, Object> properties);
+ public VoteDTO getNewVote(PollAccountDTO account);
+
}
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -29,14 +29,25 @@
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.dto.VoteDTO;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.ChoiceDAO;
+import org.chorem.pollen.business.persistence.PersonToList;
+import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.business.persistence.Poll;
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.Vote;
import org.chorem.pollen.business.persistence.VoteDAO;
+import org.chorem.pollen.business.persistence.VoteToChoice;
+import org.chorem.pollen.business.persistence.VoteToChoiceDAO;
+import org.chorem.pollen.business.persistence.VotingList;
+import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
+import org.chorem.pollen.common.PollType;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaEntity;
import static org.nuiton.i18n.I18n.n_;
@@ -58,7 +69,7 @@
public ServiceVoteImpl(PollenContextImplementor context) {
this.context = context;
- context.getConverter().prepareVoteConverters();
+ this.context.getConverter().prepareVoteConverters();
}
@Override
@@ -257,6 +268,7 @@
if (user == null) {
return result;
}
+ // Initialize the default account for user
if (user.getFirstName() != null && user.getLastName() != null) {
result.setVotingId(
user.getFirstName() + " " + user.getLastName());
@@ -267,6 +279,8 @@
} else if (user.getLastName() != null) {
result.setVotingId(user.getLastName());
}
+ // Link the new account with the user
+ result.setUserId(user.getId());
return result;
}
@@ -349,4 +363,162 @@
ContextUtil.doFinally(transaction);
}
}
+
+ @Override
+ public VoteDTO getNewVote(PollAccountDTO account) {
+ VoteDTO result = new VoteDTO();
+ result.setWeight(1.);
+ result.setPollAccountId(account.getId());
+ return result;
+ }
+
+ private void updateChoiceValues(TopiaContext transaction,
+ VoteDTO vote, Vote eVote) throws TopiaException {
+
+ VoteToChoiceDAO voteToChoiceDAO =
+ PollenModelDAOHelper.getVoteToChoiceDAO(transaction);
+
+ ChoiceDAO choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
+
+ for (Map.Entry<String, Integer> choiceValue :
+ vote.getChoiceValues().entrySet()) {
+
+ // Find existing choice
+ Choice choice = choiceDAO.findByTopiaId(choiceValue.getKey());
+
+ // Find existing vote
+ VoteToChoice voteToChoice = voteToChoiceDAO.findByProperties(
+ VoteToChoice.CHOICE, choice,
+ VoteToChoice.VOTE, eVote);
+
+ // Create new vote if needed
+ if (voteToChoice == null) {
+ voteToChoice = voteToChoiceDAO.create(
+ VoteToChoice.CHOICE, choice,
+ VoteToChoice.VOTE, eVote);
+ }
+ // Update vote value
+ voteToChoice.setVoteValue(choiceValue.getValue());
+ }
+ }
+
+ private PersonToList validateForRestrictedPoll(TopiaContext transaction,
+ VoteDTO vote, PollAccount eAccount, Poll ePoll)
+ throws TopiaException {
+ PersonToList person = null;
+ if (eAccount == null) {
+ //throw exception : not allowed
+ return person;
+ } else {
+ PersonToListDAO personDAO =
+ PollenModelDAOHelper.getPersonToListDAO(transaction);
+
+ String pPoll =
+ PersonToList.VOTING_LIST + "." + VotingList.POLL;
+
+ TopiaQuery query = personDAO.createQuery().
+ add(PersonToList.POLL_ACCOUNT, eAccount).
+ add(PersonToList.HAS_VOTED, Boolean.FALSE).
+ add(pPoll, ePoll);
+
+ person = personDAO.findByQuery(query);
+ if (person == null && !ePoll.getAnonymous()) {
+ // throw exception : not allowed
+ return person;
+ }
+ }
+ return person;
+ }
+
+// @Override
+// public void createOrUpdateVote(VoteDTO vote, PollDTO poll) {
+// TopiaContext transaction = null;
+// try {
+// PollType pollType = poll.getPollType();
+//
+// //PollAccountDTO account = vote.getAccount();
+//
+// if (log.isInfoEnabled()) {
+// log.info("P:[ getNewVote ] : " +
+// "accountName = " + account.getVotingId() +
+// " _ accountUId = " + account.getAccountUId() +
+// " _ pollUId = " + poll.getPollUId() +
+// " _ pollType = " + pollType);
+// }
+//
+// transaction = context.getRootContext().beginTransaction();
+//
+// VoteDAO dao = PollenModelDAOHelper.getVoteDAO(transaction);
+//
+// Vote eVote = dao.findByTopiaId(vote.getId());
+//
+// if (eVote != null) {
+//
+// updateChoiceValues(transaction, vote, eVote);
+//
+// // Don't touch to pollAccount for existing vote
+// } else {
+//
+// Poll ePoll = PollenModelDAOHelper.getPollDAO(transaction).
+// findByTopiaId(poll.getId());
+//
+// // Retrieve existing account
+// PollAccountDAO accountDAO =
+// PollenModelDAOHelper.getPollAccountDAO(transaction);
+// PollAccount eAccount =
+// accountDAO.findByTopiaId(account.getId());
+//
+// PersonToList person = null;
+// if (pollType.isRestrictedOrGroup()) {
+// person = validateForRestrictedPoll(transaction, vote,
+// eAccount, ePoll);
+// } else {
+// if (eAccount == null) {
+// // Create new Account
+// eAccount =
+// accountDAO.create(context.createPollenUrlId());
+// context.getConverter().convert(account, eAccount);
+// }
+//
+// VotingListDAO listDAO =
+// PollenModelDAOHelper.getVotingListDAO(transaction);
+//
+// VotingList list = null;
+// if (ePoll.sizeVotingList() == 0) {
+// list = listDAO.create();
+// } else {
+// list = ePoll.getVotingList().get(0);
+//
+// }
+// }
+//
+// // Link with existing connected user
+// if (account.getUserId() != null) {
+// UserAccount user =
+// PollenModelDAOHelper.getUserAccountDAO(transaction).
+// findByTopiaId(account.getUserId());
+//
+// user.addPollAccount(eAccount);
+// }
+//
+// eVote = context.getConverter().convert(vote, dao.create());
+// if (!eVote.getAnonymous()) {
+// eVote.setPollAccount(eAccount);
+// }
+//
+// ePoll.addVote(eVote);
+//
+//
+// }
+//
+//
+//
+// } catch (Exception eee) {
+// context.doCatch(transaction, eee,
+// n_("pollen.error.serviceVote.getVote"),
+// poll.getTitle(), poll.getId());
+// } finally {
+// context.doFinally(transaction);
+// }
+// }
}
\ No newline at end of file
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-23 11:15:12 UTC (rev 2955)
@@ -7,6 +7,7 @@
pollen.error.serviceList.createAccountForPersonList=
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.servicePoll.addComment=
+pollen.error.servicePoll.createChoice=
pollen.error.servicePoll.createPoll=
pollen.error.servicePoll.delete=
pollen.error.servicePoll.deleteChoice=
@@ -19,6 +20,7 @@
pollen.error.servicePoll.updatePoll=
pollen.error.serviceResults.importPoll=
pollen.error.serviceUser.createDefaultAdmin=
+pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
pollen.exception.load_configuration=
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-23 11:15:12 UTC (rev 2955)
@@ -7,6 +7,7 @@
pollen.error.serviceList.createAccountForPersonList=
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire cr\u00E9\u00E9 par %1$s pour le sondage %2$s (%3$s)
+pollen.error.servicePoll.createChoice=
pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s cr\u00E9\u00E9 par %2$s
pollen.error.servicePoll.deleteChoice=
pollen.error.servicePoll.deleteComment=Impossible de supprimer le commentaire ayant pour identifiant "%1$s", appartenenant au sondage %2$s (%3$s)
@@ -18,6 +19,7 @@
pollen.error.servicePoll.updatePoll=Impossible de mettre \u00E0 jour le sondage %1$s (%2$s)
pollen.error.serviceResults.importPoll=
pollen.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut \: %1$s (%2$s)
+pollen.error.serviceVote.getVote=
pollen.error.serviceVote.getVotesByPoll=
pollen.error.serviceVote.hasAlreadyVoted=
pollen.exception.load_configuration=La configuration n'a pas \u00E9t\u00E9 charg\u00E9e correctement \! Veuillez v\u00E9rifier le d\u00E9marrage de l'application.
Modified: trunk/pollen-business/src/main/xmi/pollen.zargo
===================================================================
--- trunk/pollen-business/src/main/xmi/pollen.zargo 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/main/xmi/pollen.zargo 2010-03-23 11:15:12 UTC (rev 2955)
@@ -1,90 +1,94 @@
-PKO�X<pollen.argo}Tˎ�0��W >�LFU�a�tѪUG�v9pW�1�4�����v2$�����uMe/��B1n��e�Tu'Z�a�T[�!�FB��CSW����)�����C�晼|!���ڞ�@���(<Q�0�M�V�5��
+PKΕv<pollen.argo}Tˎ�0��W >�LFU�a�tѪUG�v9pW�1�4�����v2$�����uMe/��B1n��e�Tu'Z�a�T[�!�FB��CSW����)�����C�晼|!���ڞ�@���(<Q�0�M�V�5��
�F�9F����??��@
�|�sը�D����A/4
-z��z�`�H�-.�-M�{G�S3*<"C}II�(�i��7��rQ#e3eRy�G�$�Rcޑ�R}���y�A��h�+����aT&U`����z�N��j��8���C�qw���;8b�Z7j�J!D{���y�^v`o;(��Z��+����s����vaF87�1ۜ[f3��C�Kʛ���*����eIJ(�Z���&��b�pږ�o����>쿽�E�h8����[�K`[ڹ��Av��PK-��\��筟�� �}���s�A��^z�2�u�RȞ��pF�X������|��b��wc�N���]�>�5������u/tB�L��O�������̎ۖ�<�PKptB�PKO�X<pollen_DC_Pollen.pgml�]k��6���_�۸�O��!J����_��d�d��b�P�j�ﺭ�3����/%�z�E��i���E�m[r7�J����w��e>�-W�x��]9�h1�'������>\���^����~��F�S~�o�����ϣ�䇫�zr��H?�D��r��N�-^N���4����&�p�_�V�p=�{�^n���2��̮~����y�Z�o���KF//}��������DŽ�o����OO��K�q��N�u밋�F�k�D�/����1�ϣ��w���w�e�y�}�a6u�W���oI��"�7#��r|�/���5\?��f����S8_E?���2���^�ϳ��{��5Z�ɯ]�/��������f������e����P��ni�MO����}��q<���/�>��Q�v���x����ŏ�p������w��ٗp�~������e4^���<*L�U6%���!������v����d��/p��;��l��N�ɾA�j`�q9�7�a�F���"�U���!m���VK�R6!�_�o67��WL;4�j��w���_2�� ���f �h
-�1���ߓ�30dՈ3���YG���@�8<a.0��=j��8F���?y�����yO�wg�p>��Hc[��c<�Ho&߽��o*�����j={��í��E�����2_����ߝ���e�����>��}`I�q������`B3��g_`:�����qP�0�@�:y6ތ��f�.�*E8rX��{�p��_^������]�s��sص*�9�{�
-s�.�q���n!<�a.�5�q~[�x�p��ܦ`��<��l��Qc�
-���5�^�/�:��A��~�|���CѸ���
-]����\�&#���QFv.����h-�(�c�˹gu9��K���˕�)�@��3]���9�
-���S����2ܒ�'����x�YL�<������A0����%^s���Mk�d���vq�����p6�.?���L�l0�b�~�Zy��
-�0�y�A܄&F�C�{ 7��X�}�*M ��k�؊��ɚ���c�2�� &dT+��51hb��ʦ��41B�qx�80�Ak��!A+�|&������h���!ӚX�<o��*̵�@G�&&�9��^�#B4hs������A��ݧ�hkbȴ&�2��3�W��E1�Z�@�
-���N�9UL�t�|4u��=��T1�"�(�C��2
-�U���F�ALD�C��9�u�k�Z}����1m`�ڻE�i�\��h���V��9�qC�=�{6E�ՠ
-)�ЖV��G;���3��&|�mϣpQ��W�9�,�,|�Z�b� �
-,ܯA��dHh�`��@BBÀ�^B#����u�7#��R`���0{��[����|G�`K�m �j�ޖ8�e[:y:Kgd4��X�:���lF�DC�L��d����g�aȹ������h����\�H<1����2��ު6��Hc�O�>�9�U��-=K91�q�4��#-
-ړSq�r�i�C���r��[�3�lcK&w�p�������&9:��ױ�����h�p�[*�X�^����$���_9gЭ0�R�BD�E�����iNy�����vAJ�C��To�o
-Ⱥx�PJ�����s<G���1O�S�8�FP�Œ�"�k�k �P�PG�I��j��t3���=D�%�cD~y�h��XG�hYxP 8�C
-4|<�W�D3���V��]`E:�{vj�7���|m�(:�C)gp]a���K�Y}����W�,�Fx��2�M�^_2�:L=��u�ȿ��h���a^��dP>��iu�1���ņ��W/9Y����Lq笼��U�8="�W졦�?>�MR��T_TA��NC�2�"�(����6�Q���#��a���\�wm�.�̙�rj�b.�\�W����fDi�����ڊ�{diR���m)�X�3�((���+戱�9рV�ݣ?��"U��@4��g�+�T1���0����@7T̥�WT̑RŜH�%�:�t�b�s�a�٪r�?1[7�F8��]�#ت�V�����!ҋp�Eq�E<�kUs�YfCQ�c����9b�jnK(|o�n�.Bў��Es���><����ő�ֱ�9��%����ʷT���fN��^�C%W�^ho�%RŜ��s����-7��>�_ӱ'�n���H�!%=���==&w3CzK6�!'e��^=�P�m�C+�&i{�"�|_-����jV�)�I�T,ӷ[���z�!�W<�Ck��`�e�A�i���
-=�I;�@�u=�c�\ŋ:=��@��1k��1�G����V��p��ch_��d6T�b��m=��@�a�.�~�[�ÀM��[O���èr7������1��Ck7�zL�J@+T��Vv��yth�W�x<KA�n?6��f�t�b�_o���c�\�?T<
-��q]��=����~�'Q�L����d��p����7�$��i��_���ye{i����ȿ�#z��8��߬���/��M<]���.�����Vz������c�_������Ba
-�@\+P�y3_�^y �K�W<A��Mp�ײ�B�zXLn�x]�`�j|
-�^�VLA����>�`㸻��~&ӯ�D�9�(�au$,$�ң�3��?��n������<3E��+3����;^^0�⪠��|EP��r�o���ݞU���Y{�;�_^�џ8�1��������.�V%���ʲ�Z���S���V�)[���@�`'˒�T���l˓@hcYZ�S����V�3怘��Rhb�%�:�cH5N1��e1�`�"W!]�mw�Ue��.�oF.ƻ�F+�n=���E3��e)"���Uq���lֵ���n2T�1`�(ݢ��a��W&{���y��4�ue��K�+�i�Y=�cI��%����ʷT�|зR�����\4�,���
-ܡ���ƭк���[Z�������ɶ��E�6�ɄM����A�D{���ߌf3�2���{L�2�:�ɪr��xW�L�;b���u,�y��J��e2��e2���P��<���<��0������l�}E�=U��v�� �p���� L�t��c?����Z�˜����̥rw��B���Q�;RE�Jw?�aZ��[K�Z���Ɖ�o-�;Kĭ��D÷��e���Q���!
-p������5�1ը�[���d�>Oj��4��yG�����;�]� ���UU��d�p���E���҉���fX�I�F�{1���i���<-(��%�`�k�r�#��B�F{���X��d@�J�J���@*Q+��h5��3�R��4��Z�}|d�ZP*SC��Y�:�t�Pm۪�S\ 0[���r���(��EQ��2�@*X��%@�Y��y{�4A�J��� L����Z���ѮZ�V��hE���t8�nM�P5�����:V��t�d:�:\����@*^�#�#�L��a����lBMj�F@��a�Ú��0=�Mq�[mMUP��2��n���p`c�X7��t)��$*������*~�ݵ��*}9���\���*�_��6RgW����Λ��ҳA����o��)�$>����ԣ�8!S����k�H�PI%����θ�#;��
-��"!B�TBфjۙ6�˄ ��/�h
-�1�!��@�8�0�����0��B&��uB!��� 3R0�L��Z�J!� ���3�qU
-�B\[�E�jM���Ω���fQ�a:�E!�Tܢ-rL�j�[�s��ǹ��8Q%�<Z���:�*=�QnpUz����5��L2��V�5�L�=�)Фh3��{�k�Z�#�BM��2��p�r
-u�Y?���z�r�J� �E!6��z�Љ�8�w�h�vA����f�����*ak�AӰ��ٕ^'���a�u#đmK� ��' o|
-��
-�����{P�غ�E�o�l|�+��=g2��I0��a۳���7])vE�b.�\/�Ge9Ϥ����\UzD�u[��G_�2����,UppdŅ�+8X��"1���ض��۞�$r�S��*d
-��;����E��f�!�y@�����PH'8ʡ���Ώ�����ͼ��/�l�3 r�� gnW�� �Z���O!�q���Y3��sOE�v2��K�8��t�~Ɠ�x&�Ɛ���ئ�?��I�N��T�
-�[p�M�8z�o�t4���-��N"�;%{Nq�j�z�jv5�V̈́'��"���U����_���s���m-��ՈS`��
-?)�KC�&n�n�xm�^�E;�g_M�a�Y56��N��>��"�4{i��W�v�g�},�x������
-R.�0���X@�O�ѭ����E�D,خ`N3Y����$x٘/������i�!�0[�tZ�������\�%KfFXh3z9���E����&�v)�JRz��X�j:�SJ����]O��z8o��R:-I�B�7q��Hץ�d�����@<D�j�i�#��"u,�p��zT�����ыpT����z�k::��2���G<x�C�}���ѷ�����D
-]�5���k�Е��4�5G�k+5t� v (�}lv�s���|��n�F@K���]�A�v�9.�g�[��~l����n��vvRY���^�I����5������M�>Y3������q�8�X���n��m�3�-��f�]M�n��k�P�JB-������L�̒�g�tÌ U���}2ᶋUL��p).��˦`�X�$��R$�Hxc��� V��W�U�$V �$��aˡ�bU�H�̊Tit#�E�����[k�g& Ubt#�x���Y>Yׄ*�8Q>����e��#�}����������U��鲿�b��o�6��Yܰ��UJC�.�JC�M�Sq�=`�]UZ�Q�jR
-5��`���m5�k�T�)��j���(�x��%ެl9��/��&��E�<��;��.����5'Y�e��J�k���#�{x�6�i�t�Q��z�x�6�9���i�7�eų��M+_����*���mZ7�z����[L�Y�#~��^��6|�/��&b�5� M�Hh�4`����9=�o������&���\2�á��j�&��}88��}����I.�t��%}ͺ9���t�
-}k9����g�پ�L��0��q��[���1���8c�i��R��M��K� �X�����?4�s����\��
-�9'�'�)
-�d-�ma℞b-�7�l��9U"���e��y}�):w�J��ѹ�kt�!��2�y:t�Ι�_~����1>�shG���y>t����tS��v6w���$^J����S�Q\O�"���b������qތ�c�I��Zj��̼os������r��XA��
-���U�
-rK[��l�G�`=�϶��,�m�N��oBk|������Ch�� aоh�ư����IG9����8��}�F+�c�v>pͶ�H�������-���2�К����n�
-Rm�a���Tvi��P��@�_�E{���l������<e�;�ԠCt6h��l�����c{�Φ��t6�=)����=>�y��u� �zE�)Фhh��(|���}/]�i5�Ю�����o��[�p��[�6�~$q=l�4���7|U�����@�Տ���]&�mEg�Mߞ�����{��a`�����9�
-9��Nߞ�ؐc>d���7]l���ur��ņ�!9�����4F�'���*�T܇�DŽ�]��;�}����������&t2�)d
-��)�x�ƊÕt)w7�s�{t�^��s��tN�'����<�3��q:�;I��!
- ���s��t�$�����ιL:�4�q��,5W?�z�vN�y�>��9�VD���^� =�7��l��5����l�뀎�&�P�@�ox{��&���� ��M�j�p�,^�r=>w�i�f��m>���at�!��=fs��l�l�����J�H t�j�\���9�s2W�7O��@��o���?'�s�bg��C�_�r=2wбzf��]>�m&g+ٜ:9ېι=�swkf�t��7�������9w�s
-�7N��~ӹ��|�y:�t�������*��TqJ��]�?J���5<Զ�s'��Aj<�w�������K��+�h�#
-�X���!�*�N��X'��>�g��Y繟I�/ �:@d�Y'�6��HͲ��?�����v�u��r�v���.mZkw�mJB�"�(d�5L<2yď!l
-����y��0���=��P>wȬJ���9{�e;����y���l����=�L�o\ȳ�\�V^zJ��'r���ֺ���o���6��`HI���k�k�2����PK�ʜ5RŋPKO�X<pollen.todo�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��q�(��;�D�*���+G���*(�8z)%)J
-@% ���,.2���E���9e�)�E�%��� Y,B3PK4�[-m�PKO�X<pollen_profile.profile�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��qq��e��q��ÙPK7Rp:BPKO�X<
-pollen.xmi�]k��8��>��5�U=S����ҕɖ��[S5I�&��~ κ��'��p�6F`��"1�;����+��{ӫw�����=�(��`���N\w38���샿�l�����z���Ͼ?�����]��.����G�Im��v���'��w��O����}v߿�;�@{&)3Q{P�Y���_f�
-w��Ͳ�[|���������n��`��$��u�~߇Q���a��C���G���,C���Oo9�o�����/�F=������B2�/گ�>�q��3�a�>��}.�sQ� �C�������/�A����G~ۯ��ʿZ�@��ǯ/�cz��C�f���9}۟�;淟Ņ�����^DXH� �$}��#ӦN��ݬg�2��\T�sQ�溤ێ��Q�����!p~=
-��2\٣>��������=t|�w�ʾ��.��7�aR����^��K;N"���{�ӫ�w0��"�-t���7������{�f��-٦��$��@���,A�;=}V����n��pA�@Ņ���릇$?��^o���~�������x�Y�ݗ�T��T�?��}�N����J¿��~ѯ���_�=�SQJge��8��$خ�bO�M�� D��((���Y�՜oa��|L/�^`/�٤��9���1^"WF{�8o-�Ӎ��c�8O�"��`� ���6e�u5��]�ٯ�Y}���SN�m�'?�O�{�;8����Ē}�$�3DK�$�� K{+�au����|��<a^��ܴU5S�x��qd�dU(O��q_�S�h�A��:��$�|���'�\��(f>
-4�t��a��ew��x�_����i�� ��3� ��I�����>��`�>&�&��T%r����2��Qv���.��)���fŠ9����4���?������������\�:��v�ߩޔ=�nv��?WF� �=�KU�F��=Yg��?58gM�r9W��j�I�jQ�M�^$��
--���!�����{�?6��N����iK�+�i��4p���h@L��]״��d�A6C�\�h��&x;?5M&� ��t98��Cqqx<@ǯ��gw�f1n�
-{�-��_Qx�Sc7�#$�����s��ֺN(�`����?N��-�g���C�{��o^n��A�+~o��6[�OS��V�ȅы�>�3tQ���nOO a)m\�kY�,���l�][b>P<MS%eQ����������Q�Y̮Du�DI�`.ݓ�F
--n$b��4��8�P-b����Uu|���U�5%U�4O�dU��J���F��1���B�LA���
-��{���X֟,4�C��@7���/�t��2r�).n����0��Ck�����a��
-�0D:�%��i�'�[��]z��^�K��fD�%�#�8�H��P������gtWv3����Dӓ\�TP�]b�Ar��E���?5�"w W ��b�b��b���������S�\�*��:�+���Ʃwx���TK�sѹɋ#S�}^:�y�th����(3yѡ��%�z�1�]M1udT1y
-"y��AP�҉�����%�s
-�����i�~r���"���1�\�A��Nr�HtZ}�QɅ�.n���l����+7�}��rgk��WVq51�����0�{�j��7#�.nF2�R\\I�!%�t� f��u�53(���\;+7b5�vV�/�$i�F3��-'<|c�UF�V��H��r�1֡�����8����9$��GH1�#�7Wl�ÔJ���:Ŧj┉�D��8� [�C�#���@X3@F�v+H>7] ��[I1��.9P�}�!��YcI~͵^a�Cr�����eÔ$��K����)D��f��R�o��qcl�2_;���v�3#e�)�����]�ud�bV�?���7HTnjl�D,.�oa�!v��_�'Q�^w�[U��1�N���0�łT�8D�p(5`m��Xil��O�M��D:�60L�|X��
-ٍ�E�m�QRܲd��"��t;e#a��)<��%b����=H�H*5��ZH}!V��A��b�t6��I�RjH����]��'Z�<)ψ����_.�IF2�����T4������D�H9 3����wv���K��(N>N:�H������ɥS'���,�l8�˔��sU�����69�u`�@�=:y��'?�3�LF���|�,zE�] N�z�[��5AZ6\]vm���Y��@�=�-�pD�����Pjp��@�р���w��s���$��9���G�Ğ|�d&��'�Ӟ�ac���x��B����k��T(w���ʗ J�����7:2>?�_��G�,9*5�IЀ)]�G�l��$T1tIґ�p
-��+
-{�8��.>��»,�*���i���Y5<ͳ%[�2j�(l�dGQ���a?�N�0�:��"�|�A�kz@���[�j�j\��g$v|;�ޣ�a��@����'��a
-j�9K�%O⌯��fuȪ'� y�R�֎d��(�&�u�,�W�*�e-�JP\�����m�^9(��q�%"�mH��Kܧx�7&�u���pA���TjpC>&�Cs�@n�q2�ꐉI�yrR���i����O9��T����1�r�#炷� ��B��N�[��
-� e�'Im?=��[ȍ|��y�vk�<Uj�����W�����G{�5�D��f4Ɲ�i��0%:R���y��Ԁ���kh���� I��� `�����ɥS'���K.����g���Xi��d�=L�7D��F�x��f�H���h:����]�p��o��@���xt
-APN��G�7���>*.No��5�����X;g">���T�CV�&��+d�p6P�d���\@"�!e�b�ŲK
-n�J����p�6��GK�=]. ��Ew�|�����;;�ȇ�X�م���I$:V���y}�R�J<#���lL pr`��]62��f|�D�)��=@�JPjpC\p�[������ǎ�zPj�37���_�&p�@,�!3�A�,�R�����H��2�M�K��V���$�0 �q˺�� �ͬJ�kB�E�
-��F�u�7�g��^ꄩ�P�C�!DN�7D%W��
-��p�tWS4�Y�CN��J<�J)!܌�@$��# �y(����� ��)�PQI1+�ƨغg�747V������Û��;d�+"���U��M�`�m$^E�X�#�@{��J
-nhC�phL;ζ&�1媸D22� �7.5�:4&�8`Ku�dc"�<ӸԀ5����eV������(�?����BQ��QG��ď�$��Iy��B� ����^�sِ�R�^@( ���*vg���)�;�XкX}>��.��.7%��r�
-AS���nt9&�;A��ʂA,�1����]���-��t�/i��"�3U��Z��^�8�v�T����#��Pjp�qH�0][���噞c��ާ��C�-��K$'��=���taD.�8t�����X�w}����m<KB��b)Vɪ݈����s�A��u��z�:p;�Kc�gΑ$F�G��o3�̭����\��6��������6���3�0h��Fr���e9���3����H�9̞D��DI�`�������?jM$��b8�h,9��0�H���f ���cT��G�n��pF%s�%1���rO��R����GR
-�v*h�MJ��jѫ#wru��5
-��.� ��a�'l�nq+���oz�k����ڐu�HA�ȵ�����&�m#Ѥ��r�W�ў2�QҰ�b�C�Z�lWIl�*�<�)h�δ���7A�@��þ7"� Ϗ>�Q����s���W�d�0ȴYy�J��X�-�V��贼�ēs�����"p+�ċ�ܚnG��[��a��F��ȕ����Ӯʂ�Mi�|���7��@f^p��k����O��HMz��Z�o`o\���r�0��ѫ#�����mv�<K��;.5p��`:I�Rѩǃ�T�4U�qCX/��{��f�Qղ�$��W�·�7�&��sFV��6*z�z����k��m_��h��HMz&9��pgk�xD�;���[�Y`�R\܌C�q���L����S[~���Gd�����^TO瘢B/�5UOV���zH�%؎j�b6Q�l�H7��M�!M8"���f�UȰ�y����U%[Ul�ɨd+d؊&:L��Q����7{'K��^���o�<G��������ˍ�"�RS]C�L�̙F6�T���B�悗�_���%C$�aO��G�����[ר�X�xe�@�%�I$k�¯���b<�,cTLCZ�4�.��d���+�W�ڿye/Cvq]�k��h>X��-7��z�$4�<J��b��HG����Q\<B9AU����T]��������r@��}ǻ>��{sV�m��1m;�U(p)��ӻ��vM��x��
-bx<�!�������O0�_�ͣ.��������]N(U�E��<7�'54ہ*R��j�F��Fq�����z W��m����,��2kͼ����1!�dm�c�8��[�߶�ĝ����۟�b�����g0�l�F}}�ym��]ڵ�T�l#���u�b�i��x�A�G��Bv�)b}�V"���|N2E{Zi<b�
-�d��X��� �[����H;���Ί�yj��\�i"=$�nB����~�oD�26��`]o���e�P�|�B �ۼ�>K�����Vzq1������f-�N��Cv�ӑ����';��nZ��G��,�3לf�P=��<����:�ܥ���F�����g�� e'�.��ft�m��l��0tV����yu�R*�>�|h=���gQ!>�5?XC��V���o���ʁ�b��ڱJi��-�\;V+�
-�}
-�˪f�`@|T�>kͨ�ζ5�(��ޅѝ,8�*�'3�v�u*�g�:{�X;j���o#� �
-�z�g>
-�U����G�vY1 >*��
-�Vۆ
-�y���pY���G��;�_��9����x��,�Q��%R1�Df��(S!?����i0�,�Q��iP^,�Q��% T�oê�h�Z�>SK�/1
-�؉i�ȩX<��.�ʏ�lK���R*?�
-�YA�~�/
-
-!#K�N��ϤB|����B��@��6����0=V�.
-
-nSK��6�S|*K��h��ҨМ5V�.ܧ��v1h��[��rˠb��n�0�p��V������ɪ�kR1yMF�]�%�w���]Ґfj-�+���T�N�Q�rY^�ҥT|T�\��f�Y�T���)��s�#V�#�VNJ
-o��Uo����w��ˢ"Tn]��C���P\,��ˀ��T�o�m�$�{�.i��ȌG��Ӽ"�4�ˀQ�*J�A�U���*p1PbS����×���7<n��>�9\�hs��)(����BnU��E�E�jv �.�^���b�$�v��(I����Kr7.6��SS����F�#ă����PL�j�m\��qa�����]m�z�Q�L�l.*˄F�2�]�����((q`W���AA��x�8(����_�.��;��)�*�Weu����࣠Dk�?���d�x�����m=�AAU<����pPP�G���L#��~��ˮk�@sRȞl��胼�.�\��y�%�ܥ�L��#��$��X�����
-�b��F��#g%�@�'A���S���ԥ�F��cW�$�<�̔؛����H~�=-�S_�ﳧet�#���=o$���z����eI0w��������L�2���G�~ ������Qϧ�@��Fe��ld2�F.�|��������:3̚�i���DA����0�Q�g;�t虊
-�Q�<ՓU�Fm��NO�$0ry"��LO�85�c���E"�ۛ������� ��?�}���PK��t���PKO�X<ptB�pollen.argoPKO�X<�ʜ5RŋGpollen_DC_Pollen.pgmlPKO�X<4�[-m��pollen.todoPKO�X<7Rp:B�pollen_profile.profilePKO�X<��t���
-pollen.xmiPK1�4
\ No newline at end of file
+z��z�`�H�-.�-M�{G�S3*<"C}II�(�i��7��rQ#e3eRy�G�$�Rcޑ�R}���y�A��h�+����aT&U`����z�N��j��8���C�qw���;8b�Z7j�J!D{���y�^v`o;(��Z��+����s����vaF87�1ۜ[f3��C�Kʛ���*����eIJ(�Z���&��b�pږ�o����>쿽�E�h8����[�K`[ڹ��Av��PK-��\��筟�� �}���s�A��^z�2�u�RȞ��pF�X������|��b��wc�N���]�>�5������u/tB�L��O�������̎ۖ�<�PKptB�PKΕv<pollen_DC_Pollen.pgml�]k��6���_�-,�SWE|��:�5�W$�F�i`0T����U�;������D^R�Mˌ,�Lْ�xxyux������t�%�/&�����.�l��&�����?}�/���������?>>^������ۧ���W���_�0J���u�[:_��q��e��&�x�\-��r2��b9_
+��yr��\���Ow�x��__���^^��%�//��/< ��"�<� ���·���yo����c�
+��,~I�_����c:�&�������t�����d�m���O�ߒ���D�go�7��_���k�|�<YL����x�H~X,�y�.��&�'�����k2��_��^ȿ=�!^.���2����{������}q����oz�L�|�+?�i:��y�Lv�a��Iʗ���\�8����>��?~�:�|�����+?�ߛ'�e<O�҄\�����8�������n�:-��^�}�9�����=�oF��v\^�
+qX������FtU bhHk��mg��e_)�P��7ۛry�5�M����%��`c*#@�H� �d%s���A��Y5�]��,�?��q q�0��4�d�A��ß<�3�Wp�<M�Ż�e<��_侭x�1���7��^L�7���j��<M��z��%3�(�_�e��!���;Y~�˘���y�}�][ǒ���"��_8�P�L��l�5�� ������g��p��f�
+���#�y���nw��k<_��߾qs>
+7n�N�9Oz�Xn�Թ9�����-����e��:��ok`#n۔�㿳�b��M:?hLF��zwͻ��K�L�i�����3�̶�F������\����~K�fG�%G�,9�\��e�y�-9��K��ɒ˦�钫�S^rE�W�� ���!S4ϺA8@�~J�������������7�xf�2��&5p�wԣ���%]r���Mk��d��6F�v�O� ��7����-��n灪o(T��D�QL�
+M��7�8�@~�="�&V�
+�41$hb���c+Z�O$k����UhbȢ&&��UM�L:�������'��dnhb�����J�&�\C�&Vu&�L��I�5����@C�5������䔛kk��MLps#37G$���uO+O�0�
+zH
+�1�ĐmM,g��e�\ל,�����T ��w�m.�Ωb�E��G�EW�G��!@�,B��A��4�WMff
+1��k�,D�}�_���k:7T����h����^��4�/��p4����pdܴ�;�{7E�ՠ
+)����ЎG/�ل����C~���$��b�`N �=���g�U<n`�a
+�T��>�����$��<�4���,���������Pܩx��38�%[��hK�P����Q������Z8C0 �ь�͢��,E3Jf d
+n3�̠e>�C�e`d����2r�5�\�e�$C�#�z(#K���0��F��BJ����rnm�X�a�cd��ʉ�m˩�k1��4ӡPS+1u�-�l7��&��Yp���������8��\p�_�\6
+\�m�K�����d���+���X�^�H�HV�@�9G�9�*_X
+\H@c@�E���#]��x�z�) ��އ�x?&����9��{��g��E���>TTF� ցk ��P�P'�Q�C=�P��@u�g��K��ډ�����q�L�ɼ�H8�}4|8M��0���V��.0#��ֽ;7���f:M�6�]�ء�s��g�dzt��%]->��d��;Kğ�-�
+}���K�S'���x������,V�e#��[M%D7�|��d��F���-'� [97�p"��3� g�o�r�����]V$5���E��w�g�Ze�ӷ��!�o>i��#?�l�5=W�]�2�+)s6���˘+8��sa�P�����_(r6c��<p*c�T2�8�e[*"�rv��]��jKGϘ#�2�D��1w��4��Dʘ+��h5��'̘#R�\F�0��?��Ϙ��d̑JƜ�H�-�ڑt=c�s�a��B[�O�����'t��v�õ��C��9��q��<\yS�v�Z�\e��P$�De����8k��͚[�0�,7��ho��Is��><�r����[�r�T�-���˭z�6g�H9s�5���ϙ�_�3�"]"e�I9O�
+����s�d��c���t�Wn#=�T�{������gI�aY�r�I��cJY�N�1T��0I�+%�u�jKG�c�]=�d@6�S9M�m=���1P�8_�z��cP�hؿ��cr�5z��1L�`I�����|����z=������������ �Z=���ÝR����d��� �3G���1�z˪�{���1(btp�����5�����ki��k�Q'P�1�*ը����S
+���%/�p�����P�{���C6���t5&������Q|���G%ﹾ���K:J�gZdw�?�M�vn�z��M>I/|���W�������T�G��?���ȇ�d>N���7�}'��>qϷ��K�Β����^�J��&���1�xzZ$��J��u� �����.'�ܑ�ߑ���� ��&��k9�{�i=�F7�Y��z�S��>@/g'��E��P�s�u�}Gq?�������P��aw$l$�ʣ�3��?��n������tg�����l���7��df�]A��Ŏ@��
+�o���]�U���Y{�{�_^�1y�1���D��Ї���p�N���ʲ�[��S,����W�أǁ��N��ф���lǃ@hcY٤S���P�� c@L�b)4��\��ч�����IJ�B���+���G��U}���������x�ר����Z[Z4:XV<��K�C��� �f]��P�_o&Cu���-Ɓf�}eV�lVZp�+Mn]Y}�R �
+���+�cA�J�&��J�ޢ��0�o�`}
+��)�hZY����}+�
+[)2�ue��[Z�c$���Ѻ��E�6�Ʉ"���b/}��hf�س�l�$�w�c;��ձL��e��]�v��v!j%�c���'Vz-�t/����Zح�1�n�1�π�(fн(fC��5��X1̠�1L�3�H��0����y�~�/+-��ˍ��ߏ��K;��p��ɝ�&wDG�*w�?�=�~�,�k���g,X'����$�~l��Y�ז�?h,p�%��h_C��*�;���Ac�Q?�����82����i7�!�]'w��AZyw ��N�`�r#vW$�4`w9�)�?�dͰ��5��k1���i%�s*=-���e��`Rh�� �Ԅ�HZJP��%�Id/E��p�NQ��������Ij�����A�qͣ���7��U��DW�,C�J����nU�)�kV�MW[{9J���!/�VM$%�I^� �y�r���i����U�A�U*
+R����c����Z�Њ(�,8����dZY�����)\�2ה.����z�6y-���d��<�lx�iU�Ά Ԥj�
+vg�S��g�)N}�ͩ�*9UV6��eU�ll���ɟ.W�D���#�������؉ND��a��kg���
+���gɲ���ٕ����{3X~6H�-73E�$$C��z���1d�X�~� ���Ғ?��w��.:�U�=�H��5�P4��v��M��2a�@�K� �dnȄ�8�0$�:`�(��� s�52!ǿ�
+�$�O���I�eB�_���:���hU"�]\���������$��B�ŝR#���)͢2
+�t($��+��b,rL�j������UBi�yPa`���]qS �+�S�*W�g\���k�A&�em�5�L���h���@1�3�5],M�ϡ�z���c�k�9��j������ˡ/+�6�����#t�mB'
+�ޭWӮ�
+�P�`w�mW�6+ag� iػ��J����r�]-�8�mi�3���p�]-��ط��$خA�s�j1D��_�*�z�+����$X.yE���'���7C��V�e����<�l!晥��A�ʏ�b��E|���u+�I��JGV�8`9���]�����`@��"��z����N!��d�)8�$r�S(����}�s�x'��;��$�Np�]I�������/�n�3sr�'g�*�k-�B䈧��r_C��;iēt.�H�ΦC��>Vn1�x��l�1�o�[d�(�ϵޤx�����
+���E�8�b�e��p�Uo��;���8űo5���C�i5x9�)"M����5�Ɍ��'S9�?r�6N���S=��@���'G|�=b�,B����p�k}y��x��|Q4Q��fz�!m���}��Y�i���@�vX6��1��%Y>��=(H5��bEa��~��2�`��9�Ax�l#��GF��1fC�z"aҧ�l���\��iEN/5��f��s1�,;3�B�����Ԛ�. �6ٮK�T��+�ǪFPә�R:��t��8���� ����J�"�n�(�R���K�Y�����@<D�j鹇#�l<��p��zT��E��1�pT����z�k::��r7
+]�p�C�s�����k�;�&j��Z��k�c�r�y�ך�Zk+5t� v���������*�u�z��V4��5��)��vs��^g�[��(���n��6v����]��$H�DY�_�� _N¦y����i�>iv\.�
+���u���cƸ%�눽O��2���M�{��XE����q���;w�v�aք*рj�>��p��*&�UT8��S�eSpD�b�XE)���Q@��r�ub��U�+��vز+9�J+R1�"U��H@6ޭ>�E����IB���Hl�!�v҄O�5��*N�ϦC�y��T{�b.T1�B�z��h��t-n���D�JZo�6���6�a]���
+)�`+�2n������ev�gi�FM�s��jDk�>I+�z�nCh�^ˤdO l�p�t�"l<Kg�^��bϖ���kC�hQ�-ܪ��`���MYs�XV��"��>ٮH}���F7��N�3�7�o>Z����&7��8�ֻ��v�i���k��_%p��M�_��~��:��ot���+0ܖ���`;�DL��<��M����>��A�
+����䰰�K8���\M"Ɉ�(�ˇ���mڇu�OM�p��CH_�,�k����i�^�kl:��`
+@�=��ez�h�U����Y��?���L;t��o���_NƦ�/t��Ѩ�/oN�
+n��y�=xqHif{n#/{���e�t�ӉxJ>���l�G��s{O��:���F��^/cاsQ��}��২ ��s�0�*R����|�:���RG��9��t�T'�R"=�������z�$!\oDK�.�W?`�{3ȏUC$�k�EG3�-�v��{�^9���d��.��P�[*}�����({t�=ێ�=dX�e�^��oBk|�ܨ{��!4��0�������=p�+M:�~D�{��H��~M���*8�v�sd�-��s����Vvh�s��9�r�T�i��8:��]�a:T=0�n1.{����ϑ/6�]l��?G��ԠC\lP���ʛ�,���<(���A���kr������?�7{]g8�%��@=�P��O�͑^�m/S��p������[��6�����ц�/��TϹ�$k�s����n6ޯ0��J�Q{U&�)?Yl��$��x��t�LޮGm�3�Nߞ"ِ#~����$r���9���
+9�g��=A�!ǼN��o98����i*�
+9��1!u��Ŏ�G�m:G�':�5<�
+C
+Y-uʱޱQS1��sHY1ܐ���ѹ}&Vz���N�9s�5O���9�y:g�tw�ΙC4 �O�p��M�m�9�:��t�i��J�;Xi����7윌�}2�ws�RD���� g��nNQl�?k�wcRl����&���|�@r����&����� q���&LU:\9��܌��uZ�]>w[�E>��k�����[�]�}6Gϛ��J�H t�j��\���9z�d�>n��ў�5��6��N2�cEeoB�_�r32�ױzv��]1�mg�lN�mH��3�sw{f�t�?o:w�����9��s
+�N���sw��p�t���\�m�9�O�Ug���7�f�6M�kx�m����)���xH�?E�]!���{f���]$��q�}�Uz���Nr?s�O���s?��_�M&�4���N�?c�N�e��6�M����/��b��\;�Cm�}�4���ڔ��%4
+Q�2kd�c���[W��������=�m_>�ϬJ���9w�e;��f�y}m�}6��al��k6�.�{.[+/=%��9w�bk�������?�
+��m0�$r��5D��5~�^��PK���NIŋPKΕv<pollen.todo�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��q�(��;�D�*���+G���*(�8z)%)J
+@% ���,.2���E���9e�)�E�%��� Y,B3PK4�[-m�PKΕv<pollen_profile.profile�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��qq��e��q��ÙPK7Rp:BPKΕv<
+pollen.xmi�]k��8��>��5�U=S����ҕɖm쭩��R�L�~ κ��'���q�F`��"1�;����+��{ӫw�����=�(��`���N\w38���샿�l�����z���Ͼ?�����]��>����G�I���n���G��w��O����Cv߇�@4���h<(ڃd�֛/3I���?�f��-�A����l��w7t��0H@���:��(I�]F�0���1�^�#Ll�x�����Oo9�o�����/�F=������B2�/گ�>�1tg�3�a�>��}.�sQ� �C�������/�A����G~ۯ��ʿZ�@�㧯/�cz��C�g���9}۟/;淟Ņ����ӓ�EXH� �$}��#ӦΏ�ݬg�2��\T�sQ�溤ێ��Q�����!py���Y|��Q���������:��;�Ke�{`��?�0)}���Ϗ��'p.�=���U6{�In����_�����o���
+�M3{uŖlS��Q
+�v�
+�[K� ߝ�>���7��pAN@Ņ���릇$?�^n���~�������x���ݗ�T��T�?��}�N����J¿�>���_?�?`w٧�����q=I�]#Ğj���A�x9QPV��Y�՜oa�|L/�^`/٤��9���1^"WF{�8o-���=�c�8O�"��`� ���6e�u5�7��]��/�Y���SN�m�'?�OG{�;8����[�%��I�'���Y�A��V��|9���|Cy¼��i�j:��� �����"
+�P�,5��K�2�� 9FuȗI��1AO��&CQ�|h��
+@G�6���q�����;��g'<����T�&
+�w�o �A����}��D;�T�S�ȹ7�����'�-���?�p�ǣ�����D�C��"�^��vD�?���
+p���ڇ�zS����p(�\�g��8/U�ٗ�d�Y3������5���\u��j��^$I� DU7Qz��k���^����K����j��.���?d���X״Ӏ�i���р��#��i��F�l���Ѡ�M,��~j�L^��rp�Ç$����X
+@����w�f1n�
+{�-��_Qx<Pc7�#$�����s��֦N(�`����?N��-����C�\z��o�n��E�+~oO�.[�OS��V�ȅѳ�>�3tQ�v���O a)m\�kY�,���l�][b>P<MS%eQ�7��������Q�Y̮Du�DI��^�'K�Z�H�z�4��8�P-b��ę���Uu|���U�5%U�4O�dU��J���F��1���B�LA���
+��{���X֟,4�C��@7���/�t��2r�).n����2��Ck�����a��
+�0D:�%��i�'�[����f�9��V�̈�K�3Gqv��=2����mV]�Q33��
+M3W��ơ0�����Y\��UZ_��(rr�0R���-CHt3�F��r��!iZ*:���b������Y���7:��R�4�;��-�L)�o�ܿUjСyk"쓦�̼E�e4C�����t5�ԑ�-Rż)��M;����@�J'�ƫ#S�:�ێA{�� a�'7��Y�'��k��_i�ް���UT�ݲ��x�r�B9G���+7�}�rgke��Vq&1�����0<{{*���R.i�1��Q\\5�!Ռt� }�\;��CfP�!ӹvVn�j��[��n�I2~�f��Z:Nx��'j����Ò"9��ʙwX�0����"���O8��T�C!��k���\,S*����"욪�S&�Z�lol��(.Na-'*H>?] �鐱AR���K��2A��DH6k�X�_s-�W�`���ki�ks�0%���d�!h����Eg��R�o��Y�� �ō��A���Ό���8��[t�1fŬ�v��o��>�� ҉X\���C�N�N�L��ȷ�R�5bڝb��a��Pp8���Pj�ڒѱ�ؼ�� 3�.�t�-_����R��_�e[�EGIq˒�kЊ:�휍�����O��;�# $w$��r�����Um�F<��r{��DҤ(z}��ɟ��'O�3�e�'�ŗ��G�рLf,f�!��a4��5<��('d�bqq`���DS}ɞ���Ig! u����#��`�$и�%�
+�|��~(��7���&�,�j�g/���~�IV���e�1��Rʉ�Rr+"�`�&�@�F��ˮ-��c��j���#�q]G�#2��� ���&5���Y��f#���ُZ'����>�$�䪒�TpƟ0N{��������v�7��s�:��)�̗�A\����e��'N����ȑ�#G�7I0E�K�h���ښ�*�.I:�N���E���G�C�%�g0Rx���O��8?A�UQ� ���y�d밦���q�Av��:K����YS��l��o;(5`M��z�]�R�Aʟ"�����ob��{�j�+*Pm�h�0EA3LAE��E���I���t�b�Y��$�|Rj���т0��R�$��\��8#�JV�����\ �����`�sL�+�e:n�D��C�
+IB�X�c)��/���$b��q�.H���J
+n��Dz�BcN�M4N�B21�#ON*5�T�>
+���0�_�)瞐Ju<��5FV�|�\�V3A7]�Iqж0���$���G�|���/��^��P��9��{���]Ύq�'ZcO$lFc���7?�
+S�#��o��J
+X[+�f�ƺɉ���L�F��� ��\j0uhܼ��؉�C6�9
+`���=L��TjpC4�:�O��,I0 �MG��V���뼃��`�-�h��t��!��X����� ��G��i�-����p3��b�@�7���u��ؤy��R�Jc�l��H�:d�lR��Xv��
+qA�t9��f��d)|���$R��.����^\���cg����c:�0�r^:�D�*�� ��YjpC�g$���� N�,]w��F>܌ϐH�#���S J
+n�^ᖀ$��32������̍���W�� �<'�x�b�<ˠ�����h�@:����o�v�U��8 0Leܲ�)2�w3���Pq��B��Qv����~��:a* �d@��A��
+�Aɕ���j64���Fb���f���R@J7c( w�H&@J(5�92�kh�@5TGTR�J�1*����
+͍U�`�!��f4"�Y� �xUjp�y�t��WQ&��H<� �R�ڐ@4ӎ���_~L�*.�L�L9&��K
+����Ƨ���R2٘ �4.5`�h*gc��}��r60���?��q�PԦu��B�%��8��iRf��jBq�����\6dG����@�#����Y0�:|���/�.E�ϵ�˵��MIr��?DC����o]� �N�緲`�t��6�Ar�c�kG��$��sڪ��@�Liz��i��1N��$�xGq���w3��dR7L�Ve3�Ay����q��9a��|����@lj=���C���]��8�4i�p=V�]_�&��`ϒ�n�X�C�j7"����\8a@'�c��ܼ �N�Ҙ��s$���<��� s�-:�3@#F~���9�߲=h`������ h���kg`Y�#����3@02R{�'Q�Q�68� !�`��+���q�Z��%'<�F~I�:��,�w�r�*��(�m?.�dι#�: �T��Y*w���HJ��*a���ޤ�
+���:r'W|[��!~��:��!���
+�-Nxre73��c�MOrm��^�.)H�6��ޤ�m%��7"�@���4�S3J6[�yh]k��*�M[E#�g�2�ڙVq2��#�~0�{#�������$n:����x0@��L��'����rj% �N�{O<9�,0H�*/�I��ʭ�v䉺�|&�o��\��9�=��,8ߔv�7����
+�Hq#
+d��ۿ��:X�ĩ�����9�5��ƵN��+�3���:2���i����53K1�
+M3��d�5$ϒ����W�8�t0��i�����t�b������Yj�B����e7I����o�o�M�#�猬"mT����%2��mߗV۾
+�
+����Lr.���֤�B�;���[lX`�R\܌C�q���L����S[~����W�^Zug
+�Gڍ��#R\\-��Z6���R�H������㩪�u��St�8��غb�MF[#CV<(�5�i����7y'K��\���m�<G�I'��S�ˍ�"�RS]C�L�̙F6T�T$�wк��e�W�/py�$kQ����Aqq�؛Hv؊F}�ĆG*�J�A�"f�g3p�O!K������ˮ-��-D�Je=���o^�Ð]\�c);�,]��Ԓ����uK�g/��(.���v��c�*���EV��}>���]���pٽ�+g���1j��U(o)��ӻ��vM�{�B��t(�&8>�(���x�]��������࿀�=?�_)��$R%]L�s�RC��"�/�����`��o��K�p5���ٺm����-[/frn{L�xu[�X;�m��ӷm�q�A���9��O_1Q����t�_��>�@�>��Q�?�����3M���
+�X�����cMOr!;���w+��h>'��=-�4�a���ܱ �l�s�{���)E�I����rgE�<�CJ��
+�?!JF�B?�7�3F[o���7}VԲ���?h��mX�l^�AW���J/.���~ճЬ��i�}�Π@v:Rvu���d�_�M�Az�(ԑ��♛k�.��O�#�j��#A�]��Zj��XK�Z
+Rv���nG��V����#5�bR�d��¼:m)_Z
+>
+��B�賨�E�����A~����[��X9�Q�];�)�� �%�k�zmQ!�5��ϢAsY����gm�F�A|�*'r�
+�Ɍ��
+���^*֎�2��ۊ4�o˪��ه�BcU|}D7�Q�]V��
+�m˪ն�Boޢ�6\V�x��Q����%b�/?�&����h�?K`��b�T?���'�T�Obs��D7Kd�p�D�Kd��gI�۲*>|��Ī�Ԓ�KL�A1vb9r*�z���!����/���O�BwVк�ˇBC��R����3�:dD��P�7P��Mi%?*L�U��B���R��M��J�ҫ2��4*4g�U��F�i��]���h��2����[<L*�~�u���"�a�j��TL^��dkI��]�:y�4��ZK��{�1U�S|T�\�׳t).�%��j֊�p�
+�bO?����:V�Zk*��kV��k*V�5�<,��P�u���Bq��+/��P!��������="#3 �N�2�08Ҥ.jD��( �V��ê��@�M�[�_.J��5����p1P���¦��斒
+A�U���V`Tt��%D��z�る��T\�}$Z�b�$�v/�ݸ��NM BlZ[��.JrB1a�}��q1P�ƅ�GN
+.t�e�EG�2���L�,%�v9�N+˓����
+\�/%~;|���ࠠ*x�pP�'�X{�0��T�^���ۋ����$��R�qPP������U �8���#�AAU��2ypP����%>/��i�I!{�a����\sI~�Ֆr�Z2��@�2`A��#+ �]2��H�����OM~Xk�R�Z��]���3Sbofv�#�}���N}q$�Ϟ�ѩ��������`���A��c� $����߿�gP'3����9���6�nVD���m"y�i����L��� rz���k�@�0k��)��J/�{C��G�^�ҡg**�DI�TOV�QO:=ɒ���]�0�3=1P��h���S��no������N$0H������O�PK�F&$��PKΕv<ptB�pollen.argoPKΕv<���NIŋGpollen_DC_Pollen.pgmlPKΕv<4�[-m��pollen.todoPKΕv<7Rp:Bypollen_profile.profilePKΕv<�F&$��
+�pollen.xmiPK1�4
\ No newline at end of file
Deleted: 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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -1,163 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.business.services;
-
-import org.chorem.pollen.business.PollenBusinessException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.TestManager;
-import org.chorem.pollen.business.dto.ChoiceDTO;
-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 de la gestion des choix.
- *
- * @author enema
- * @version $Id$
- */
-public class ServiceChoiceImplTest {
- private ServiceChoiceImpl instance;
-
- /** log. */
- private static final Log log = LogFactory
- .getLog(ServiceChoiceImplTest.class);
-
- public ServiceChoiceImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- TestManager.start("ServiceChoiceImplTest");
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- TestManager.stop();
- }
-
- @Before
- public void setUp() {
- instance = new ServiceChoiceImpl(TestManager.getContext());
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of createChoice method, of class ServiceChoiceImpl.
- */
- @Test
- public void testCreateChoice() {
- ChoiceDTO choice = new ChoiceDTO();
- choice.setDescription("Test_CreateChoice");
- choice.setValidate(false);
- choice.setName("Test_CreateChoice");
- choice.setValue(3);
- String result = instance.createChoice(choice);
- if (log.isDebugEnabled()) {
- log.debug("result: " + result);
- }
- assertTrue(result.length() > 0);
- }
-
- /**
- * Test of createChoices method, of class ServiceChoiceImpl.
- */
- @Test
- public void testCreateChoices() {
- /* Couvert par le test unitaire sur Poll
- List<ChoiceDTO> choices = null;
- String pollId = "";
- TopiaContext trans = null;
- ChoiceImpl instance = new ChoiceImpl();
- boolean expResult = false;
- boolean result = instance.createChoices(choices, pollId, trans);
- assertEquals(expResult, result);
- */
- }
-
- /**
- * Test of updateChoice method, of class ServiceChoiceImpl.
- */
- @Test
- public void testUpdateChoice() {
- ChoiceDTO dto = new ChoiceDTO();
- dto.setDescription("test_UpdateChoice");
- dto.setName("test_UpdateChoice");
- dto.setValidate(false);
- String choiceId = instance.createChoice(dto);
- dto.setId(choiceId);
- dto.setDescription("update description");
- boolean result = instance.updateChoice(dto);
- assertTrue(result);
- }
-
- /**
- * Test of deleteChoice method, of class ServiceChoiceImpl.
- */
- @Test
- public void testDeleteChoice() {
- ChoiceDTO dto = new ChoiceDTO();
- dto.setDescription("Test_DeletePoll");
- dto.setName("Test_DeletePoll");
- dto.setValidate(false);
- String choiceId = instance.createChoice(dto);
- dto.setId(choiceId);
- boolean result = instance.deleteChoice(choiceId);
- assertTrue(result);
- }
-
- /**
- * Test of findChoiceById method, of class ServiceChoiceImpl.
- */
- @Test
- public void testFindChoiceById() {
- ChoiceDTO dto = new ChoiceDTO();
- dto.setDescription("test findChoiceById");
- dto.setName("test findChoiceById");
- dto.setValidate(false);
- String choiceId = instance.createChoice(dto);
- ChoiceDTO result = instance.findChoiceById(choiceId);
- String resultId = result.getId();
- assertEquals(choiceId, resultId);
- }
-
- /**
- * Test of selectChoices method, of class ServiceChoiceImpl.
- */
- @Test
- public void testSelectChoices() {
- ChoiceDTO dto = new ChoiceDTO();
- dto.setDescription("test selectChoices");
- dto.setName("test selectChoices");
- dto.setValidate(false);
- String choiceId = instance.createChoice(dto);
- List<ChoiceDTO> result = instance.selectChoices(null);
- assertTrue(result.size() > 1);
- }
-}
\ No newline at end of file
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -138,7 +138,7 @@
/** EXEC METHOD **/
instance.createAccountInPersonList(dto, account);
- Assert.assertNotNull(account.getAccountId());
+ Assert.assertNotNull(account.getAccountUId());
Assert.assertNotNull(account.getId());
Assert.assertEquals(1, dto.getPollAccounts().size());
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContextImpl;
import org.chorem.pollen.business.TestData;
import org.chorem.pollen.business.TestManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -34,6 +33,8 @@
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.dto.VoteDTO;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.ChoiceDAO;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.CommentDAO;
import org.chorem.pollen.business.persistence.Poll;
@@ -47,7 +48,6 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.nuiton.util.beans.BinderProvider;
/**
* Tests du service de gestion des sondages.
@@ -120,7 +120,8 @@
dto.setChoices(choices);
- final String result = instance.createPoll(dto);
+ instance.createPoll(dto);
+ final String result = dto.getId();
if (log.isDebugEnabled()) {
log.debug("result: " + result);
}
@@ -368,7 +369,7 @@
dto.setPollType(PollType.FREE);
dto.setChoiceType(ChoiceType.TEXT);
dto.setVoteCounting(VoteCountingType.NORMAL);
- String pollId = instance.createPoll(dto);
+ instance.createPoll(dto);
List<PollDTO> result = instance.selectPolls(null);
assertTrue(result.size() > 0);
}
@@ -403,8 +404,8 @@
poll.setPollType(PollType.FREE);
poll.setChoiceType(ChoiceType.TEXT);
poll.setVoteCounting(VoteCountingType.NORMAL);
- final String id = instance.createPoll(poll);
- poll.setId(id);
+ instance.createPoll(poll);
+ final String pollId = poll.getId();
/** EXEC METHOD **/
final CommentDTO comment = new CommentDTO();
@@ -426,7 +427,7 @@
Comment result = dao.findByTopiaId(comment.getId());
Assert.assertNotNull(result);
Assert.assertNotNull(result.getPoll());
- Assert.assertEquals(id, result.getPoll().getTopiaId());
+ Assert.assertEquals(pollId, result.getPoll().getTopiaId());
}
};
@@ -448,8 +449,7 @@
poll.setPollType(PollType.FREE);
poll.setChoiceType(ChoiceType.TEXT);
poll.setVoteCounting(VoteCountingType.NORMAL);
- String id = instance.createPoll(poll);
- poll.setId(id);
+ instance.createPoll(poll);
final CommentDTO comment = new CommentDTO();
comment.setAuthor("Jack Pot");
@@ -491,8 +491,7 @@
poll.setPollType(PollType.RESTRICTED);
poll.setChoiceType(ChoiceType.TEXT);
poll.setVoteCounting(VoteCountingType.NORMAL);
- String id = instance.createPoll(poll);
- poll.setId(id);
+ instance.createPoll(poll);
PollAccountDTO account = new PollAccountDTO();
account.setVotingId("toto");
@@ -500,4 +499,120 @@
// TODO
}
+
+ /**
+ * Test of getNewPoll method, of class ServicePollImpl.
+ */
+ //@Test
+ public void testGetNewPoll_0args() {
+ System.out.println("getNewPoll");
+ }
+
+ /**
+ * Test of getNewPoll method, of class ServicePollImpl.
+ */
+ //@Test
+ public void testGetNewPoll_PollDTO() {
+ System.out.println("getNewPoll");
+ }
+
+ /**
+ * Test of getPoll method, of class ServicePollImpl.
+ */
+ //@Test
+ public void testGetPoll() {
+ System.out.println("getPoll");
+ }
+
+ /**
+ * Test of getComments method, of class ServicePollImpl.
+ */
+ //@Test
+ public void testGetComments() {
+ System.out.println("getComments");
+ }
+
+ /**
+ * Test of getNewHiddenChoice method, of class ServicePollImpl.
+ */
+ //@Test
+ public void testGetNewHiddenChoice() throws IOException {
+ TestManager.start("testGetNewHiddenChoice");
+ instance = new ServicePollImpl(TestManager.getContext());
+
+ // TODO
+
+ //ChoiceDTO choice = instance.getNewHiddenChoice(null, null)
+ }
+
+ /**
+ * Test of createChoice method, of class ServicePollImpl.
+ * @throws IOException
+ */
+ @Test
+ public void testCreateChoice() throws IOException {
+ TestManager.start("testCreateChoice");
+ instance = new ServicePollImpl(TestManager.getContext());
+
+ /** PREPARE DATA **/
+ PollDTO poll = instance.getNewPoll();
+ poll.setTitle("createChoice");
+ poll.setPollType(PollType.FREE);
+ poll.setChoiceType(ChoiceType.TEXT);
+ poll.setVoteCounting(VoteCountingType.NORMAL);
+ instance.createPoll(poll);
+
+ /** EXEC METHOD **/
+ ChoiceDTO choice = new ChoiceDTO();
+ choice.setName("CHOICE1");
+ choice.setDescription("description");
+
+ // No constraint for creation
+ instance.createChoice(poll, choice);
+
+ Assert.assertNotNull(choice.getId());
+ Assert.assertEquals(1, poll.getChoices().size());
+ Assert.assertEquals("CHOICE1", poll.getChoices().get(0).getName());
+ }
+
+ /**
+ * Test of deleteChoice method, of class ServicePollImpl.
+ * @throws Exception
+ */
+ @Test
+ public void testDeleteChoice() throws Exception {
+ TestManager.start("testDeleteChoice");
+ instance = new ServicePollImpl(TestManager.getContext());
+
+ /** PREPARE DATA **/
+ PollDTO poll = instance.getNewPoll();
+ poll.setTitle("createChoice");
+ poll.setPollType(PollType.FREE);
+ poll.setChoiceType(ChoiceType.TEXT);
+ poll.setVoteCounting(VoteCountingType.NORMAL);
+ instance.createPoll(poll);
+
+ final ChoiceDTO choice = new ChoiceDTO();
+ choice.setName("CHOICE1");
+ choice.setDescription("description");
+ instance.createChoice(poll, choice);
+
+ /** EXEC METHOD **/
+ instance.deleteChoice(poll, choice.getId());
+
+ Assert.assertEquals(0, poll.getChoices().size());
+
+ // Test if the choice entity not exist anymore in database
+ TestData test = new TestData() {
+
+ @Override
+ protected void test() throws Exception {
+ ChoiceDAO dao = PollenModelDAOHelper.getChoiceDAO(transaction);
+ Choice result = dao.findByTopiaId(choice.getId());
+ Assert.assertNull(result);
+ }
+ };
+
+ test.execute();
+ }
}
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -0,0 +1,49 @@
+
+package org.chorem.pollen.ui.base;
+
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.tapestry5.annotations.InjectPage;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.upload.services.UploadSymbols;
+import org.chorem.pollen.ui.pages.ErrorPage;
+import org.chorem.pollen.ui.utils.UnitConverter;
+
+/**
+ * AbstractUploadPage
+ *
+ * Created: 22 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class AbstractUploadPage {
+
+ @InjectPage
+ private ErrorPage errorPage;
+
+ @Inject
+ private Messages messages;
+
+ /** Tailles maximales des fichiers uploadés */
+ @Inject
+ @Symbol(UploadSymbols.FILESIZE_MAX)
+ private int fileSizeMax;
+
+ @Inject
+ @Symbol(UploadSymbols.REQUESTSIZE_MAX)
+ private int requestSizeMax;
+
+ Object onUploadException(FileUploadException eee) {
+ String fSize = UnitConverter.getFormattedFileSize(fileSizeMax);
+ String rSize = UnitConverter.getFormattedFileSize(requestSizeMax);
+ errorPage.addError(
+ messages.format("pollen.ui.error.upload", fSize, rSize));
+ return errorPage;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/AbstractUploadPage.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -135,7 +135,7 @@
public String getAdminId() {
PollAccountDTO creator = servicePollAccount.findPollAccountById(poll
.getCreatorId());
- return poll.getPollUId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountUId();
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -24,6 +24,7 @@
import java.util.Locale;
import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
@@ -178,6 +179,10 @@
return feedContext;
}
+ public FeedBack getFeedBack() {
+ return feedback;
+ }
+
/**
* Methode appelée lorsque l'utilisateur s'identifie. L'utilisateur est
* retrouvé grâce au service d'authentification.
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedBack.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -114,4 +114,8 @@
errorMessages.add(message);
}
}
+
+ public boolean getHasErrors() {
+ return !errorMessages.isEmpty();
+ }
}
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -1,19 +1,15 @@
package org.chorem.pollen.ui.data;
-import java.io.File;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.fileupload.FileUploadException;
-import org.apache.tapestry5.StreamResponse;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.Block;
import org.apache.tapestry5.upload.services.UploadedFile;
-import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.dto.ChoiceDTO;
+import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.ui.utils.ImageUtil;
-import org.nuiton.util.DateUtils;
+import org.chorem.pollen.ui.services.ServiceImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,29 +56,41 @@
}
- public ChoiceField(ChoiceDTO dto, ChoiceType type) {
+ public ChoiceField(PollDTO poll) {
+ switch (poll.getChoiceType()) {
+ case DATE:
+ setDateType();
+ break;
+ case TEXT:
+ setTextType();
+ break;
+ case IMAGE:
+ setImageType(poll.getPollUId());
+ }
+ }
+
+ public ChoiceField(PollDTO poll, ChoiceDTO dto) {
+ this(poll);
if (log.isDebugEnabled()) {
- log.debug("Instanciate ChoiceField : type = " + type +
+ log.debug("Instanciate ChoiceField : " +
+ "type = " + poll.getChoiceType() +
" _ name = " + dto.getName());
}
- switch (type) {
+ switch (poll.getChoiceType()) {
case DATE:
- setDateType();
setDate(new Date(Long.parseLong(dto.getName())));
break;
case TEXT:
- setTextType();
setText(dto.getName());
break;
case IMAGE:
- setImageType(dto.getPollUId());
setImageFileName(dto.getName());
}
setDescription(dto.getDescription());
setHidden(dto.getHidden());
setId(dto.getId());
setValidate(dto.getValidate());
- setPollUId(dto.getPollUId());
+// setPollUId(dto.getPollUId());
setName(dto.getName());
//setValue(dto.getValue());
//setVoteId(dto.getVoteId());
@@ -159,6 +167,10 @@
image = null;
}
+ public ChoiceType getType() {
+ return type;
+ }
+
public void setDate(Date date) {
this.date = date;
}
@@ -170,14 +182,16 @@
public void setImage(UploadedFile image) throws FileUploadException {
if (image != null) {
this.image = image;
- if (!image.getContentType().equals("image") ||
- !image.getContentType().equals("IMAGE")) {
- throw new FileUploadException("wrong type for image upload");
+ String contentType = StringUtils.lowerCase(image.getContentType());
+ if (!contentType.contains("image")) {
+ throw new FileUploadException("wrong type " +
+ image.getContentType() + " for image upload " +
+ image.getFileName());
}
}
}
- public UploadedFile getImage() throws ParseException {
+ public UploadedFile getImage() {
return image;
}
@@ -212,12 +226,13 @@
* correspond to the image file name ;
* - TEXT : the text becomes the choice name.
* </pre>
+ * @param serviceImage used to save the image
*/
- public void saveName() {
+ public void saveName(ServiceImage serviceImage) {
String name = "";
switch (type) {
case DATE:
- name = String.valueOf(date.getTime());
+ name = String.valueOf(getDate().getTime());
break;
case IMAGE:
// // Get directory to save the image using the context from
@@ -238,7 +253,7 @@
// if (log.isDebugEnabled()) {
// log.debug("save name for image : " + file.getName());
// }
- //name = serviceImage.saveImage(getImage(), getImageDir());
+ name = serviceImage.saveImage(getImage(), getImageDir());
break;
case TEXT:
name = getText();
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -0,0 +1,33 @@
+
+package org.chorem.pollen.ui.pages;
+
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.chorem.pollen.ui.components.Border;
+import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.data.AddressBarItem;
+
+/**
+ * Error
+ *
+ * Created: 22 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ErrorPage {
+
+ @InjectComponent
+ private Border border;
+
+ public void addError(String message) {
+ border.getFeedBack().addError(message);
+ }
+
+ public AddressBarItem[] getAddress() {
+ return new AddressBar().getItems();
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/ErrorPage.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -103,7 +103,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getPollUId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountUId();
}
void onActivate() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -103,7 +103,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getPollUId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountUId();
}
void onActivate() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -103,7 +103,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getPollUId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountUId();
}
void onActivate() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -824,7 +824,7 @@
PollDTO poll, Messages messages) {
PollAccountDTO creator = servicePollAccount.findPollAccountById(poll.getCreatorId());
String voteURL = siteURL + "poll/VoteFor/" + poll.getPollUId();
- String modifURL = siteURL + "poll/Modification/" + poll.getPollUId() + ":" + creator.getAccountId();
+ String modifURL = siteURL + "poll/Modification/" + poll.getPollUId() + ":" + creator.getAccountUId();
Map<String, String> data = new HashMap<String, String>();
data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
@@ -848,7 +848,7 @@
List<Map<String, String>> mailList = new ArrayList<Map<String, String>>();
for (PollAccountDTO account : list.getPollAccountDTOs()) {
if (account.getEmail() != null) {
- String accountVoteURL = voteURL + ":" + account.getAccountId();
+ String accountVoteURL = voteURL + ":" + account.getAccountUId();
/*data.put("to", account.getEmail());
data.put("title", messages.format("votingEmail_subject",
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -543,7 +543,7 @@
// Mails aux votants
for (PollAccountDTO account : modifiedAccounts) {
if (account.getEmail() != null) {
- String accountVoteURL = voteURL + ":" + account.getAccountId();
+ String accountVoteURL = voteURL + ":" + account.getAccountUId();
data.put("to", account.getEmail());
data.put("title", messages.format("votingEmail_subject", poll
@@ -609,7 +609,7 @@
}
if (id.split(":", 2).length == 2) {
String creatorId = id.split(":", 2)[1];
- if (creatorId.equals(creator.getAccountId())) {
+ if (creatorId.equals(creator.getAccountUId())) {
userAllowed = true;
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -482,7 +482,7 @@
userAllowed = true;
} else if (id.split(":", 2).length == 2) {
String creatorId = id.split(":", 2)[1];
- if (creatorId.equals(creator.getAccountId())) {
+ if (creatorId.equals(creator.getAccountUId())) {
userAllowed = true;
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -26,6 +26,7 @@
import java.util.Locale;
import java.util.Map;
+import org.apache.commons.fileupload.FileUploadException;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
@@ -37,6 +38,7 @@
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Persist;
@@ -49,7 +51,6 @@
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.upload.services.UploadedFile;
-import org.chenillekit.tapestry.core.components.DateTimeField;
import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.business.PollenProperty;
@@ -64,7 +65,6 @@
import org.chorem.pollen.business.dto.ResultListDTO;
import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.dto.VoteDTO;
-import org.chorem.pollen.business.services.ServiceChoice;
import org.chorem.pollen.business.services.ServicePoll;
import org.chorem.pollen.business.services.ServicePollAccount;
import org.chorem.pollen.business.services.ServiceResults;
@@ -73,10 +73,10 @@
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.ui.base.AbstractUploadPage;
import org.chorem.pollen.ui.base.ContextLink;
import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.components.ImageContextLink;
import org.chorem.pollen.ui.components.Pager;
import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.ChoiceField;
@@ -87,7 +87,6 @@
import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
import org.chorem.pollen.ui.services.ServiceImage;
import org.chorem.pollen.ui.utils.FeedUtil;
-import org.chorem.pollen.ui.utils.ImageUtil;
import org.slf4j.Logger;
/**
@@ -99,7 +98,7 @@
*/
@IncludeStylesheet({"context:css/vote.css", "context:css/lightbox.css"})
@IncludeJavaScriptLibrary({"${tapestry.scriptaculous}/builder.js","context:js/lightbox.js"})
-public class VoteForPoll {
+public class VoteForPoll extends AbstractUploadPage {
@Inject
private Logger log;
@@ -129,10 +128,10 @@
// @Component(id = "pollAccountName")
// private TextField nameField;
- /** Composant DateTimeField pour les choix du sondage */
- @SuppressWarnings("unused")
- @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" })
- private DateTimeField dateDTF;
+// /** Composant DateTimeField pour les choix du sondage */
+// @SuppressWarnings("unused")
+// @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" })
+// private DateTimeField dateDTF;
/** Locale courante */
@Inject
@@ -203,10 +202,10 @@
// @Property
// private PollAccountDTO pollAccount;
- /** Nouveau choix de type texte */
- @Property
- @Persist
- private ChoiceDTO newChoice;
+// /** Nouveau choix de type texte */
+// @Property
+// @Persist
+// private ChoiceDTO newChoice;
/** Nouveau choix de type date */
@Property
@@ -228,8 +227,6 @@
private ServicePollAccount servicePollAccount;
@Inject
private ServiceResults serviceResults;
- @Inject
- private ServiceChoice serviceChoice;
/**
* Composant pour la gestion des flux RSS
@@ -245,20 +242,20 @@
return feedContext;
}
- /**
- * Composant pour la gestion des upload d'images
- */
- @InjectComponent
- private ImageContextLink imgContext;
+// /**
+// * Composant pour la gestion des upload d'images
+// */
+// @InjectComponent
+// private ImageContextLink imgContext;
+//
+// /**
+// * Context to get images for choices.
+// * @return an ImageContextLink defined in .tml file
+// */
+// public ImageContextLink getImgContext() {
+// return imgContext;
+// }
- /**
- * Context to get images for choices.
- * @return an ImageContextLink defined in .tml file
- */
- public ImageContextLink getImgContext() {
- return imgContext;
- }
-
@InjectComponent
private FeedBack voteFeedback;
@@ -662,13 +659,13 @@
private ChoiceDTO currentVoteChoice;
public char setCurrentVoteChoice() {
- currentVoteChoice = null;
- for (ChoiceDTO choice : vote.getChoiceDTOs()) {
- if (choice.getId().equals(choiceOfPoll.getId())) {
- currentVoteChoice = choice;
- break;
- }
- }
+// currentVoteChoice = null;
+// for (ChoiceDTO choice : vote.getChoiceDTOs()) {
+// if (choice.getId().equals(choiceOfPoll.getId())) {
+// currentVoteChoice = choice;
+// break;
+// }
+// }
return 0;
}
@@ -827,8 +824,8 @@
.replace(' ', '_'));
getPoll().getChoices().add(newImageChoice);
//File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
- File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
- ImageUtil.saveImage(newImageChoice, imgFile);
+// File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
+// ImageUtil.saveImage(newImageChoice, imgFile);
choiceName = newImageChoice.getName();
choiceDesc = newImageChoice.getDescription();
}
@@ -848,33 +845,16 @@
// return poll == null;
// }
- public boolean isPollStarted() throws PollenBusinessException {
- Date now = new Date();
- return getPoll().getBeginDate() == null || getPoll().getBeginDate().before(now);
- }
- public boolean isPollFinished() throws PollenBusinessException {
- Date now = new Date();
- return getPoll().getEndDate() != null && getPoll().getEndDate().before(now);
- }
-
public boolean isPollChoiceOrVoteStarted() throws PollenBusinessException {
return isPollChoiceStarted() || isPollStarted();
}
- public boolean isPollRunning() throws PollenBusinessException {
- return isPollStarted() && !isPollFinished() && !getPoll().isClosed();
- }
-
// public boolean isDescNull() {
// return choiceOfPoll.getDescription() == null
// || "".equals(choiceOfPoll.getDescription());
// }
- /** Retourne vrai si le champs pollAccount doit apparaître. */
- public boolean isAccountFieldDisplayed() throws PollenBusinessException {
- return !getPoll().isAnonymous() || isRestrictedPoll() || isGroupPoll();
- }
public boolean isFreePoll() throws PollenBusinessException {
return getPoll().getPollType() == PollType.FREE;
@@ -1085,7 +1065,7 @@
if (poll != null) {
// Initialisations pour les formulaires
- newChoice = new ChoiceDTO();
+// newChoice = new ChoiceDTO();
newDateChoice = new DateChoiceUIO();
newImageChoice = new ImageChoiceUIO();
} else {
@@ -1096,6 +1076,22 @@
return poll;
}
+ public boolean isPollStarted() throws PollenBusinessException {
+ Date now = new Date();
+ return getPoll().getBeginDate() == null ||
+ getPoll().getBeginDate().before(now);
+ }
+
+ public boolean isPollFinished() throws PollenBusinessException {
+ Date now = new Date();
+ return getPoll().getEndDate() != null &&
+ getPoll().getEndDate().before(now);
+ }
+
+ public boolean isPollRunning() throws PollenBusinessException {
+ return isPollStarted() && !isPollFinished() && !getPoll().isClosed();
+ }
+
/**
* Use a PollAccount to represent the current session user.
* The existing account is used if accountUId is present in the uri.
@@ -1142,6 +1138,57 @@
return userExists && user.getId().equals(getPoll().getUserId());
}
+ /************** PAGER *****************************************************/
+
+ @InjectComponent
+ private Pager pager;
+
+ private Integer page;
+
+ @Persist
+ private Integer nbVotesPerPage;
+
+ public int getPage() {
+ if (page == null) {
+ page = pager.getFirstPage();
+ }
+ return page;
+ }
+
+ @Log
+ public void setPage(int page) {
+ this.page = page;
+ }
+
+ /**
+ * Get the number of votes to display per page from configuration.
+ *
+ * @return the number of votes to display per page
+ */
+ public int getNbVotesPerPage() {
+ if (nbVotesPerPage == null) {
+ nbVotesPerPage = getPagerRange();
+ }
+ return nbVotesPerPage;
+ }
+
+ public void setNbVotesPerPage(int nbVotesPerPage) {
+ this.nbVotesPerPage = nbVotesPerPage;
+ }
+
+ public int getPagerRange() {
+ return Integer.parseInt(
+ pollen.getProperty(PollenProperty.NB_VOTES_PER_PAGE));
+ }
+
+ public String getNoPagerText() throws PollenBusinessException {
+ if (getPoll().getNbVotes() == 0) {
+ return messages.get("pollen.ui.vote.noVote");
+ }
+ return messages.format("pollen.ui.vote.noPager",
+ getPoll().getNbVotes());
+ }
+
/************** CHOICES ***************************************************/
private List<ChoiceField> choices;
@@ -1158,7 +1205,18 @@
@Inject
private Block choiceDate;
+ private ChoiceField newChoice;
+
@Inject
+ private Block newChoiceText;
+
+ @Inject
+ private Block newChoiceImage;
+
+ @Inject
+ private Block newChoiceDate;
+
+ @Inject
private ComponentResources resources;
@Inject
@@ -1179,8 +1237,7 @@
}
choices = new ArrayList<ChoiceField>();
for (ChoiceDTO curr : getPoll().getChoices()) {
- ChoiceField field = new ChoiceField(curr,
- getPoll().getChoiceType());
+ ChoiceField field = new ChoiceField(getPoll(), curr);
choices.add(field);
}
}
@@ -1245,7 +1302,54 @@
boolean thumb) {
return serviceImage.createImageStream(src, imageDir, thumb);
}
+
+ /**
+ * Delegator : Retrieve the newChoice to create a choice in the poll
+ * using the addChoice form.
+ *
+ * @return a ChoiceField to manage different choice type
+ * @throws PollenBusinessException
+ */
+ public ChoiceField getNewChoice() throws PollenBusinessException {
+ if (newChoice == null) {
+ newChoice = new ChoiceField(getPoll());
+// switch (getPoll().getChoiceType()) {
+// case DATE:
+// newChoice = ChoiceField.getChoiceDate();
+// break;
+// case IMAGE:
+// newChoice = ChoiceField.getChoiceImage(
+// getPoll().getPollUId());
+// break;
+// case TEXT:
+// default:
+// newChoice = ChoiceField.getChoiceText();
+// }
+ // Don't know what validate is
+ newChoice.setValidate(true);
+ }
+ return newChoice;
+ }
+ /**
+ * Retrieve the block to display for input choiceName depends on
+ * choice type.
+ *
+ * @return the block to display
+ * @throws PollenBusinessException
+ */
+// public Block getNewChoiceBlock() throws PollenBusinessException {
+// switch(getPoll().getChoiceType()) {
+// case IMAGE:
+// return newChoiceImage;
+// case DATE:
+// return newChoiceDate;
+// case TEXT:
+// default:
+// return newChoiceText;
+// }
+// }
+
public boolean isPollChoiceRunning() throws PollenBusinessException {
return getPoll().isChoiceAddAllowed() && isPollChoiceStarted();
}
@@ -1265,7 +1369,7 @@
return started && !ended;
}
- public boolean canDeleteChoice() throws PollenBusinessException {
+ public boolean getCanDeleteChoice() throws PollenBusinessException {
return isPollChoiceRunning() && isCreatorUser();
}
@@ -1274,7 +1378,7 @@
*/
void onActionFromDeleteChoice(String choiceId)
throws PollenBusinessException {
- if (canDeleteChoice()) {
+ if (getCanDeleteChoice()) {
servicePoll.deleteChoice(getPoll(), choiceId);
// Reset choices (ChoiceField list) to retrieve the updated one
// from poll
@@ -1282,57 +1386,24 @@
}
}
- /************** PAGER *****************************************************/
-
- @InjectComponent
- private Pager pager;
-
- private Integer page;
-
- @Persist
- private Integer nbVotesPerPage;
-
- public int getPage() {
- if (page == null) {
- page = pager.getFirstPage();
- }
- return page;
+ public boolean getCanAddChoice() throws PollenBusinessException {
+ return isPollChoiceRunning();
}
- @Log
- public void setPage(int page) {
- this.page = page;
- }
-
/**
- * Get the number of votes to display per page from configuration.
- *
- * @return the number of votes to display per page
+ * SUCCESS EVENT :: add a new choice from addChoice form.
+ *
+ * @throws PollenBusinessException
*/
- public int getNbVotesPerPage() {
- if (nbVotesPerPage == null) {
- nbVotesPerPage = getPagerRange();
+ void onSuccessFromAddChoice() throws PollenBusinessException {
+ if (getCanAddChoice()) {
+ // No validation done on choice with existing name
+ // Save name depends on choice type
+ newChoice.saveName(serviceImage);
+ servicePoll.createChoice(getPoll(), newChoice);
}
- return nbVotesPerPage;
}
- public void setNbVotesPerPage(int nbVotesPerPage) {
- this.nbVotesPerPage = nbVotesPerPage;
- }
-
- public int getPagerRange() {
- return Integer.parseInt(
- pollen.getProperty(PollenProperty.NB_VOTES_PER_PAGE));
- }
-
- public String getNoPagerText() throws PollenBusinessException {
- if (getPoll().getNbVotes() == 0) {
- return messages.get("pollen.ui.vote.noVotes");
- }
- return messages.format("pollen.ui.vote.noPager",
- getPoll().getNbVotes());
- }
-
/************** VOTES *****************************************************/
private List<VoteDTO> votes;
@@ -1340,6 +1411,8 @@
@Property
private int voteIndex;
+ private VoteDTO currentVote;
+
/**
* Retrieve votes of the current poll from business module.
* The votes are ordered by creation date, only the ones to display are
@@ -1356,10 +1429,47 @@
return votes;
}
+ public VoteDTO getCurrentVote() {
+ if (currentVote == null) {
+ currentVote = serviceVote.getNewVote(getPollAccount());
+ }
+ return currentVote;
+ }
+
+ /**
+ * Retourne vrai si le champs pollAccount doit apparaître.
+ *
+ * FD-20100322 ::
+ * Strange behavior ? why testing pollType (restricted or group) to
+ * display accountField ?!? Even it's anonymous, the field appears for
+ * restricted poll ?!?
+ *
+ * @return
+ * @throws PollenBusinessException
+ * @deprecated strange method
+ */
+ @Deprecated
+ public boolean isAccountFieldDisplayed() throws PollenBusinessException {
+ return !getPoll().isAnonymous() || isRestrictedPoll() || isGroupPoll();
+ }
+
+ public void setChoiceValue(Integer value) {
+ getCurrentVote().setChoiceValue(choice.getId(), value);
+ }
+
+ public Integer getChoiceValue() {
+ return getCurrentVote().getChoiceValue(choice.getId());
+ }
+
+ public boolean getCanVote() throws PollenBusinessException {
+ return isPollRunning();
+ }
+
public boolean canEditVote() throws PollenBusinessException {
// If the current account exist from uri and equals to the current vote
String newAccountId = getPollAccount().getId();
- if (newAccountId != null && newAccountId.equals(vote.getPollAccountId())) {
+ if (newAccountId != null &&
+ newAccountId.equals(vote.getPollAccountId())) {
return true;
// If the connected user is an admin
} else if (userExists && user.isAdministrator()) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -74,7 +74,7 @@
for (VotingListDTO list : poll.getVotingListDTOs()) {
for (PollAccountDTO account : list.getPollAccountDTOs()) {
if (account.getEmail().equals(user.getEmail())) {
- return poll.getPollUId() + ":" + account.getAccountId();
+ return poll.getPollUId() + ":" + account.getAccountUId();
}
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -34,8 +34,6 @@
import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.services.ServiceAuth;
import org.chorem.pollen.business.services.ServiceAuthImpl;
-import org.chorem.pollen.business.services.ServiceChoice;
-import org.chorem.pollen.business.services.ServiceChoiceImpl;
import org.chorem.pollen.business.services.ServiceList;
import org.chorem.pollen.business.services.ServiceListImpl;
import org.chorem.pollen.business.services.ServicePoll;
@@ -123,12 +121,6 @@
return new ServiceVoteImpl(context);
}
- /** Will be divided between serviceVote and servicePoll **/
- public static ServiceChoice buildServiceChoice(
- @InjectService("PollenContext") PollenContextImplementor context) {
- return new ServiceChoiceImpl(context);
- }
-
public static ServiceImage buildServiceImage(
@InjectService("PollenContext") PollenContextImplementor context) {
return new ServiceImageImpl(context);
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 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -146,7 +146,7 @@
for (PollAccountDTO account : list.getPollAccountDTOs()) {
if (account.getEmail() != null) {
String accountVoteURL = voteURL + ":"
- + account.getAccountId();
+ + account.getAccountUId();
data.put("to", account.getEmail());
data.put("title", messages.format(
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -117,7 +117,7 @@
}
dir.mkdirs();
}
- String filename = tmpfile.getFileName();
+ String filename = tmpfile.getFileName().replace(' ', '_');
File image = new File(dir, filename);
tmpfile.write(image);
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties 2010-03-23 11:15:12 UTC (rev 2955)
@@ -43,5 +43,23 @@
pollen.ui.choice.delete.confirm=Are you sure you want to delete this choice ?
pollen.ui.choice.delete.title=Delete this choice
-pollen.ui.vote.noVotes=Aucune personne n'a encore particip\u00E9 au sondage
-pollen.ui.vote.noPager=%d existing votes
\ No newline at end of file
+pollen.ui.vote.noVote=Aucune personne n'a encore particip\u00E9 au sondage
+pollen.ui.vote.noPager=%$1d existing votes
+pollen.ui.choice.datePattern=MM/dd/yyyy h:mm a
+pollen.ui.choice.add.title=Adding a choice
+pollen.ui.choice.add.submit=Add
+pollen.ui.error.upload=An error occurred while uploading files. Maximum size allowed is %$1s per file, and %$2s total.
+
+# Tapestry messages for VoteForPoll.tml
+# FORM:: addChoice
+choiceDescription-label=Description
+choiceText-label=Choice
+addChoice-choiceText-required-message=You must provide a choice.
+choiceDate-label=Date and time
+addChoice-choiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+addChoice-choiceDate-regexp-message=Date does not match pattern 12/31/2000 12:59 AM.
+addChoice-choiceDate-required-message=You must provide a choice.
+choiceImage-label=Image
+addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
+addChoice-choiceImage-regexp-message=The image must be a JPG, GIF or PNG file.
+addChoice-choiceImage-required-message=You must provide a choice.
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-03-23 11:15:12 UTC (rev 2955)
@@ -43,5 +43,23 @@
pollen.ui.choice.delete.confirm=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer ce choix ?
pollen.ui.choice.delete.title=Supprimer ce choix
-pollen.ui.vote.noVotes=Aucune personne n'a encore particip\u00E9 au sondage
-pollen.ui.vote.noPager=%d votes existants
+pollen.ui.vote.noVote=Aucune personne n'a encore particip\u00E9 au sondage
+pollen.ui.vote.noPager=%1$d votes existants
+pollen.ui.choice.datePattern=dd/MM/yyyy HH:mm
+pollen.ui.choice.add.title=Ajout d'un choix
+pollen.ui.choice.add.submit=Ajouter
+pollen.ui.error.upload=Une erreur s'est produite lors du transfert des fichiers. La taille maximale autoris\u00E9e est de %1$s par fichier et %2$s au total.
+
+# Tapestry messages for VoteForPoll.tml
+# FORM:: addChoice
+choiceDescription-label=Description
+choiceText-label=Choix
+addChoice-choiceText-required-message=Vous devez saisir un choix.
+choiceDate-label=Date et heure
+addChoice-choiceDate-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+addChoice-choiceDate-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59.
+addChoice-choiceDate-required-message=Vous devez saisir un choix.
+choiceImage-label=Image
+addChoice-choiceImage-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
+addChoice-choiceImage-regexp-message=L'image doit-\u00EAtre au format JPG, GIF ou PNG.
+addChoice-choiceImage-required-message=Vous devez saisir un choix.
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Border.tml 2010-03-23 11:15:12 UTC (rev 2955)
@@ -161,8 +161,10 @@
<noscript>
<t:feedback t:id="errorJs" />
</noscript>
- <t:feedback t:id="borderFeedback" />
- <t:body />
+ <t:feedback t:id="borderFeedback" />
+ <t:unless t:test="feedBack.hasErrors">
+ <t:body />
+ </t:unless>
</div>
</div>
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties 2010-03-23 11:15:12 UTC (rev 2955)
@@ -23,22 +23,22 @@
#vote-noPagerText=%d existing votes
#choices
-addChoice=Adding a choice
-textName-label=Choice *
-textName-required-message=You must provide a choice.
-textDesc-label=Description
-imgFile-label=Image *
-imgFile-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
-imgFile-regexp-message=The image must be a JPG, GIF or PNG file.
-imgFile-required-message=You must provide a choice.
-imgDesc-label=Description
-dateDTF-label=Date and time *
-dateDTF-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
-dateDTF-regexp-message=Date does not match pattern 12/31/2000 12:59 AM.
-dateDTF-required-message=You must provide a choice.
-dateDesc-label=Description
-DTF-pattern=MM/dd/yyyy h:mm a
-submitChoice=Add
+#addChoice=Adding a choice
+#textName-label=Choice *
+#textName-required-message=You must provide a choice.
+#textDesc-label=Description
+#imgFile-label=Image *
+#imgFile-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
+#imgFile-regexp-message=The image must be a JPG, GIF or PNG file.
+#imgFile-required-message=You must provide a choice.
+#imgDesc-label=Description
+#dateDTF-label=Date and time *
+#dateDTF-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+#dateDTF-regexp-message=Date does not match pattern 12/31/2000 12:59 AM.
+#dateDTF-required-message=You must provide a choice.
+#dateDesc-label=Description
+#DTF-pattern=MM/dd/yyyy h:mm a
+#submitChoice=Add
#comments
comments=Comments about the poll
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties 2010-03-23 11:15:12 UTC (rev 2955)
@@ -24,21 +24,21 @@
#choices
addChoice=Ajout d'un choix
-textName-label=Choix *
-textName-required-message=Vous devez saisir un choix.
-textDesc-label=Description
-imgFile-label=Image *
-imgFile-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
-imgFile-regexp-message=L'image doit-\u00EAtre au format JPG, GIF ou PNG.
-imgFile-required-message=Vous devez saisir un choix.
-imgDesc-label=Description
-dateDTF-label=Date et heure *
-dateDTF-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
-dateDTF-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59.
-dateDTF-required-message=Vous devez saisir un choix.
-dateDesc-label=Description
-DTF-pattern=dd/MM/yyyy HH:mm
-submitChoice=Ajouter
+#textName-label=Choix *
+#textName-required-message=Vous devez saisir un choix.
+#textDesc-label=Description
+#imgFile-label=Image *
+#imgFile-regexp=\\.(jpe?g|gif|png|JPE?G|GIF|PNG)$
+#imgFile-regexp-message=L'image doit-\u00EAtre au format JPG, GIF ou PNG.
+#imgFile-required-message=Vous devez saisir un choix.
+#imgDesc-label=Description
+#dateDTF-label=Date et heure *
+#dateDTF-regexp=\\d{2}\/\\d{2}\/\\d{4}( \\d{2}\\:\\d{2})?
+#dateDTF-regexp-message=La date de d\u00E9but doit-\u00EAtre au format 31/12/2000 23:59.
+#dateDTF-required-message=Vous devez saisir un choix.
+#dateDesc-label=Description
+#DTF-pattern=dd/MM/yyyy HH:mm
+#submitChoice=Ajouter
#comments
comments=Commentaires \u00E0 propos du sondage
Added: trunk/pollen-ui/src/main/webapp/ErrorPage.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/ErrorPage.tml (rev 0)
+++ trunk/pollen-ui/src/main/webapp/ErrorPage.tml 2010-03-23 11:15:12 UTC (rev 2955)
@@ -0,0 +1,4 @@
+<t:border t:address="address" t:pageLogo="literal:Index"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+</t:border>
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-23 11:15:12 UTC (rev 2955)
@@ -64,7 +64,8 @@
</p:else>
</t:if>
<th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">
- <t:unless test="choice.hidden">
+ <t:unless test="choice.hidden">
+ <!-- Blocks for each choice type -->
<t:block t:id="choiceText">
<span class="desc">${choice.text}</span>
</t:block>
@@ -76,6 +77,7 @@
<t:block t:id="choiceDate">
<t:output value="choice.date" format="dateFormat"/>
</t:block>
+ <!-- Display choice with or whithout description -->
<t:if t:test="choice.description">
<span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">
<t:delegate to="choiceBlock" />
@@ -84,7 +86,8 @@
<t:delegate to="choiceBlock" />
</p:else>
</t:if>
- <t:if test="canDeleteChoice()">
+ <t:if test="canDeleteChoice">
+ <!-- Action to delete the choice -->
<t:actionlink t:id="deleteChoice" context="choice.id"
t:mixins="confirm" t:message="message:pollen.ui.choice.delete.confirm">
<img src="${asset:context:img/delete.png}" title="message:pollen.ui.choice.delete.title"
@@ -94,39 +97,39 @@
</t:unless>
</th>
</tr>
- </thead><!--
- <t:if test="pollRunning">-->
-<!-- <tfoot>
+ </thead>
+ <t:if test="canVote">
+ <tfoot>
<tr>
<t:if test="accountFieldDisplayed">
<th id="voterName">
- <t:textField t:value="pollAccount.votingId" t:id="pollAccountName" t:validate="required"/>
+ <input t:type="textfield" t:id="pollAccountName" value="pollAccount.votingId" t:validate="required"/>
</th>
<p:else>
<th></th>
</p:else>
</t:if>
<t:loop t:source="choices" t:value="choice" volatile="true">
- <t:if test="!choiceOfVote.hidden">
+ <t:if test="!choice.hidden">
<th>
- <t:if test="isNormalVoteCounting()">
- <t:checkbox t:value="addChoice" />
+ <t:if test="poll.voteCounting.normal">
+ <input t:type="checkbox" value="addChoice" />
</t:if>
- <t:if test="isPercentageVoteCounting()">
- <t:textField t:value="choiceOfVote.value" size="3" t:validate="required, min=0, max=100"/>%
+ <t:if test="poll.voteCounting.percentage">
+ <t:textField t:value="currentVote.getChoiceValues(choice.id)" size="3" t:validate="required, min=0, max=100"/>%
</t:if>
- <t:if test="isCondorcetVoteCounting()">
+ <t:if test="poll.voteCounting.condorcet">
<t:textField t:id="condorcetInput" t:value="choiceOfVote.value" size="3" t:nulls="zero" t:validate="min=0, max=99"/>
</t:if>
- <t:if test="isNumberVoteCounting()">
+ <t:if test="poll.voteCounting.number">
<t:textField t:value="addNumberVote" size="3" />
</t:if>
</th>
</t:if>
</t:loop>
</tr>
- </tfoot>-->
- <!--</t:if>-->
+ </tfoot>
+ </t:if>
<tbody>
<t:unless t:test="poll.anonymous">
<t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true">
@@ -229,47 +232,50 @@
<!--</t:zone>-->
- <!-- Ajout de choix -->
- <t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUId"/>
- <t:if test="${pollChoiceRunning}">
- <h4>${message:addChoice}</h4>
+ <!-- Ajout de choix -->
+ <!--<t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUId"/>-->
+ <t:if test="canAddChoice">
+ <h4>${message:pollen.ui.choice.add.title}</h4>
<div id="choiceFormDiv">
- <t:form t:id="choiceForm">
- <t:formfragment t:id="textChoiceFragment" visible="textType">
- <t:label for="textName" />
- <br/>
- <t:textfield t:id="textName" t:value="newChoice.name" t:validate="required"/>
- <br/>
- <t:label for="textDesc" />
- <br/>
- <t:textfield t:id="textDesc" t:value="newChoice.description" />
- </t:formfragment>
- <t:formfragment t:id="dateChoiceFragment" visible="dateType">
- <t:label for="dateDTF" />
- <br/>
- <input t:id="dateDTF" t:value="newDateChoice.date" t:validate="required, regexp" datePattern="${message:DTF-pattern}"/>
- <br/>
- <t:label for="dateDesc" />
- <br/>
- <t:textfield t:id="dateDesc" t:value="newDateChoice.description" />
- </t:formfragment>
- <t:formfragment t:id="imgChoiceFragment" visible="imageType">
- <t:label for="imgFile" />
- <br/>
- <input t:type="upload" t:id="imgFile" t:value="newImageChoice.img" t:validate="required, regexp" />
- <br/>
- <t:label for="imgDesc" />
- <br/>
- <t:textfield t:id="imgDesc" t:value="newImageChoice.description" />
- </t:formfragment>
- <t:submit t:id="submitChoiceForm" t:value="${message:submitChoice}" />
+ <t:form t:id="addChoice">
+ <t:if t:test="newChoice.type.date">
+ <label t:type="label" for="choiceDate" />*<br />
+ <input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"
+ t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"
+ t:datePattern="message:pollen.ui.choice.datePattern"/>
+ </t:if>
+ <t:if t:test="newChoice.type.image">
+ <label t:type="label" for="choiceImage" />*<br />
+ <input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />
+ </t:if>
+ <t:if t:test="newChoice.type.text">
+ <label t:type="label" for="choiceText" />*<br />
+ <input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>
+ </t:if>
+<!-- <t:delegate t:to="newChoiceBlock" /><br />
+ <t:block t:id="newChoiceDate">
+ <label t:type="label" for="choiceDate" />*<br />
+ <input t:type="ck/dateTimeField" t:id="choiceDate" value="newChoice.date"
+ t:timePicker="true" t:timePickerAdjacent="true" t:validate="required, regexp"
+ t:datePattern="message:pollen.ui.choice.datePattern"/>
+ </t:block>
+ <t:block t:id="newChoiceImage">
+ <label t:type="label" for="choiceImage" />*<br />
+ <input t:type="upload" t:id="choiceImage" t:value="newChoice.image" t:validate="required, regexp" />
+ </t:block>
+ <t:block t:id="newChoiceText">
+ <label t:type="label" for="choiceText" />*<br />
+ <input t:type="textfield" t:id="choiceText" value="newChoice.text" t:validate="required"/>
+ </t:block>-->
+ <label t:type="label" for="choiceDescription" /><br />
+ <input t:type="textfield" t:id="choiceDescription" value="newChoice.description" />
+ <input t:type="submit" value="message:pollen.ui.choice.add.submit" />
</t:form>
</div>
</t:if>
- <!-- Ajout de commentaires -->
-
+ <!-- Ajout de commentaires -->
<h3>${message:comments}</h3>
<t:zone t:id="commentZone" show="show" update="show">
<div id="commentsDiv">
Modified: trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-ui/src/main/webapp/user/UserPollsCreated.tml 2010-03-23 11:15:12 UTC (rev 2955)
@@ -10,7 +10,7 @@
<t:grid t:id="pollsGrid" t:source="polls" t:row="poll" model="pollsModel" t:inPlace="true"
t:rowsPerPage="10" t:pagerPosition="bottom" t:rowClass="prop:evenodd.next">
<p:functionsCell>
- <t:PageLink t:page="poll/VoteForPoll" t:context="poll.pollId">
+ <t:PageLink t:page="poll/VoteForPoll" t:context="poll.pollUId">
<img src="${asset:context:img/vote.png}" title="${message:vote-help}" alt="${message:vote}" />
</t:PageLink>
<t:PageLink t:page="poll/results" t:context="adminId">
@@ -21,18 +21,18 @@
<t:PageLink t:page="poll/modification" t:context="adminId">
<img src="${asset:context:img/edit.png}" title="${message:edit-help}" alt="${message:edit}" />
</t:PageLink>
- <t:ActionLink t:id="close" t:context="poll.pollId">
+ <t:ActionLink t:id="close" t:context="poll.pollUId">
<img src="${asset:context:img/close.png}" title="${message:close-help}" alt="${message:close}" />
</t:ActionLink>
</t:unless>
- <t:ActionLink t:id="export" t:context="poll.pollId">
+ <t:ActionLink t:id="export" t:context="poll.pollUId">
<img src="${asset:context:img/export.png}" title="${message:export-help}" alt="${message:export}" />
</t:ActionLink>
- <t:PageLink t:page="poll/creation" t:context="poll.pollId">
+ <t:PageLink t:page="poll/creation" t:context="poll.pollUId">
<img src="${asset:context:img/copy.png}" title="${message:copy-help}" alt="${message:copy}" />
</t:PageLink>
- <t:ActionLink t:id="deletePoll" t:context="poll.pollId">
+ <t:ActionLink t:id="deletePoll" t:context="poll.pollUId">
<img src="${asset:context:img/delete.png}" title="${message:delete-help}" alt="${message:delete}" />
</t:ActionLink>
</p:functionsCell>
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -18,4 +18,16 @@
public enum ChoiceType {
TEXT, DATE, IMAGE;
+
+ public boolean isText() {
+ return this.equals(TEXT);
+ }
+
+ public boolean isDate() {
+ return this.equals(DATE);
+ }
+
+ public boolean isImage() {
+ return this.equals(IMAGE);
+ }
}
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -19,6 +19,22 @@
public enum PollType {
FREE, RESTRICTED, GROUP;
+ public boolean isFree() {
+ return this.equals(FREE);
+ }
+
+ public boolean isRestricted() {
+ return this.equals(RESTRICTED);
+ }
+
+ public boolean isGroup() {
+ return this.equals(GROUP);
+ }
+
+ public boolean isRestrictedOrGroup() {
+ return isRestricted() || isGroup();
+ }
+
public static boolean isGroupType(String value) {
return GROUP.name().equals(value);
}
Modified: trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/VoteCountingType.java
===================================================================
--- trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/VoteCountingType.java 2010-03-23 10:38:12 UTC (rev 2954)
+++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/VoteCountingType.java 2010-03-23 11:15:12 UTC (rev 2955)
@@ -18,4 +18,20 @@
public enum VoteCountingType {
NORMAL, PERCENTAGE, CONDORCET, NUMBER;
+
+ public boolean isNormal() {
+ return this.equals(NORMAL);
+ }
+
+ public boolean isPercentage() {
+ return this.equals(PERCENTAGE);
+ }
+
+ public boolean isCondorcet() {
+ return this.equals(CONDORCET);
+ }
+
+ public boolean isNumber() {
+ return this.equals(NUMBER);
+ }
}
1
0
r2954 - branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll
by echatellier@users.chorem.org 23 Mar '10
by echatellier@users.chorem.org 23 Mar '10
23 Mar '10
Author: echatellier
Date: 2010-03-23 11:38:12 +0100 (Tue, 23 Mar 2010)
New Revision: 2954
Log:
Fix vote count in mail notification
Modified:
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-20 18:42:04 UTC (rev 2953)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-23 10:38:12 UTC (rev 2954)
@@ -642,8 +642,8 @@
// Mail au créateur
data.put("to", poll.getCreatorEmail());
data.put("title", messages.format("voteEmail_subject", poll.getTitle()));
- data.put("msg", messages.format("voteEmail_msg", poll.getTitle(), poll
- .getVoteDTOs().size(), voteURL, modifURL));
+ data.put("msg", messages.format("voteEmail_msg", poll.getTitle(),
+ poll.getNbVotes(), voteURL, modifURL));
for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) {
PreventRuleManager manager = new PreventRuleManager(rule);
1
0
Author: fdesbois
Date: 2010-03-20 19:42:04 +0100 (Sat, 20 Mar 2010)
New Revision: 2953
Log:
- Improve context managment : no more static. Use inject in Tapestry
- Idem in PollenConverter use as a unique service managed by PollenContext
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImplementor.java
trunk/pollen-business/src/test/resources/log4j.properties
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.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/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/ServiceResultsImpl.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/main/java/org/chorem/pollen/business/utils/ContextUtil.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/scaling/ScalingVote.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.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/ServiceChoiceImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePreventRuleImplTest.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.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/FeedContextLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PropertiesFileSymbolProvider.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -3,27 +3,13 @@
import java.util.Date;
import java.util.Properties;
-import java.util.UUID;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.chorem.pollen.business.services.SendMail;
-import org.chorem.pollen.business.services.ServiceUserImpl;
-import org.nuiton.i18n.I18n;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.ArgumentsParserException;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-import org.nuiton.i18n.init.DefaultI18nInitializer;
/**
* PollenContext
*
- * Created: 24 févr. 2010
+ * Created: 20 mars 2010
*
* @author fdesbois
* @version $Revision$
@@ -31,45 +17,9 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class PollenContext {
+public interface PollenContext {
- /** log. */
- private static final Log log = LogFactory.getLog(PollenContext.class);
-
- public static final String DEFAULT_FILENAME = "pollen.properties";
-
- private static ApplicationConfig configuration;
-
- private static Date currentDate;
-
- private static SendMail sendMail;
-
/**
- * Default configuration file will be loaded using
- * {@link org.nuiton.util.ApplicationConfig }.
- * Then the other configuration initialization will be done in
- * {@link #loadConfiguration(ApplicationConfig)} method.
- */
- private static void loadDefaultConfiguration() {
- try {
- if (log.isInfoEnabled()) {
- log.info("load default configuration from " +
- PollenContext.DEFAULT_FILENAME);
- }
- ApplicationConfig conf = new ApplicationConfig();
- conf.setConfigFileName(PollenContext.DEFAULT_FILENAME);
- conf.parse(new String[]{});
-
- conf.printConfig();
-
- loadConfiguration(conf);
- } catch (ArgumentsParserException eee) {
- doCatch(eee, n_("pollen.error.context.parse"),
- PollenContext.DEFAULT_FILENAME);
- }
- }
-
- /**
* Load the application configuration :
* <pre>
* - Add entities implementation classes for Topia-persistence
@@ -78,13 +28,7 @@
*
* @param conf ApplicationConfig
*/
- public static void loadConfiguration(ApplicationConfig conf) {
- configuration = conf;
- configuration.setOption("topia.persistence.classes",
- PollenModelDAOHelper.getImplementationClassesAsString());
- configuration.setOption("topia.service.migration.version",
- PollenModelDAOHelper.getModelVersion());
- }
+ void loadConfiguration(ApplicationConfig conf);
/**
* Start of the application. The application configuration will be loaded
@@ -96,194 +40,51 @@
* - Initialize i18n for error messages
* - Create default admin if needed (this will load the topiaRootContext).
* </pre>
- *
+ *
*/
- public static void start() {
- try {
- if (log.isInfoEnabled()) {
- log.info("Initialize i18n bundle");
- }
- I18n.setInitializer(new DefaultI18nInitializer("pollen-business"));
- I18n.init();
+ void start();
- ServiceUserImpl serviceUser = new ServiceUserImpl();
- serviceUser.createDefaultAdmin(
- PollenProperty.ADMIN_LOGIN.getValue(),
- PollenProperty.ADMIN_PASSWORD.getValue(),
- PollenProperty.ADMIN_EMAIL.getValue()
- );
-
- sendMail = new SendMail();
- sendMail.start();
-
- if (log.isInfoEnabled()) {
- log.info("pollen is started !");
- }
-
- } catch (Exception eee) {
- doCatch(eee, n_("pollen.error.context.start"));
- }
- }
-
/**
* Stop the application. Close the Topia rootContext.
*/
- public static void stop() {
- try {
- getRootContext().closeContext();
- sendMail.stopExec();
- } catch (Exception eee) {
- doCatch(eee, n_("pollen.error.context.stop"));
- }
- }
+ void stop();
- public static SendMail getSendMail() {
- return sendMail;
- }
-
/**
- * Get a property from the configuration.
+ * Get the SendMail thread to manage emails.
*
- * @param property PollenProperty
- * @return value of this property
- * @
+ * @return the SendMail running thread
*/
- public static String getProperty(PollenProperty property) {
- return getConfiguration().getOption(property.getKey());
- }
+ SendMail getSendMail();
/**
* Get a property from the configuration.
*
- * @param key of the property
+ * @param property PollenProperty
* @return value of this property
- * @
*/
- public static String getProperty(String key) {
- return getConfiguration().getOption(key);
- }
+ String getProperty(PollenProperty property);
/**
- * Get all properties from the configuration
+ * Test if the property is defined in this context
*
- * @return the Properties of the application
- * @
+ * @param property PollenProperty
+ * @return value of this property
*/
- public static Properties getProperties() {
- return getConfiguration().getOptions();
- }
+ boolean hasProperty(PollenProperty property);
/**
- * Get the configuration of the application.
+ * Get the configuration of the application. Instantiate the default one
+ * if needed.
*
* @return the ApplicationConfig
- * @
*/
- public static ApplicationConfig getConfiguration() {
- if (configuration == null) {
- loadDefaultConfiguration();
- }
- return configuration;
- }
+ ApplicationConfig getConfiguration();
/**
- * Get the Topia rootContext.
+ * Return the current date from context
*
- * @return the main TopiaContext needed to begin new transaction
- * @
+ * @return a date
*/
- public static TopiaContext getRootContext() {
- try {
- return TopiaContextFactory.getContext(getProperties());
- } catch (TopiaNotFoundException eee) {
- doCatch(eee, n_("pollen.error.context.getRootContext"));
- }
- return null;
- }
+ Date getCurrentDate();
- /**
- * Manage exceptions. The {@code exception} will be embedded in a
- * PollenException with the {@code message} provided.
- * Used in catch statement in services.
- *
- * @param eee the exception to manage
- * @param message the message to add to the new PollenException
- * @param args for message
- * @throws PollenException which contains the exception as the cause
- */
- public static void doCatch(Exception eee, String message, Object... args) throws PollenException {
- doCatch(null, eee, message);
- }
-
- /**
- * Manage exceptions. The {@code exception} will be embedded in a
- * PollenException with the {@code message} provided. Also, the current
- * {@code transaction} will be rollback.
- * Used in catch statement in services.
- *
- * @param transaction the current TopiaContext
- * @param eee the exception to manage
- * @param message the message to add to the new PollenException
- * @param args for message
- * @throws PollenException
- */
- public static void doCatch(TopiaContext transaction, Exception eee, String message, Object... args) throws PollenException {
- if (log.isErrorEnabled()) {
- log.error(_(message, args), eee);
- }
-
- // rollback de la transaction courante
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error(_("pollen.error.context.rollback"), ex);
- }
- }
- }
- // PollenBusinessException must be managed (catch and throw) when needed
-// if (! (eee instanceof PollenBusinessException)) {
- throw new PollenException(eee, message, args);
-// }
- }
-
- /**
- * Close current TopiaContext.
- * Used in finally statement in services.
- *
- * @param transaction current TopiaContext
- */
- public static void doFinally(TopiaContext transaction) {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException eee) {
- if (log.isErrorEnabled()) {
- log.error(_("pollen.error.context.close"), eee);
- }
- }
- }
- }
-
- /**
- * Create an id to easily managed polls using urls.
- *
- * @return a fresh generated String
- */
- public static String createPollenUrlId() {
- return UUID.randomUUID().toString().replaceAll("-", "");
- }
-
- public static void setCurrentDate(Date currentDate) {
- PollenContext.currentDate = currentDate;
- }
-
- public static Date getCurrentDate() {
- if (currentDate == null) {
- currentDate = new Date();
- }
- return currentDate;
- }
-
}
Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImpl.java (from rev 2951, trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java)
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImpl.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -0,0 +1,342 @@
+
+package org.chorem.pollen.business;
+
+import java.util.Date;
+import java.util.Properties;
+import java.util.UUID;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
+import org.chorem.pollen.business.services.SendMail;
+import org.chorem.pollen.business.services.ServiceUserImpl;
+import org.nuiton.i18n.I18n;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+
+/**
+ * PollenContext
+ *
+ * Created: 24 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class PollenContextImpl implements PollenContextImplementor {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(PollenContextImpl.class);
+
+ public static final String DEFAULT_FILENAME = "pollen.properties";
+
+ private ApplicationConfig configuration;
+
+ private Date currentDate;
+
+ private SendMail sendMail;
+
+ /** Conversion service for services **/
+ private PollenConverter converter;
+
+ public PollenContextImpl() {
+
+ }
+
+ @Override
+ public void finalize() {
+ stop();
+ }
+
+ /**
+ * Default configuration file will be loaded using
+ * {@link org.nuiton.util.ApplicationConfig }.
+ * Then the other configuration initialization will be done in
+ * {@link #loadConfiguration(ApplicationConfig)} method.
+ */
+ private void loadDefaultConfiguration() {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("load default configuration from " +
+ PollenContextImpl.DEFAULT_FILENAME);
+ }
+ ApplicationConfig conf = new ApplicationConfig();
+ conf.setConfigFileName(PollenContextImpl.DEFAULT_FILENAME);
+ conf.parse(new String[]{});
+
+ conf.printConfig();
+
+ loadConfiguration(conf);
+ } catch (ArgumentsParserException eee) {
+ doCatch(eee, n_("pollen.error.context.parse"),
+ PollenContextImpl.DEFAULT_FILENAME);
+ }
+ }
+
+ /**
+ * Load the application configuration :
+ * <pre>
+ * - Add entities implementation classes for Topia-persistence
+ * - Add model version for Topia-migration-service
+ * </pre>
+ *
+ * @param conf ApplicationConfig
+ */
+ @Override
+ public void loadConfiguration(ApplicationConfig conf) {
+ configuration = conf;
+ configuration.setOption("topia.persistence.classes",
+ PollenModelDAOHelper.getImplementationClassesAsString());
+ configuration.setOption("topia.service.migration.version",
+ PollenModelDAOHelper.getModelVersion());
+ }
+
+ /**
+ * Start of the application. The application configuration will be loaded
+ * automatically if needed using {@link #loadDefaultConfiguration }. Also
+ * you can manually load the configuration using
+ * {@link #loadConfiguration(ApplicationConfig)}
+ * This start does :
+ * <pre>
+ * - Initialize i18n for error messages
+ * - Create default admin if needed (this will load the topiaRootContext).
+ * </pre>
+ *
+ */
+ @Override
+ public void start() {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Start Pollen");
+ log.info("Initialize i18n bundle");
+ }
+ I18n.setInitializer(new DefaultI18nInitializer("pollen-business"));
+ I18n.init();
+
+ ServiceUserImpl serviceUser = new ServiceUserImpl(this);
+ serviceUser.createDefaultAdmin(
+ getProperty(PollenProperty.ADMIN_LOGIN),
+ getProperty(PollenProperty.ADMIN_PASSWORD),
+ getProperty(PollenProperty.ADMIN_EMAIL)
+ );
+
+ sendMail = new SendMail(this);
+ sendMail.start();
+
+ if (log.isInfoEnabled()) {
+ log.info("pollen is started !");
+ }
+
+ } catch (Exception eee) {
+ doCatch(eee, n_("pollen.error.context.start"));
+ }
+ }
+
+ /**
+ * Stop the application. Close the Topia rootContext.
+ */
+ @Override
+ public void stop() {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Stop Pollen");
+ }
+ getRootContext().closeContext();
+ sendMail.stopExec();
+ } catch (Exception eee) {
+ doCatch(eee, n_("pollen.error.context.stop"));
+ }
+ }
+
+ @Override
+ public SendMail getSendMail() {
+ return sendMail;
+ }
+
+ /**
+ * Get a property from the configuration.
+ *
+ * @param property PollenProperty
+ * @return value of this property
+ */
+ @Override
+ public String getProperty(PollenProperty property) {
+ return getConfiguration().getOption(property.getKey());
+ }
+
+ /**
+ * Test if the property is defined in this context
+ *
+ * @param property PollenProperty
+ * @return value of this property
+ */
+ @Override
+ public boolean hasProperty(PollenProperty property) {
+ return !getProperty(property).equals("");
+ }
+
+ /**
+ * Get a property from the configuration.
+ *
+ * @param key of the property
+ * @return value of this property
+ */
+ public String getProperty(String key) {
+ return getConfiguration().getOption(key);
+ }
+
+ /**
+ * Get all properties from the configuration
+ *
+ * @return the Properties of the application
+ */
+ public Properties getProperties() {
+ return getConfiguration().getOptions();
+ }
+
+ /**
+ * Get the configuration of the application.
+ *
+ * @return the ApplicationConfig
+ */
+ @Override
+ public ApplicationConfig getConfiguration() {
+ if (configuration == null) {
+ loadDefaultConfiguration();
+ }
+ return configuration;
+ }
+
+ /**
+ * Get the Topia rootContext.
+ *
+ * @return the main TopiaContext needed to begin new transaction
+ */
+ @Override
+ public TopiaContext getRootContext() {
+ try {
+ return TopiaContextFactory.getContext(getProperties());
+ } catch (TopiaNotFoundException eee) {
+ doCatch(eee, n_("pollen.error.context.getRootContext"));
+ }
+ return null;
+ }
+
+ @Override
+ public PollenConverter getConverter() {
+ if (converter == null) {
+ converter = new PollenConverter();
+ }
+ return converter;
+ }
+
+ /**
+ * Manage exceptions. The {@code exception} will be embedded in a
+ * PollenException with the {@code message} provided.
+ * Used in catch statement in services.
+ *
+ * @param eee the exception to manage
+ * @param message the message to add to the new PollenException
+ * @param args for message
+ * @throws PollenException which contains the exception as the cause
+ */
+ @Override
+ public void doCatch(Exception eee, String message, Object... args)
+ throws PollenException {
+ doCatch(null, eee, message);
+ }
+
+ /**
+ * Manage exceptions. The {@code exception} will be embedded in a
+ * PollenException with the {@code message} provided. Also, the current
+ * {@code transaction} will be rollback.
+ * Used in catch statement in services.
+ *
+ * @param transaction the current TopiaContext
+ * @param eee the exception to manage
+ * @param message the message to add to the new PollenException
+ * @param args for message
+ * @throws PollenException
+ */
+ @Override
+ public void doCatch(TopiaContext transaction, Exception eee, String message,
+ Object... args) throws PollenException {
+ if (log.isErrorEnabled()) {
+ log.error(_(message, args), eee);
+ }
+
+ // rollback de la transaction courante
+ if (transaction != null) {
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error(_("pollen.error.context.rollback"), ex);
+ }
+ }
+ }
+ // PollenBusinessException must be managed (catch and throw) when needed
+// if (! (eee instanceof PollenBusinessException)) {
+ throw new PollenException(eee, message, args);
+// }
+ }
+
+ /**
+ * Close current TopiaContext.
+ * Used in finally statement in services.
+ *
+ * @param transaction current TopiaContext
+ */
+ @Override
+ public void doFinally(TopiaContext transaction) {
+ if (transaction != null) {
+ try {
+ transaction.closeContext();
+ } catch (TopiaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error(_("pollen.error.context.close"), eee);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create an id to easily managed polls using urls.
+ *
+ * @return a fresh generated String
+ */
+ @Override
+ public String createPollenUrlId() {
+ return UUID.randomUUID().toString().replaceAll("-", "");
+ }
+
+// public void setCurrentDate(Date currentDate) {
+// PollenContextBusiness.currentDate = currentDate;
+// }
+
+ @Override
+ public Date getCurrentDate() {
+ if (currentDate == null) {
+ currentDate = new Date();
+ }
+ return currentDate;
+ }
+
+ /**
+ * Set the current date in context. Used for test
+ *
+ * @param currentDate to set in the context
+ */
+ public void setCurrentDate(Date currentDate) {
+ this.currentDate = currentDate;
+ }
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Added: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImplementor.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImplementor.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImplementor.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -0,0 +1,78 @@
+
+package org.chorem.pollen.business;
+
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * PollenContextImplementor
+ *
+ * Created: 20 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public interface PollenContextImplementor extends PollenContext {
+
+ /**
+ * Topia main context used to open new transaction.
+ *
+ * @return the topia root context
+ */
+ TopiaContext getRootContext();
+
+ /**
+ * Pollen converter used to convert entities to DTO.
+ *
+ * @return the current pollen converter
+ */
+ PollenConverter getConverter();
+
+ /**
+ * Manage exceptions. The {@code exception} will be embedded in a
+ * PollenException with the {@code message} provided.
+ * Used in catch statement in services.
+ *
+ * @param eee the exception to manage
+ * @param message the message to add to the new PollenException
+ * @param args for message
+ * @throws PollenException which contains the exception as the cause
+ */
+ void doCatch(Exception eee, String message, Object... args)
+ throws PollenException;
+
+ /**
+ * Manage exceptions. The {@code exception} will be embedded in a
+ * PollenException with the {@code message} provided. Also, the current
+ * {@code transaction} will be rollback.
+ * Used in catch statement in services.
+ *
+ * @param transaction the current TopiaContext
+ * @param eee the exception to manage
+ * @param message the message to add to the new PollenException
+ * @param args for message
+ * @throws PollenException
+ */
+ void doCatch(TopiaContext transaction, Exception eee, String message,
+ Object... args) throws PollenException;
+
+ /**
+ * Close current TopiaContext.
+ * Used in finally statement in services.
+ *
+ * @param transaction current TopiaContext
+ */
+ void doFinally(TopiaContext transaction);
+
+ /**
+ * Create a unique UId for entities which need it (PollAccount, Poll).
+ * This UId represent the entity in UI module.
+ *
+ * @return a new pollenUrlId (UId)
+ */
+ String createPollenUrlId();
+
+
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContextImplementor.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -1,6 +1,8 @@
package org.chorem.pollen.business;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -28,7 +30,7 @@
import org.nuiton.util.beans.BinderProvider;
/**
- * ConverterFactory
+ * PollenConverter
*
* Created: 22 févr. 2010
*
@@ -42,9 +44,22 @@
private static final Log log = LogFactory.getLog(PollenConverter.class);
- private static BinderBuilder builder = new BinderBuilder();
+ private BinderBuilder builder;
- private static final void prepare(Class<? extends TopiaEntity> entityClass, Class<?> dtoClass, String... properties) {
+ private List<Class<? extends TopiaEntity>> prepareLoaded;
+
+ public PollenConverter() {
+ builder = new BinderBuilder();
+ prepareLoaded = new ArrayList<Class<? extends TopiaEntity>>();
+ }
+
+ private final void prepare(Class<? extends TopiaEntity> entityClass,
+ Class<?> dtoClass, String... properties) {
+
+ if (prepareLoaded.contains(entityClass)) {
+ return;
+ }
+
// Binder DTO -> Entity
builder.createBinderModel(dtoClass, entityClass).
addSimpleProperties(properties);
@@ -57,9 +72,11 @@
//builder.addProperty(TopiaEntity.TOPIA_ID, "id");
BinderProvider.registerBinder(builder);
+
+ prepareLoaded.add(entityClass);
}
- public static void preparePollConverters() {
+ public void preparePollConverters() {
String[] properties = new String[] {
Poll.TITLE,
Poll.DESCRIPTION,
@@ -79,7 +96,7 @@
prepare(Poll.class, PollDTO.class, properties);
}
- public static void prepareChoiceConverters() {
+ public void prepareChoiceConverters() {
String[] properties = new String[] {
Choice.NAME,
Choice.DESCRIPTION,
@@ -89,7 +106,7 @@
prepare(Choice.class, ChoiceDTO.class, properties);
}
- public static void prepareVotingListConverters() {
+ public void prepareVotingListConverters() {
String[] properties = new String[] {
VotingList.NAME,
VotingList.WEIGHT
@@ -98,7 +115,7 @@
prepare(VotingList.class, VotingListDTO.class, properties);
}
- public static void preparePollAccountConverters() {
+ public void preparePollAccountConverters() {
String[] properties = new String[] {
PollAccount.VOTING_ID,
PollAccount.EMAIL
@@ -107,7 +124,7 @@
prepare(PollAccount.class, PollAccountDTO.class, properties);
}
- public static void preparePreventRuleConverters() {
+ public void preparePreventRuleConverters() {
String[] properties = new String[] {
PreventRule.ACTIVE,
PreventRule.METHOD,
@@ -120,7 +137,7 @@
prepare(PreventRule.class, PreventRuleDTO.class, properties);
}
- public static void prepareVoteConverters() {
+ public void prepareVoteConverters() {
String[] properties = new String[] {
Vote.WEIGHT,
Vote.COMMENT,
@@ -130,7 +147,7 @@
prepare(Vote.class, VoteDTO.class, properties);
}
- public static void prepareCommentConverters() {
+ public void prepareCommentConverters() {
String[] properties = new String[] {
Comment.TEXT,
Comment.POST_DATE,
@@ -140,13 +157,15 @@
prepare(Comment.class, CommentDTO.class, properties);
}
- public static Choice convert(ChoiceDTO dto, Choice entity) {
- BinderProvider.getBinder(ChoiceDTO.class, Choice.class).copy(dto, entity);
+ public Choice convert(ChoiceDTO dto, Choice entity) {
+ BinderProvider.getBinder(
+ ChoiceDTO.class, Choice.class).copy(dto, entity);
return entity;
}
- public static ChoiceDTO convert(Choice entity, ChoiceDTO dto) {
- BinderProvider.getBinder(Choice.class, ChoiceDTO.class).copy(entity, dto);
+ public ChoiceDTO convert(Choice entity, ChoiceDTO dto) {
+ BinderProvider.getBinder(
+ Choice.class, ChoiceDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
String name = entity.getName();
dto.setHidden(name != null
@@ -155,7 +174,7 @@
return dto;
}
- public static Poll convert(PollDTO dto, Poll entity) {
+ public Poll convert(PollDTO dto, Poll entity) {
BinderProvider.getBinder(PollDTO.class, Poll.class).copy(dto, entity);
entity.setChoiceType(dto.getChoiceType().name());
entity.setPollType(dto.getPollType().name());
@@ -163,7 +182,7 @@
return entity;
}
- public static PollDTO convert(Poll entity, PollDTO dto) {
+ public PollDTO convert(Poll entity, PollDTO dto) {
BinderProvider.getBinder(Poll.class, PollDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
dto.setPollUId(entity.getPollId());
@@ -182,43 +201,49 @@
return dto;
}
- public static VotingList convert(VotingListDTO dto, VotingList entity) {
- BinderProvider.getBinder(VotingListDTO.class, VotingList.class).copy(dto, entity);
+ public VotingList convert(VotingListDTO dto, VotingList entity) {
+ BinderProvider.getBinder(
+ VotingListDTO.class, VotingList.class).copy(dto, entity);
return entity;
}
- public static VotingListDTO convert(VotingList entity, VotingListDTO dto) {
- BinderProvider.getBinder(VotingList.class, VotingListDTO.class).copy(entity, dto);
+ public VotingListDTO convert(VotingList entity, VotingListDTO dto) {
+ BinderProvider.getBinder(
+ VotingList.class, VotingListDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
return dto;
}
- public static PollAccount convert(PollAccountDTO dto, PollAccount entity) {
- BinderProvider.getBinder(PollAccountDTO.class, PollAccount.class).copy(dto, entity);
+ public PollAccount convert(PollAccountDTO dto, PollAccount entity) {
+ BinderProvider.getBinder(
+ PollAccountDTO.class, PollAccount.class).copy(dto, entity);
return entity;
}
- public static PollAccountDTO convert(PollAccount entity, PollAccountDTO dto) {
- BinderProvider.getBinder(PollAccount.class, PollAccountDTO.class).copy(entity, dto);
+ public PollAccountDTO convert(PollAccount entity, PollAccountDTO dto) {
+ BinderProvider.getBinder(
+ PollAccount.class, PollAccountDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
dto.setAccountId(entity.getAccountId());
return dto;
}
- public static PreventRule convert(PreventRuleDTO dto, PreventRule entity) {
- BinderProvider.getBinder(PreventRuleDTO.class, PreventRule.class).copy(dto, entity);
+ public PreventRule convert(PreventRuleDTO dto, PreventRule entity) {
+ BinderProvider.getBinder(
+ PreventRuleDTO.class, PreventRule.class).copy(dto, entity);
return entity;
}
- public static PreventRuleDTO convert(PreventRule entity, PreventRuleDTO dto) {
- BinderProvider.getBinder(PreventRule.class, PreventRuleDTO.class).copy(entity, dto);
+ public PreventRuleDTO convert(PreventRule entity, PreventRuleDTO dto) {
+ BinderProvider.getBinder(
+ PreventRule.class, PreventRuleDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
Poll poll = entity.getPoll();
dto.setPollId(poll.getTopiaId());
return dto;
}
- public static Vote convert(VoteDTO dto, Vote entity) {
+ public Vote convert(VoteDTO dto, Vote entity) {
BinderProvider.getBinder(VoteDTO.class, Vote.class).copy(dto, entity);
return entity;
}
@@ -234,7 +259,7 @@
* @param dto VoteDTO
* @return VoteDTO
*/
- public static VoteDTO convert(Vote entity, VoteDTO dto) {
+ public VoteDTO convert(Vote entity, VoteDTO dto) {
BinderProvider.getBinder(Vote.class, VoteDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
Poll poll = entity.getPoll();
@@ -268,13 +293,15 @@
return dto;
}
- public static Comment convert(CommentDTO dto, Comment entity) {
- BinderProvider.getBinder(CommentDTO.class, Comment.class).copy(dto, entity);
+ public Comment convert(CommentDTO dto, Comment entity) {
+ BinderProvider.getBinder(
+ CommentDTO.class, Comment.class).copy(dto, entity);
return entity;
}
- public static CommentDTO convert(Comment entity, CommentDTO dto) {
- BinderProvider.getBinder(Comment.class, CommentDTO.class).copy(entity, dto);
+ public CommentDTO convert(Comment entity, CommentDTO dto) {
+ BinderProvider.getBinder(
+ Comment.class, CommentDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
return dto;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -50,11 +50,11 @@
return key;
}
- public String getValue() {
- return PollenContext.getProperty(this);
- }
+// public String getValue() {
+// return PollenContexImpl.getProperty(this);
+// }
- public boolean hasValue() {
- return !getValue().equals("");
- }
+// public boolean hasValue() {
+// return !getValue().equals("");
+// }
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.PollenBusinessException;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.dto.CommentDTO;
import org.chorem.pollen.business.dto.PollDTO;
@@ -61,8 +62,8 @@
* @deprecated use {@link ConverterHelper}
*/
@Deprecated
- public PollDTO createPollDTO(Poll ePoll) {
- PollDTO pollDTO = PollenConverter.convert(ePoll, new PollDTO());
+ public PollDTO createPollDTO(Poll ePoll, PollenConverter converter) {
+ PollDTO pollDTO = converter.convert(ePoll, new PollDTO());
// pollDTO.setId(ePoll.getTopiaId());
// pollDTO.setPollId(ePoll.getPollId());
@@ -96,7 +97,7 @@
// }
for (Comment comment : ePoll.getComment()) {
CommentDTO dto =
- PollenConverter.convert(comment, new CommentDTO());
+ converter.convert(comment, new CommentDTO());
pollDTO.addComment(dto);
}
// if (ePoll.getComment().size() > 0) {
@@ -119,15 +120,16 @@
* Retourne une liste de dtos sondage à partir d'une liste d'entités.
*
* @param lPolls liste de entités sondages
+ * @param converter
* @return la liste des dtos sondages
* @deprecated use {@link ConverterHelper}
*/
@Deprecated
- public List<PollDTO> createPollDTOs(List<Poll> lPolls) {
+ public List<PollDTO> createPollDTOs(List<Poll> lPolls, PollenConverter converter) {
ArrayList<PollDTO> results = new ArrayList<PollDTO>();
PollDTO dto;
for (Poll p : lPolls) {
- dto = this.createPollDTO(p);
+ dto = this.createPollDTO(p, converter);
results.add(dto);
}
return results;
@@ -141,11 +143,11 @@
* @deprecated use dao managment instead
*/
@Deprecated
- public void persistChoices(PollDTO pollDTO, Poll ePoll)
+ public void persistChoices(PollDTO pollDTO, Poll ePoll, PollenContextImplementor context)
throws TopiaException, PollenBusinessException {
// mise à jour ou création des choix
- ServiceChoice sChoice = new ServiceChoiceImpl();
+ ServiceChoice sChoice = new ServiceChoiceImpl(context);
for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
boolean updated = sChoice.updateChoice(choiceDTO);
if (!updated) {
@@ -182,11 +184,11 @@
* @param pollDTO le dto sondage
* @param ePoll l'entité sondage
*/
- public void persistPreventRules(PollDTO pollDTO, Poll ePoll)
+ public void persistPreventRules(PollDTO pollDTO, Poll ePoll, PollenContextImplementor context)
throws TopiaException, PollenBusinessException {
// mise à jour ou création des règles de notification
- ServicePreventRule sPreventRule = new ServicePreventRuleImpl();
+ ServicePreventRule sPreventRule = new ServicePreventRuleImpl(context);
for (PreventRuleDTO preventRuleDTO : pollDTO.getPreventRuleDTOs()) {
boolean updated = sPreventRule.updatePreventRule(preventRuleDTO);
if (!updated) {
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -37,6 +37,7 @@
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
import org.apache.commons.io.IOUtils;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.PollenProperty;
/**
@@ -63,6 +64,8 @@
/** logger. */
private static final Logger log = LoggerFactory.getLogger(SendMail.class);
+ protected PollenContextImplementor context;
+
public static final String EXTENSION_MAIL = ".mail";
public static final String EXTENSION_INDEX = ".index";
@@ -71,11 +74,14 @@
protected volatile boolean stop;
- public SendMail() {
-
+ public SendMail(PollenContextImplementor context) {
+ this.context = context;
+ if (log.isInfoEnabled()) {
+ log.info("P:[ SendMail ] init");
+ }
// get email directory in configuration
// create it if not exists
- String filename = PollenProperty.EMAIL_DIR.getValue();
+ String filename = context.getProperty(PollenProperty.EMAIL_DIR);
mailStorageDirectory = new File(filename);
if (!mailStorageDirectory.exists()) {
if (mailStorageDirectory.mkdirs()) {
@@ -95,6 +101,9 @@
*/
@Override
public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("P:[ SendMail ] start");
+ }
// try to find existing files
while (!stop) {
@@ -162,10 +171,12 @@
// index contains next index to treat so == is ok
if (currentIndex >= index) {
- String host = PollenProperty.EMAIL_HOST.getValue();
+ String host =
+ context.getProperty(PollenProperty.EMAIL_HOST);
int port = Integer.parseInt(
- PollenProperty.EMAIL_PORT.getValue());
- String from = PollenProperty.EMAIL_FROM.getValue();
+ context.getProperty(PollenProperty.EMAIL_PORT));
+ String from =
+ context.getProperty(PollenProperty.EMAIL_FROM);
MailUtil.sendMail(host, port, from,
receiver, subject, body);
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceAuthImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -18,8 +18,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataUserConverter;
import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
@@ -37,15 +37,15 @@
*/
public class ServiceAuthImpl implements ServiceAuth {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private UserAccountDAO userDAO = null;
private DataUserConverter converter = new DataUserConverter();
/** log. */
private static final Log log = LogFactory.getLog(ServiceAuthImpl.class);
- public ServiceAuthImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServiceAuthImpl(PollenContextImplementor context) {
+ this.context = context;
}
@Override
@@ -53,7 +53,7 @@
TopiaContext transaction = null;
boolean result = false;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -84,7 +84,7 @@
TopiaContext transaction = null;
UserDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -16,15 +16,14 @@
package org.chorem.pollen.business.services;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataChoiceConverter;
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.persistence.Choice;
@@ -41,15 +40,15 @@
*/
public class ServiceChoiceImpl implements ServiceChoice {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private ChoiceDAO choiceDAO = null;
private DataChoiceConverter converter = new DataChoiceConverter();
/** log. */
private static final Log log = LogFactory.getLog(ServiceChoiceImpl.class);
- public ServiceChoiceImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServiceChoiceImpl(PollenContextImplementor context) {
+ this.context = context;
}
@Override
@@ -57,7 +56,7 @@
TopiaContext transaction = null;
String topiaId = "";
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
@@ -114,7 +113,7 @@
TopiaContext transaction = null;
boolean resu = false;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
@@ -145,7 +144,7 @@
public boolean deleteChoice(String choiceId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
@@ -172,7 +171,7 @@
TopiaContext transaction = null;
ChoiceDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
@@ -205,7 +204,7 @@
List<ChoiceDTO> results = null;
List<Choice> choiceEntities = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
@@ -240,7 +239,7 @@
List<ChoiceDTO> results = null;
List<Choice> choiceEntities = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -18,12 +18,10 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContext;
-import org.chorem.pollen.business.PollenConverter;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPersonListConverter;
import org.chorem.pollen.business.converters.DataVotingListConverter;
import org.chorem.pollen.business.dto.PersonListDTO;
@@ -51,7 +49,7 @@
*/
public class ServiceListImpl implements ServiceList {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private VotingListDAO votingListDAO = null;
private PersonListDAO personListDAO = null;
private DataVotingListConverter votingListConverter = new DataVotingListConverter();
@@ -60,11 +58,11 @@
/** log. */
private static final Log log = LogFactory.getLog(ServiceListImpl.class);
- public ServiceListImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServiceListImpl(PollenContextImplementor context) {
+ this.context = context;
- PollenConverter.preparePollAccountConverters();
- PollenConverter.prepareVotingListConverters();
+ context.getConverter().preparePollAccountConverters();
+ context.getConverter().prepareVotingListConverters();
}
@Override
@@ -72,7 +70,7 @@
TopiaContext transaction = null;
String topiaId = "";
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
@@ -84,7 +82,7 @@
// Création des pollAccount de la liste si nécessaire
// FIXME do not call a Service from an other one
- ServicePollAccount spa = new ServicePollAccountImpl();
+ ServicePollAccount spa = new ServicePollAccountImpl(context);
//spa.createPollAccounts(votingList.getPollAccountDTOs(), transaction);
for (PollAccountDTO account : votingList.getPollAccountDTOs()) {
if (spa.findPollAccountById(account.getId()) == null) {
@@ -117,7 +115,7 @@
public boolean updateVotingList(VotingListDTO votingList) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction);
@@ -147,7 +145,7 @@
TopiaContext transaction = null;
String topiaId = "";
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
PersonList entity = personListDAO.create();
@@ -157,7 +155,7 @@
// Création des comptes de la liste
// FIXME do not call a Service from an other one
- ServicePollAccount spa = new ServicePollAccountImpl();
+ ServicePollAccount spa = new ServicePollAccountImpl(context);
for (PollAccountDTO account : personList.getPollAccounts()) {
account.setPersonListId(entity.getTopiaId());
}
@@ -185,7 +183,7 @@
public void createAccountInPersonList(PersonListDTO personList, PollAccountDTO account) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
@@ -195,9 +193,9 @@
PollenModelDAOHelper.getPollAccountDAO(transaction);
// Create new pollAccount
- String accountUID = PollenContext.createPollenUrlId();
+ String accountUID = context.createPollenUrlId();
PollAccount eAccount = accountDAO.create(accountUID);
- PollenConverter.convert(account, eAccount);
+ context.getConverter().convert(account, eAccount);
// Add the account into the list
eList.addPollAccount(eAccount);
@@ -210,11 +208,11 @@
personList.addPollAccount(account);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.serviceList.createAccountForPersonList"),
personList.getName(), account.getVotingId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -222,7 +220,7 @@
public void deleteAccountFromPersonList(PersonListDTO personList, String accountId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// Find the account
PollAccountDAO accountDAO =
@@ -245,11 +243,11 @@
personList.removePollAccount(accountId);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.serviceList.deleteAccountFromPersonList"),
accountId, personList.getName(), personList.getId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -257,7 +255,7 @@
public boolean deletePersonList(String personListId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
@@ -285,7 +283,7 @@
List<PersonList> personListEntities = null;
UserAccountDAO userDAO = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
UserAccount user = userDAO.findByTopiaId(userId);
@@ -320,7 +318,7 @@
TopiaContext transaction = null;
PersonListDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction);
@@ -356,7 +354,7 @@
List<PersonList> personListEntities = null;
UserAccountDAO userDAO = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
UserAccount user = userDAO.findByTopiaId(userId);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -22,10 +22,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPollAccountConverter;
import org.chorem.pollen.business.dto.PollAccountDTO;
-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;
@@ -41,7 +41,7 @@
*/
public class ServicePollAccountImpl implements ServicePollAccount {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private PollAccountDAO pollAccountDAO = null;
private DataPollAccountConverter converter = new DataPollAccountConverter();
@@ -49,8 +49,8 @@
private static final Log log = LogFactory
.getLog(ServicePollAccountImpl.class);
- public ServicePollAccountImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServicePollAccountImpl(PollenContextImplementor context) {
+ this.context = context;
}
@Override
@@ -58,7 +58,7 @@
TopiaContext transaction = null;
String topiaId;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollAccountDAO = PollenModelDAOHelper
.getPollAccountDAO(transaction);
@@ -123,7 +123,7 @@
public boolean deletePollAccount(String pollAccountId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollAccountDAO = PollenModelDAOHelper
.getPollAccountDAO(transaction);
@@ -150,7 +150,7 @@
TopiaContext transaction = null;
boolean resu = false;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollAccountDAO = PollenModelDAOHelper
.getPollAccountDAO(transaction);
@@ -185,7 +185,7 @@
TopiaContext transaction = null;
PollAccountDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollAccountDAO = PollenModelDAOHelper
.getPollAccountDAO(transaction);
@@ -219,7 +219,7 @@
TopiaContext transaction = null;
PollAccountDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollAccountDAO = PollenModelDAOHelper
.getPollAccountDAO(transaction);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -25,7 +25,6 @@
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenConverter;
import org.chorem.pollen.business.converters.DataPollConverter;
import org.chorem.pollen.business.converters.DataVotingListConverter;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -52,7 +51,8 @@
import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
@@ -73,22 +73,22 @@
*/
public class ServicePollImpl implements ServicePoll {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private PollDAO pollDAO = null;
private DataPollConverter converter = new DataPollConverter();
/** log. */
private static final Log log = LogFactory.getLog(ServicePollImpl.class);
- public ServicePollImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServicePollImpl(PollenContextImplementor context) {
+ this.context = context;
- PollenConverter.preparePollConverters();
- PollenConverter.prepareChoiceConverters();
- PollenConverter.prepareVotingListConverters();
- PollenConverter.preparePollAccountConverters();
- PollenConverter.preparePreventRuleConverters();
- PollenConverter.prepareVoteConverters();
- PollenConverter.prepareCommentConverters();
+ context.getConverter().preparePollConverters();
+ context.getConverter().prepareChoiceConverters();
+ context.getConverter().prepareVotingListConverters();
+ context.getConverter().preparePollAccountConverters();
+ context.getConverter().preparePreventRuleConverters();
+ context.getConverter().prepareVoteConverters();
+ context.getConverter().prepareCommentConverters();
}
@Override
@@ -101,14 +101,14 @@
log.info("P:[ createPoll ] : " + pollDTO);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
// Create with the pollId from dto
String pollId = pollDTO.getPollUId();
Poll entity = pollDAO.create(pollId);
- PollenConverter.convert(pollDTO, entity);
+ context.getConverter().convert(pollDTO, entity);
// ** Manage the poll creator
PollAccount creator = prepareCreator(transaction, pollDTO);
@@ -118,7 +118,7 @@
ChoiceDAO choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
Choice choice =
- PollenConverter.convert(choiceDTO, choiceDAO.create());
+ context.getConverter().convert(choiceDTO, choiceDAO.create());
choice.setPoll(entity);
}
@@ -133,7 +133,7 @@
PollenModelDAOHelper.getPreventRuleDAO(transaction);
for (PreventRuleDTO ruleDTO : pollDTO.getPreventRuleDTOs()) {
PreventRule rule =
- PollenConverter.convert(ruleDTO, ruleDAO.create());
+ context.getConverter().convert(ruleDTO, ruleDAO.create());
rule.setPoll(entity);
}
@@ -148,14 +148,14 @@
// Update dto : need creator and id update
// WARN : Update for choices, preventRules and
// votingLists is not needed in this case
- PollenConverter.convert(entity, pollDTO);
+ context.getConverter().convert(entity, pollDTO);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.createPoll"),
pollDTO.getTitle(), pollDTO.getCreatorId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
return result;
}
@@ -172,7 +172,7 @@
* @return the PollAccount used as creator for this poll
* @throws TopiaException
*/
- private static final PollAccount prepareCreator(TopiaContext transaction,
+ private final PollAccount prepareCreator(TopiaContext transaction,
PollDTO poll) throws TopiaException {
// Search user from database
@@ -196,7 +196,7 @@
// Create new account if account properties changed or no user found
if (creator == null) {
accountProperties.put(
- PollAccount.ACCOUNT_ID, PollenContext.createPollenUrlId());
+ PollAccount.ACCOUNT_ID, context.createPollenUrlId());
creator = accountDAO.create(accountProperties);
}
return creator;
@@ -213,12 +213,12 @@
* @return VotingList entity created
* @throws TopiaException
*/
- private static final VotingList createVotingList(TopiaContext transaction,
+ private final VotingList createVotingList(TopiaContext transaction,
VotingListDTO listDTO) throws TopiaException {
VotingListDAO dao = PollenModelDAOHelper.getVotingListDAO(transaction);
VotingList votingList =
- PollenConverter.convert(listDTO, dao.create());
+ context.getConverter().convert(listDTO, dao.create());
PollAccountDAO pollAccountDAO =
PollenModelDAOHelper.getPollAccountDAO(transaction);
@@ -230,9 +230,9 @@
// Create a new PollAccount if not already exists
if (account == null) {
- String accountId = PollenContext.createPollenUrlId();
+ String accountId = context.createPollenUrlId();
account = pollAccountDAO.create(accountId);
- PollenConverter.convert(accountDTO, account);
+ context.getConverter().convert(accountDTO, account);
}
// Create association between VotingList and PollAccount
@@ -254,26 +254,26 @@
log.info("P:[ updatePoll ] : " + pollDTO);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
Poll pollEntity = pollDAO.findByTopiaId(pollDTO.getId());
- PollenConverter.convert(pollDTO, pollEntity);
+ context.getConverter().convert(pollDTO, pollEntity);
ChoiceDAO choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
// ** Update choices (no add, no remove)
for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
Choice choice = choiceDAO.findByTopiaId(choiceDTO.getId());
- PollenConverter.convert(choiceDTO, choice);
+ context.getConverter().convert(choiceDTO, choice);
choice.update();
}
// Les règles de notifications restent mystérieuses
// Y a t-il un besoin de suppression ?
- converter.persistPreventRules(pollDTO, pollEntity);
+ converter.persistPreventRules(pollDTO, pollEntity, context);
pollDAO.update(pollEntity);
@@ -285,12 +285,12 @@
return true;
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.updatePoll"),
pollDTO.getTitle(), pollDTO.getPollUId());
return false;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -299,7 +299,7 @@
PollDTO newPoll = new PollDTO();
newPoll.setVoteCounting(VoteCountingType.NORMAL);
newPoll.setPollType(PollType.FREE);
- newPoll.setPollUId(PollenContext.createPollenUrlId());
+ newPoll.setPollUId(context.createPollenUrlId());
return newPoll;
}
@@ -318,7 +318,7 @@
log.info("P:[ deletePoll ] : pollId = " + pollId);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
@@ -333,11 +333,11 @@
return true;
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.deletePoll"), pollId);
return false;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -350,19 +350,19 @@
log.info("P:[ getPoll ] : pollUId = " + pollId);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
Poll pollEntity = pollDAO.findByPollId(pollId);
if (pollEntity != null) {
- result = PollenConverter.convert(pollEntity, new PollDTO());
+ result = context.getConverter().convert(pollEntity, new PollDTO());
// Load choices
for (Choice choice : pollEntity.getChoice()) {
ChoiceDTO dto =
- PollenConverter.convert(choice, new ChoiceDTO());
+ context.getConverter().convert(choice, new ChoiceDTO());
result.addChoice(dto);
}
@@ -387,21 +387,21 @@
// Load votes
// for (Vote vote : pollEntity.getVote()) {
// VoteDTO dto =
-// PollenConverter.convert(vote, new VoteDTO());
+// context.getConverter().convert(vote, new VoteDTO());
// result.addVote(dto);
// }
// Load comments
// for (Comment comment : pollEntity.getComment()) {
// CommentDTO dto =
-// PollenConverter.convert(comment, new CommentDTO());
+// context.getConverter().convert(comment, new CommentDTO());
// result.addComment(dto);
// }
// Load preventRules
for (PreventRule rule : pollEntity.getPreventRule()) {
PreventRuleDTO dto =
- PollenConverter.convert(rule, new PreventRuleDTO());
+ context.getConverter().convert(rule, new PreventRuleDTO());
result.addPreventRule(dto);
}
@@ -420,11 +420,11 @@
return result;
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.getPoll"), pollId);
return null;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -434,7 +434,7 @@
List<PollDTO> results = null;
UserAccountDAO userDAO = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
UserAccount user = userDAO.findByTopiaId(userId);
@@ -445,7 +445,8 @@
}
converter.setTransaction(transaction);
- results = converter.createPollDTOs(pollEntities);
+ results = converter.createPollDTOs(pollEntities,
+ context.getConverter());
transaction.commitTransaction();
@@ -458,7 +459,7 @@
ContextUtil.doCatch(e, transaction);
return null;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -468,7 +469,7 @@
List<PollDTO> results = null;
UserAccountDAO userDAO = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
UserAccount user = userDAO.findByTopiaId(userId);
@@ -481,7 +482,8 @@
}
converter.setTransaction(transaction);
- results = converter.createPollDTOs(new ArrayList<Poll>(pollEntities));
+ results = converter.createPollDTOs(
+ new ArrayList<Poll>(pollEntities), context.getConverter());
transaction.commitTransaction();
@@ -494,7 +496,7 @@
ContextUtil.doCatch(e, transaction);
return null;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -504,7 +506,7 @@
List<PollDTO> results = null;
UserAccountDAO userDAO = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
UserAccount user = userDAO.findByTopiaId(userId);
@@ -528,7 +530,9 @@
}
converter.setTransaction(transaction);
- results = converter.createPollDTOs(new ArrayList<Poll>(pollEntities));
+ results = converter.createPollDTOs(
+ new ArrayList<Poll>(pollEntities),
+ context.getConverter());
transaction.commitTransaction();
@@ -541,7 +545,7 @@
ContextUtil.doCatch(e, transaction);
return null;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -550,13 +554,13 @@
TopiaContext transaction = null;
List<PollDTO> results = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
PollDAO dao = PollenModelDAOHelper.getPollDAO(transaction);
String beginDate = Poll.BEGIN_DATE;
String endDate = Poll.END_DATE;
- Date currentDate = PollenContext.getCurrentDate();
+ Date currentDate = context.getCurrentDate();
TopiaQuery query = dao.createQuery().
addNullOr(beginDate, Op.LT, currentDate);
@@ -585,7 +589,8 @@
// }
converter.setTransaction(transaction);
- results = converter.createPollDTOs(entities);
+ results = converter.createPollDTOs(entities,
+ context.getConverter());
transaction.commitTransaction();
@@ -598,7 +603,7 @@
ContextUtil.doCatch(e, transaction);
return null;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -608,7 +613,7 @@
List<PollDTO> results = null;
List<Poll> pollEntities = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
@@ -621,7 +626,8 @@
pollEntities = pollDAO.findAllByProperties(properties);
}
converter.setTransaction(transaction);
- results = converter.createPollDTOs(pollEntities);
+ results = converter.createPollDTOs(pollEntities,
+ context.getConverter());
transaction.commitTransaction();
@@ -635,7 +641,7 @@
_("pollen.error.servicePoll.getAllPolls"));
return null;
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -647,12 +653,12 @@
log.info("P:[ createComment ] : pollUId = " + poll.getPollUId() +
" _ comment = " + comment);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// Create the new comment
CommentDAO dao = PollenModelDAOHelper.getCommentDAO(transaction);
Comment eComment =
- PollenConverter.convert(comment, dao.create());
+ context.getConverter().convert(comment, dao.create());
// Get the poll entity corresponding
Poll ePoll = PollenModelDAOHelper.getPollDAO(transaction).
@@ -668,11 +674,11 @@
poll.addComment(comment);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.addComment"),
comment.getAuthor(), poll.getTitle(), poll.getId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -684,7 +690,7 @@
log.info("P:[ deleteComment ] : pollUId = " + poll.getPollUId() +
" _ commentId = " + commentId);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// Find the comment
CommentDAO dao = PollenModelDAOHelper.getCommentDAO(transaction);
@@ -704,11 +710,11 @@
poll.removeComment(commentId);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.deleteComment"), commentId,
poll.getTitle(), poll.getId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
@@ -720,7 +726,7 @@
if (log.isInfoEnabled()) {
log.info("P:[ getComments ] : pollUId = " + poll.getPollUId());
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
CommentDAO dao = PollenModelDAOHelper.getCommentDAO(transaction);
TopiaQuery query = dao.createQuery().
@@ -730,16 +736,16 @@
for (Comment entity : entities) {
CommentDTO dto =
- PollenConverter.convert(entity, new CommentDTO());
+ context.getConverter().convert(entity, new CommentDTO());
results.add(dto);
}
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.getComments"),
poll.getTitle(), poll.getId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
return results;
}
@@ -749,7 +755,7 @@
TopiaContext transaction = null;
PollAccountDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
if (log.isInfoEnabled()) {
log.info("P:[ getRestrictedAccount ] : accountUId = " + accountUId +
@@ -777,15 +783,15 @@
if (assoc != null) {
PollAccount account = assoc.getPollAccount();
- PollenConverter.convert(account, result);
+ context.getConverter().convert(account, result);
}
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.getRestrictedAccount"),
accountUId, poll.getPollUId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
return result;
}
@@ -811,7 +817,7 @@
log.info("P:[ deleteChoice ] : pollUId = " + poll.getPollUId() +
" _ choiceId = " + choiceId);
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// Find the comment
ChoiceDAO dao = PollenModelDAOHelper.getChoiceDAO(transaction);
@@ -831,11 +837,11 @@
poll.removeChoice(choiceId);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.servicePoll.deleteChoice"), choiceId,
poll.getTitle(), poll.getId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
}
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePreventRuleImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -22,8 +22,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPreventRuleConverter;
import org.chorem.pollen.business.dto.PreventRuleDTO;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
@@ -40,7 +40,7 @@
*/
public class ServicePreventRuleImpl implements ServicePreventRule {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private PreventRuleDAO preventRuleDAO = null;
private DataPreventRuleConverter converter = new DataPreventRuleConverter();
@@ -48,8 +48,8 @@
private static final Log log = LogFactory
.getLog(ServicePreventRuleImpl.class);
- public ServicePreventRuleImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServicePreventRuleImpl(PollenContextImplementor context) {
+ this.context = context;
}
@Override
@@ -57,7 +57,7 @@
TopiaContext transaction = null;
String topiaId = "";
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
preventRuleDAO = PollenModelDAOHelper
.getPreventRuleDAO(transaction);
@@ -117,7 +117,7 @@
TopiaContext transaction = null;
boolean resu = false;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
preventRuleDAO = PollenModelDAOHelper
.getPreventRuleDAO(transaction);
@@ -151,7 +151,7 @@
public boolean deletePreventRule(String preventRuleId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
preventRuleDAO = PollenModelDAOHelper
.getPreventRuleDAO(transaction);
@@ -180,7 +180,7 @@
TopiaContext transaction = null;
PreventRuleDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
preventRuleDAO = PollenModelDAOHelper
.getPreventRuleDAO(transaction);
@@ -216,7 +216,7 @@
List<PreventRuleDTO> results = null;
List<PreventRule> preventRuleEntities = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
preventRuleDAO = PollenModelDAOHelper
.getPreventRuleDAO(transaction);
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataResultConverter;
import org.chorem.pollen.business.converters.DataVoteCountingConverter;
import org.chorem.pollen.business.dto.ResultDTO;
@@ -56,13 +56,13 @@
*/
public class ServiceResultsImpl implements ServiceResults {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
/** log. */
private static final Log log = LogFactory.getLog(ServiceResultsImpl.class);
- public ServiceResultsImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServiceResultsImpl(PollenContextImplementor context) {
+ this.context = context;
}
@Override
@@ -99,7 +99,7 @@
VoteCountingType voteCounting, boolean byGroup, boolean groupOnly) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
PollDAO daoPoll = PollenModelDAOHelper.getPollDAO(transaction);
Poll ePoll = daoPoll.findByPollId(pollId);
@@ -212,7 +212,7 @@
public String exportPoll(String pollId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// Recherche du sondage
PollDAO daoPoll = PollenModelDAOHelper.getPollDAO(transaction);
@@ -281,7 +281,7 @@
// Transformation du sondage
// FIXME do not call a Service from an other one
ServicePoll servicePoll;
- servicePoll = new ServicePollImpl();
+ servicePoll = new ServicePollImpl(context);
org.chorem.pollen.business.dto.PollDTO poll = DataVoteCountingConverter
.createPollDTO(pollExportDTO.getPoll());
@@ -296,7 +296,7 @@
}
} catch (Exception eee) {
- PollenContext.doCatch(eee,
+ context.doCatch(eee,
n_("pollen.error.serviceResults.importPoll"));
}
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -21,8 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataUserConverter;
import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
@@ -31,6 +30,7 @@
import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.business.utils.MD5;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaQuery;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -41,15 +41,15 @@
* @version $Id$
*/
public class ServiceUserImpl implements ServiceUser {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private UserAccountDAO userDAO = null;
private DataUserConverter converter = new DataUserConverter();
/** log. */
private static final Log log = LogFactory.getLog(ServiceUserImpl.class);
- public ServiceUserImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServiceUserImpl(PollenContextImplementor context) {
+ this.context = context;
}
@Override
@@ -57,7 +57,7 @@
TopiaContext transaction = null;
String topiaId = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
if (userDAO.findByLogin(user.getLogin()) != null
@@ -89,7 +89,7 @@
public boolean deleteUser(String login) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -115,7 +115,7 @@
public boolean deleteUser(UserDTO user) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -141,7 +141,7 @@
TopiaContext transaction = null;
UserDTO result = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -174,7 +174,7 @@
List<UserDTO> results = null;
List<UserAccount> userEntities = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -210,7 +210,7 @@
public boolean updateUser(UserDTO user) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -239,7 +239,7 @@
public boolean updatePasswordUser(UserDTO user, String newPassword) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
@@ -267,7 +267,7 @@
TopiaContext transaction = null;
boolean userExists = true;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
if (userDAO.findByLogin(login) == null) {
@@ -292,7 +292,7 @@
TopiaContext transaction = null;
boolean userExists = true;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction);
if (userDAO.findByEmail(email) == null) {
@@ -315,12 +315,16 @@
public void createDefaultAdmin(String login, String password, String email) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
+
UserAccountDAO dao =
PollenModelDAOHelper.getUserAccountDAO(transaction);
- if (dao.findAllByAdministrator(true).size() == 0) {
+ int nbAdmin = dao.createQuery().
+ add(UserAccount.ADMINISTRATOR, Boolean.TRUE).executeCount();
+
+ if (nbAdmin == 0) {
UserAccount userEntity = dao.create();
userEntity.setLogin(login);
String encodedPassword = MD5.encode(password);
@@ -335,11 +339,11 @@
transaction.commitTransaction();
}
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.serviceUser.createDefaultAdmin"),
login, email);
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
}
}
\ No newline at end of file
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -22,8 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContext;
-import org.chorem.pollen.business.PollenConverter;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.converters.DataPollAccountConverter;
import org.chorem.pollen.business.converters.DataVoteConverter;
import org.chorem.pollen.business.dto.PollAccountDTO;
@@ -50,16 +49,16 @@
*/
public class ServiceVoteImpl implements ServiceVote {
- private TopiaContext rootContext;
+ private PollenContextImplementor context;
private DataVoteConverter converter = new DataVoteConverter();
/** log. */
private static final Log log = LogFactory.getLog(ServiceVoteImpl.class);
- public ServiceVoteImpl() {
- rootContext = PollenContext.getRootContext();
+ public ServiceVoteImpl(PollenContextImplementor context) {
+ this.context = context;
- PollenConverter.prepareVoteConverters();
+ context.getConverter().prepareVoteConverters();
}
@Override
@@ -67,7 +66,7 @@
TopiaContext transaction = null;
String topiaId = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// création du compte associé au vote s'il n'existe pas
// sinon mise à jour du compte
@@ -84,7 +83,7 @@
if (pollAccountEntity == null) {
log.debug("Nouveau compte associé au vote");
pollAccountEntity = pollAccountDAO.create(
- PollenContext.createPollenUrlId());
+ context.createPollenUrlId());
// EVO #108 : Migration to ToPIA 2.3, the entity must be
// commited because an other findBy is called in the
// converter (wtf ?! :/). This behavior doesn't work
@@ -144,7 +143,7 @@
public boolean updateVote(VoteDTO voteDTO) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
Vote voteEntity = voteDAO.findByTopiaId(voteDTO.getId());
@@ -171,7 +170,7 @@
public boolean deleteVote(String voteId) {
TopiaContext transaction = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
Vote voteEntity = voteDAO.findByTopiaId(voteId);
@@ -213,7 +212,7 @@
// FIXME-FD20100309 : change dto to suppress link from poll to vote
// It's not necessary to have votes when retrieving the poll, this
// method do this job only when it's needed
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// List<Vote> votes = transaction.find(
// "FROM " + Vote.class.getName() +
@@ -236,18 +235,18 @@
log.debug("Nb votes found : " + eVotes.size());
}
for (Vote eVote : eVotes) {
- VoteDTO vote = PollenConverter.convert(eVote, new VoteDTO());
+ VoteDTO vote = context.getConverter().convert(eVote, new VoteDTO());
results.add(vote);
}
// converter.setTransaction(transaction);
// results = converter.createVoteDTOs(votes);
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.serviceVote.getVotesByPoll"),
poll.getPollUId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
return results;
}
@@ -281,7 +280,7 @@
" _ pollUId = " + poll.getPollUId());
}
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
// List<Long> tmp = transaction.find(
// "SELECT COUNT(*)" +
@@ -304,11 +303,11 @@
result = count > 0;
} catch (Exception eee) {
- PollenContext.doCatch(transaction, eee,
+ context.doCatch(transaction, eee,
n_("pollen.error.serviceVote.hasAlreadyVoted"),
votingId, poll.getPollUId());
} finally {
- PollenContext.doFinally(transaction);
+ context.doFinally(transaction);
}
return result;
}
@@ -319,7 +318,7 @@
List<VoteDTO> results = null;
List<Vote> voteEntities = null;
try {
- transaction = rootContext.beginTransaction();
+ transaction = context.getRootContext().beginTransaction();
VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -26,7 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.PollenBusinessException;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
import org.chorem.pollen.business.PollenException;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
import org.chorem.pollen.business.persistence.UserAccount;
@@ -76,21 +76,21 @@
* @
* @deprecated use {@link #getRootContext } instead
*/
- @Deprecated
- public TopiaContext getContext() {
- return PollenContext.getRootContext();
- }
-
+// @Deprecated
+// public TopiaContext getContext() {
+// return PollenContexImpl.getRootContext();
+// }
+//
+// /**
+// * Retourne la configuration de la base de données.
+// *
+// * @return la configuration
+// * @
+// */
+// public Properties getConf() {
+// return PollenContexImpl.getProperties();
+// }
/**
- * Retourne la configuration de la base de données.
- *
- * @return la configuration
- * @
- */
- public Properties getConf() {
- return PollenContext.getProperties();
- }
- /**
* Construction du contexte global
* @deprecated use directly {@link #getRootContext} method
*/
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestData.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -21,7 +21,8 @@
public void execute() throws Exception {
transaction = null;
try {
- transaction = PollenContext.getRootContext().beginTransaction();
+ transaction = TestManager.getContext().
+ getRootContext().beginTransaction();
test();
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/TestManager.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -9,6 +9,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import org.nuiton.util.ApplicationConfig;
/**
@@ -27,6 +29,8 @@
private static final Log log = LogFactory.getLog(TestManager.class);
+ private static PollenContextImplementor context;
+
public static void start(String dbname) throws IOException {
log.info("## START ## : " + dbname);
@@ -43,16 +47,27 @@
"jdbc:h2:file:target/surefire-data/" + dbname
);
- PollenContext.loadConfiguration(config);
- PollenContext.start();
+ getContext().loadConfiguration(config);
+ getContext().start();
// Set currentDate to 23/02/2010 for tests
Calendar calendar = new GregorianCalendar(2010, 1, 23, 0, 0, 0);
- PollenContext.setCurrentDate(calendar.getTime());
+ ((PollenContextImpl)getContext()).setCurrentDate(calendar.getTime());
}
public static void stop() throws IOException {
- PollenContext.stop();
+ getContext().stop();
}
+ public static PollenContextImplementor getContext() {
+ if (context == null) {
+ context = new PollenContextImpl();
+ }
+ return context;
+ }
+
+ public static TopiaContext beginTransaction() throws TopiaException {
+ return getContext().getRootContext().beginTransaction();
+ }
+
}
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/scaling/ScalingVote.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/scaling/ScalingVote.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/scaling/ScalingVote.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -16,13 +16,14 @@
package org.chorem.pollen.business.scaling;
-import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.business.TestManager;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.Poll;
@@ -35,7 +36,6 @@
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceDAO;
import org.chorem.pollen.business.persistence.VotingList;
-import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -55,8 +55,8 @@
private static final Log log = LogFactory.getLog(ScalingVote.class);
/** Adresse de la base de données (surchage l'adresse dans src/test/resources) */
- public static final String DB_URL = "jdbc:h2:" + System.getProperty("user.home") +
- File.separator + ".pollen" + File.separator + "pollendb";
+// public static final String DB_URL = "jdbc:h2:" + System.getProperty("user.home") +
+// File.separator + ".pollen" + File.separator + "pollendb";
/** La config en cours. */
protected static Properties config;
@@ -66,14 +66,16 @@
*
* @param args
*/
- public static void main(String args[]) {
- System.out.println("Using database at : " + DB_URL);
+ public static void main(String args[]) throws IOException {
+// System.out.println("Using database at : " + DB_URL);
- ContextUtil contextUtil = ContextUtil.getInstance();
- config = contextUtil.getConf();
- config.setProperty("hibernate.connection.url", DB_URL);
- config.remove("hibernate.hbm2ddl.auto");
+// ContextUtil contextUtil = ContextUtil.getInstance();
+// config = contextUtil.getConf();
+ TestManager.start("ScalingVote");
+// config.setProperty("hibernate.connection.url", DB_URL);
+// config.remove("hibernate.hbm2ddl.auto");
+
try {
new ScalingVote().doInsertFixedNumber();
}
@@ -92,9 +94,8 @@
*
* @throws TopiaException
*/
- public void doInsertWithVotingList() throws TopiaException {
- TopiaContext rootContext = TopiaContextFactory.getContext(config);
- TopiaContext context = rootContext.beginTransaction();
+ public void doInsertWithVotingList() throws TopiaException, IOException {
+ TopiaContext context = TestManager.beginTransaction();
PollDAO pollDAO = PollenModelDAOHelper.getPollDAO(context);
VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(context);
@@ -151,7 +152,7 @@
context.commitTransaction();
context.closeContext();
- rootContext.closeContext();
+ TestManager.stop();
}
/**
@@ -162,9 +163,8 @@
*
* @throws TopiaException
*/
- public void doInsertFixedNumber() throws TopiaException {
- TopiaContext rootContext = TopiaContextFactory.getContext(config);
- TopiaContext context = rootContext.beginTransaction();
+ public void doInsertFixedNumber() throws TopiaException, IOException {
+ TopiaContext context = TestManager.beginTransaction();
PollDAO pollDAO = PollenModelDAOHelper.getPollDAO(context);
VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(context);
@@ -218,6 +218,6 @@
context.commitTransaction();
context.closeContext();
- rootContext.closeContext();
+ TestManager.stop();
}
}
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -24,7 +24,7 @@
import java.util.List;
import java.util.Map;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
import org.chorem.pollen.business.PollenProperty;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -46,6 +46,8 @@
protected static SendMail sendMail;
+ protected static PollenContextImpl context;
+
@BeforeClass
public static void init() throws InterruptedException {
@@ -55,9 +57,9 @@
config.setOption(PollenProperty.EMAIL_PORT.getKey(), "25");
config.setOption(PollenProperty.EMAIL_FROM.getKey(), "pollenreminder(a)codelutin.com");
- PollenContext.loadConfiguration(config);
+ context.loadConfiguration(config);
- sendMail = new SendMail();
+ sendMail = new SendMail(context);
sendMail.start();
Thread.sleep(3000);
}
@@ -89,7 +91,7 @@
sendMail.prepareMails("test", mailList);
- String emailDir = PollenProperty.EMAIL_DIR.getValue();
+ String emailDir = context.getProperty(PollenProperty.EMAIL_DIR);
Assert.assertTrue(new File(emailDir, "test.mail").exists());
Assert.assertTrue(new File(emailDir, "test.index").exists());
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceAuthImplTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -52,7 +52,7 @@
@Before
public void setUp() {
- instance = new ServiceAuthImpl();
+ instance = new ServiceAuthImpl(TestManager.getContext());
}
@After
@@ -71,7 +71,7 @@
UserDTO dto = new UserDTO();
dto.setLogin(login);
- ServiceUser smu = new ServiceUserImpl();
+ ServiceUser smu = new ServiceUserImpl(TestManager.getContext());
smu.createUser(dto, password);
boolean result2 = instance.isLoginRight(login, password);
assertTrue(result2);
@@ -89,7 +89,7 @@
UserDTO dto = new UserDTO();
dto.setLogin(login);
- ServiceUser smu = new ServiceUserImpl();
+ ServiceUser smu = new ServiceUserImpl(TestManager.getContext());
smu.createUser(dto, password);
UserDTO result2 = instance.getUser(login, password);
assertEquals(login, result2.getLogin());
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceChoiceImplTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -61,7 +61,7 @@
@Before
public void setUp() {
- instance = new ServiceChoiceImpl();
+ instance = new ServiceChoiceImpl(TestManager.getContext());
}
@After
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -68,7 +68,7 @@
@Before
public void setUp() {
- instance = new ServiceListImpl();
+ instance = new ServiceListImpl(TestManager.getContext());
}
@After
@@ -124,7 +124,7 @@
// temp stop, must refactor all tests from this class
TestManager.stop();
TestManager.start("createAccountInPersonList");
- instance = new ServiceListImpl();
+ instance = new ServiceListImpl(TestManager.getContext());
/** PREPARE DATA **/
PersonListDTO dto = new PersonListDTO();
@@ -173,7 +173,7 @@
// temp stop, must refactor all tests from this class
TestManager.stop();
TestManager.start("deleteAccountFromPersonList");
- instance = new ServiceListImpl();
+ instance = new ServiceListImpl(TestManager.getContext());
/** PREPARE DATA **/
PersonListDTO dto = new PersonListDTO();
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -26,7 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
import org.chorem.pollen.business.TestData;
import org.chorem.pollen.business.TestManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -79,7 +79,7 @@
@After
public void tearDown() throws IOException {
TestManager.stop();
- BinderProvider.clear();
+ //BinderProvider.clear();
}
/**
@@ -89,7 +89,7 @@
@Test
public void testCreatePoll() throws Exception {
TestManager.start("testCreatePoll");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
PollDTO dto = instance.getNewPoll();
dto.setBeginChoiceDate(new Date());
@@ -150,7 +150,7 @@
@Test
public void testUpdatePoll() throws Exception {
TestManager.start("testUpdatePoll");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
String pollId = "";
PollDTO dto = instance.getNewPoll();
@@ -174,7 +174,7 @@
@Test
public void testDeletePoll() throws Exception {
TestManager.start("testDeletePoll");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
PollDTO dto = instance.getNewPoll();
dto.setDescription("Test_deletePoll");
@@ -194,7 +194,7 @@
@Test
public void testFindPollByPollId() throws Exception {
TestManager.start("testFindPollByPollId");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
String pollId = "";
PollDTO dto = instance.getNewPoll();
@@ -240,13 +240,13 @@
@Test
public void testFindPollsByUser() throws Exception {
TestManager.start("testFindPollsByUser");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
// création de l'utilisateur
UserDTO user = new UserDTO();
user.setLogin("login_findPollsByUser");
user.setEmail("email_findPollsByUser");
- ServiceUser su = new ServiceUserImpl();
+ ServiceUser su = new ServiceUserImpl(TestManager.getContext());
String userId = su.createUser(user, "password");
// création du sondage
@@ -269,19 +269,19 @@
@Test
public void testFindParticipatedPolls() throws Exception {
TestManager.start("testFindParticipatedPolls");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
// création de l'utilisateur
UserDTO user = new UserDTO();
user.setLogin("login_findParticipatedPolls");
user.setEmail("email_findParticipatedPolls");
- ServiceUser su = new ServiceUserImpl();
+ ServiceUser su = new ServiceUserImpl(TestManager.getContext());
String userId = su.createUser(user, "password");
// création du compte associé à l'utilisateur
PollAccountDTO account = new PollAccountDTO();
account.setUserId(userId);
- ServicePollAccount spa = new ServicePollAccountImpl();
+ ServicePollAccount spa = new ServicePollAccountImpl(TestManager.getContext());
String accountId = spa.createPollAccount(account);
// création du sondage
@@ -294,7 +294,7 @@
// création du vote
VoteDTO vote = new VoteDTO(accountId, pollId, null);
- ServiceVote sv = new ServiceVoteImpl();
+ ServiceVote sv = new ServiceVoteImpl(TestManager.getContext());
sv.createVote(vote, account);
// recherche des sondages de l'utilisateur
@@ -308,9 +308,9 @@
@Test
public void testFindRunningPolls() throws Exception {
TestManager.start("testFindRunningPolls");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
- Date now = PollenContext.getCurrentDate();
+ Date now = TestManager.getContext().getCurrentDate();
// sondage en cours sans date de fin
PollDTO poll1 = instance.getNewPoll();
@@ -359,7 +359,7 @@
@Test
public void testSelectPolls() throws Exception {
TestManager.start("testSelectPolls");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
PollDTO dto = instance.getNewPoll();
dto.setDescription("test selectPolls");
@@ -395,7 +395,7 @@
@Test
public void testCreateComment() throws Exception {
TestManager.start("testCreateComment");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
/** PREPARE DATA **/
PollDTO poll = instance.getNewPoll();
@@ -440,7 +440,7 @@
@Test
public void testDeleteComment() throws Exception {
TestManager.start("testDeleteComment");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
/** PREPARE DATA **/
PollDTO poll = instance.getNewPoll();
@@ -483,7 +483,7 @@
//@Test
public void testGetRestrictedAccount() throws IOException {
TestManager.start("testGetRestrictedAccount");
- instance = new ServicePollImpl();
+ instance = new ServicePollImpl(TestManager.getContext());
/** PREPARE DATA **/
PollDTO poll = instance.getNewPoll();
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePreventRuleImplTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -63,7 +63,7 @@
@Before
public void setUp() throws Exception {
- instance = new ServicePreventRuleImpl();
+ instance = new ServicePreventRuleImpl(TestManager.getContext());
}
@After
Modified: 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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceUserImplTest.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -54,7 +54,7 @@
@Before
public void setUp() {
- instance = new ServiceUserImpl();
+ instance = new ServiceUserImpl(TestManager.getContext());
}
@After
@@ -142,7 +142,7 @@
user.setId(instance.createUser(user, "password"));
instance.updatePasswordUser(user, "newPassword");
- ServiceAuth sa = new ServiceAuthImpl();
+ ServiceAuth sa = new ServiceAuthImpl(TestManager.getContext());
UserDTO result = sa.getUser(user.getLogin(), "newPassword");
assertNotNull(result);
}
Added: trunk/pollen-business/src/test/resources/log4j.properties
===================================================================
--- trunk/pollen-business/src/test/resources/log4j.properties (rev 0)
+++ trunk/pollen-business/src/test/resources/log4j.properties 2010-03-20 18:42:04 UTC (rev 2953)
@@ -0,0 +1,14 @@
+# Default to info level output; this is very handy if you eventually use Hibernate as well.
+log4j.rootCategory=warn, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d [%p] %c{2} %m%n
+
+log4j.logger.org.chorem.pollen=debug
+
+log4j.logger.org.chorem.pollen.business.PollenContextImpl=warn
+log4j.logger.org.chorem.pollen.business.services.SendMail=warn
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -24,7 +24,6 @@
import java.util.Locale;
import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
@@ -35,7 +34,7 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.PersistentLocale;
import org.apache.tapestry5.services.Request;
-import org.chorem.pollen.business.PollenBusinessException;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.services.ServiceAuth;
@@ -159,6 +158,9 @@
@Inject
private Request request;
+ @Inject
+ private PollenContext pollen;
+
/**
* Accès aux messages
*/
@@ -231,7 +233,7 @@
* @return current application version
*/
public String getVersion() {
- return PollenProperty.APP_VERSION.getValue();
+ return pollen.getProperty(PollenProperty.APP_VERSION);
}
public int getCurrentYear() {
@@ -240,7 +242,7 @@
}
public String getContactEmail() {
- return PollenProperty.CONTACT_EMAIL.getValue();
+ return pollen.getProperty(PollenProperty.CONTACT_EMAIL);
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedContextLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedContextLink.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedContextLink.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -2,7 +2,8 @@
package org.chorem.pollen.ui.components;
import java.io.File;
-import org.chorem.pollen.business.PollenBusinessException;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.ui.base.ContextLink;
import org.chorem.pollen.business.PollenProperty;
@@ -19,9 +20,12 @@
*/
public class FeedContextLink implements ContextLink {
+ @Inject
+ private PollenContext pollen;
+
@Override
public String getContextPath() {
- return PollenProperty.FEED_DIR.getValue();
+ return pollen.getProperty(PollenProperty.FEED_DIR);
}
@Override
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -17,10 +17,9 @@
package org.chorem.pollen.ui.components;
import java.io.File;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.tapestry5.annotations.Parameter;
-import org.chorem.pollen.business.PollenBusinessException;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.ui.base.ContextLink;
@@ -41,6 +40,9 @@
public static final String THUMB_PREFIX = "thumb_";
+ @Inject
+ private PollenContext pollen;
+
/**
* Directory for files getting or saving from this context
* (ie. subdirectory where images are uploaded, main directory is defined by contextPath)
@@ -56,7 +58,7 @@
@Override
public String getContextPath() {
- return PollenProperty.IMG_DIR.getValue();
+ return pollen.getProperty(PollenProperty.IMG_DIR);
}
@Override
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -31,7 +31,7 @@
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
-import org.chorem.pollen.business.PollenBusinessException;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.UserDTO;
@@ -199,12 +199,15 @@
};
}
+ @Inject
+ private PollenContext pollen;
+
/** Envoi du mail de notification */
private void sendMailNotification(UserDTO newUser, String password) {
Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
+ data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
+ data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
+ data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM));
data.put("to", newUser.getEmail());
data.put("title", messages.format("registerEmail_subject", newUser
.getLogin()));
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -49,6 +49,7 @@
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.upload.services.UploadSymbols;
import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -815,6 +816,9 @@
creator.getVotingId()), voteURL, messages.get("pollFeed_createContent"));
}
+ @Inject
+ private PollenContext pollen;
+
/** Envoi du mail de notification */
private void sendMailNotification(String siteURL, ServicePollAccount servicePollAccount,
PollDTO poll, Messages messages) {
@@ -822,9 +826,9 @@
String voteURL = siteURL + "poll/VoteFor/" + poll.getPollUId();
String modifURL = siteURL + "poll/Modification/" + poll.getPollUId() + ":" + creator.getAccountId();
Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
+ data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
+ data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
+ data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM));
// Mail au créateur
if (poll.getCreatorEmail() != null) {
@@ -867,8 +871,8 @@
// send mail preparation
try {
- PollenContext.getSendMail().prepareMails(poll.getId(), mailList);
- PollenContext.getSendMail().wakeUp();
+ pollen.getSendMail().prepareMails(poll.getId(), mailList);
+ pollen.getSendMail().wakeUp();
} catch (IOException ex) {
if (log.isErrorEnabled()) {
log.error("Can't prepare send mail on disk, mail won't be send !!!", ex);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -38,7 +38,6 @@
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.chenillekit.tapestry.core.components.DateTimeField;
-import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
@@ -530,13 +529,16 @@
return poll.getChoiceType() == ChoiceType.IMAGE;
}
+ @Inject
+ private PollenContext pollen;
+
/** Envoi du mail de notification */
private void sendMailNotification(List<PollAccountDTO> modifiedAccounts) {
String voteURL = siteURL + "poll/VoteFor/" + poll.getPollUId();
Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
+ data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
+ data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
+ data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM));
// Mails aux votants
for (PollAccountDTO account : modifiedAccounts) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -53,6 +53,7 @@
import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.business.PollenProperty;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.dto.CommentDTO;
@@ -587,9 +588,9 @@
String modifURL = siteURL + "poll/Modification/" + getPoll().getPollUId()
+ ":" + MD5.encode(getPoll().getCreatorId());
Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
+ data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
+ data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
+ data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM));
// Mail au créateur
data.put("to", getPoll().getCreatorEmail());
@@ -975,8 +976,9 @@
+ @Inject
+ private PollenContext pollen;
-
@Property
private PollUri uri;
@@ -1319,7 +1321,8 @@
}
public int getPagerRange() {
- return Integer.parseInt(PollenProperty.NB_VOTES_PER_PAGE.getValue());
+ return Integer.parseInt(
+ pollen.getProperty(PollenProperty.NB_VOTES_PER_PAGE));
}
public String getNoPagerText() throws PollenBusinessException {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -30,7 +30,7 @@
import org.apache.tapestry5.corelib.components.TextField;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
-import org.chorem.pollen.business.PollenBusinessException;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.UserDTO;
@@ -149,13 +149,16 @@
return this;
}
+
+ @Inject
+ private PollenContext pollen;
/** Envoi du mail de notification */
private void sendMailNotification() {
Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
+ data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST));
+ data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT));
+ data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM));
data.put("to", newUser.getEmail());
data.put("title", messages.format("registerEmail_subject", newUser
.getLogin()));
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -16,8 +16,6 @@
package org.chorem.pollen.ui.services;
-import java.math.BigDecimal;
-import org.chorem.pollen.business.services.SendMail;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
@@ -28,21 +26,29 @@
import org.apache.tapestry5.ioc.annotations.InjectService;
import org.apache.tapestry5.ioc.services.Coercion;
import org.apache.tapestry5.ioc.services.CoercionTuple;
-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.upload.services.UploadSymbols;
+import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.services.ServiceAuth;
+import org.chorem.pollen.business.services.ServiceAuthImpl;
import org.chorem.pollen.business.services.ServiceChoice;
+import org.chorem.pollen.business.services.ServiceChoiceImpl;
import org.chorem.pollen.business.services.ServiceList;
+import org.chorem.pollen.business.services.ServiceListImpl;
import org.chorem.pollen.business.services.ServicePoll;
import org.chorem.pollen.business.services.ServicePollAccount;
+import org.chorem.pollen.business.services.ServicePollAccountImpl;
+import org.chorem.pollen.business.services.ServicePollImpl;
import org.chorem.pollen.business.services.ServiceResults;
+import org.chorem.pollen.business.services.ServiceResultsImpl;
import org.chorem.pollen.business.services.ServiceUser;
+import org.chorem.pollen.business.services.ServiceUserImpl;
import org.chorem.pollen.business.services.ServiceVote;
+import org.chorem.pollen.business.services.ServiceVoteImpl;
import org.chorem.pollen.ui.data.PollUri;
-import org.slf4j.Logger;
/**
* This module is automatically included as part of the Tapestry IoC Registry,
@@ -53,28 +59,81 @@
*/
public class AppModule {
- private static final String CONFIGURATION_FILE = "pollen.properties";
-
public static void bind(ServiceBinder binder) {
- // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
+ // Pollen-Business services
+// binder.bind(ServiceAuth.class);
+// binder.bind(ServiceList.class);
+// binder.bind(ServiceUser.class);
+// binder.bind(ServicePoll.class);
+// binder.bind(ServicePollAccount.class);
+// binder.bind(ServiceResults.class);
+// binder.bind(ServiceVote.class);
+// binder.bind(ServiceChoice.class);
+// binder.bind(ServiceImage.class);
+// binder.bind(PollenContext.class, PollenContextImpl.class);
+ }
- // Make bind() calls on the binder object to define most IoC services.
- // Use service builder methods (example below) when the implementation
- // is provided inline, or requires more initialization than simply
- // invoking the constructor.
+ /**
+ * Build the main application context PollenContext.
+ *
+ * @return PollenContextImplementor type to use injection in services build
+ */
+ public static PollenContextImplementor buildPollenContext() {
+ PollenContextImplementor context = new PollenContextImpl();
+ context.start();
+ return context;
+ }
- // Pollen-Business services
- binder.bind(ServiceAuth.class);
- binder.bind(ServiceList.class);
- binder.bind(ServiceUser.class);
- binder.bind(ServicePoll.class);
- binder.bind(ServicePollAccount.class);
- binder.bind(ServiceResults.class);
- binder.bind(ServiceVote.class);
- binder.bind(ServiceChoice.class);
- binder.bind(ServiceImage.class);
+ /** Will be merged with serviceUser **/
+ public static ServiceAuth buildServiceAuth(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceAuthImpl(context);
}
+ /** Will be divided between servicePoll and serviceUser, maybe other
+ * services for LDAP or CSV
+ **/
+ public static ServiceList buildServiceList(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceListImpl(context);
+ }
+ public static ServiceUser buildServiceUser(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceUserImpl(context);
+ }
+
+ public static ServicePoll buildServicePoll(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServicePollImpl(context);
+ }
+
+ /** Will be divided between serviceVote, serviceUser and servicePoll **/
+ public static ServicePollAccount buildServicePollAccount(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServicePollAccountImpl(context);
+ }
+
+ public static ServiceResults buildServiceResults(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceResultsImpl(context);
+ }
+
+ public static ServiceVote buildServiceVote(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceVoteImpl(context);
+ }
+
+ /** Will be divided between serviceVote and servicePoll **/
+ public static ServiceChoice buildServiceChoice(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceChoiceImpl(context);
+ }
+
+ public static ServiceImage buildServiceImage(
+ @InjectService("PollenContext") PollenContextImplementor context) {
+ return new ServiceImageImpl(context);
+ }
+
public static void contributeApplicationDefaults(
MappedConfiguration<String, String> configuration) {
// Contributions to ApplicationDefaults will override any contributions to
@@ -96,63 +155,15 @@
configuration.add(UploadSymbols.REQUESTSIZE_MAX, "10485760");
}
- /*
- * This is a service definition, the service will be named "TimingFilter".
- * The interface, RequestFilter, is used within the RequestHandler service
- * pipeline, which is built from the RequestHandler service configuration.
- * Tapestry IoC is responsible for passing in an appropriate Logger
- * instance. Requests for static resources are handled at a higher level, so
- * this filter will only be invoked for Tapestry related requests.
- *
- * <p>
- * Service builder methods are useful when the implementation is inline as
- * an inner class (as here) or require some other kind of special
- * initialization. In most cases, use the static bind() method instead.
- *
- * <p>
- * If this method was named "build", then the service id would be taken from
- * the service interface and would be "RequestFilter". Since Tapestry
- * already defines a service named "RequestFilter" we use an explicit
- * service id that we can reference inside the contribution method.
- *
- public RequestFilter buildTimingFilter(final Logger log) {
- return new RequestFilter() {
- public boolean service(Request request, Response response,
- RequestHandler handler) throws IOException {
- long startTime = System.currentTimeMillis();
-
- try {
- // The responsibility of a filter is to invoke the corresponding method
- // in the handler. When you chain multiple filters together, each filter
- // received a handler that is a bridge to the next filter.
-
- return handler.service(request, response);
- } finally {
- long elapsed = System.currentTimeMillis() - startTime;
-
- log.info(String.format("Request time: %d ms", elapsed));
- }
- }
- };
- }*/
-
/**
- * This is the Shutdown service definition. This service is used when the
- * server shutdown. It detects the Tapestry registry shutdown.
+ * TypeCoercion for PollUri. This will convert automatically between String
+ * and PollUri. So pollUri can be used in activation/passivation page
+ * context.
+ *
+ * @param configuration
*/
- @EagerLoad
- public RegistryShutdownListener buildPollenShutdown(
- @InjectService("RegistryShutdownHub") RegistryShutdownHub hub) {
- RegistryShutdownListener listener = new PollenManager();
- hub.addRegistryShutdownListener(listener);
- return listener;
- }
-
- public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) {
- configuration.add("PollenStartup", new PollenManager());
- }
-
- public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration) {
+ public static void contributeTypeCoercer(
+ Configuration<CoercionTuple> configuration) {
Coercion<String, PollUri> coercion1 = new Coercion<String, PollUri>() {
@Override
@@ -169,8 +180,12 @@
}
};
- configuration.add(new CoercionTuple<String, PollUri>(String.class, PollUri.class, coercion1));
- configuration.add(new CoercionTuple<PollUri, String>(PollUri.class, String.class, coercion2));
+ configuration.add(
+ new CoercionTuple<String, PollUri>(
+ String.class, PollUri.class, coercion1));
+ configuration.add(
+ new CoercionTuple<PollUri, String>(
+ PollUri.class, String.class, coercion2));
}
/**
@@ -180,42 +195,20 @@
@EagerLoad
public static BackgroundWorker buildBackgroundWorker(
ComponentSource componentSource,
- ServicePoll servicePoll) {
+ ServicePoll servicePoll, PollenContext context) {
Messages messages = componentSource.getPage("LocalMessages")
.getComponentResources().getMessages();
- return new BackgroundWorkerImpl(messages, servicePoll);
+ return new BackgroundWorkerImpl(messages, servicePoll, context);
}
- /*
- * Contribution au démarrage de services tapestry.
- *
- * Ajout de SendMail
- *
- * @param configuration configuration tapestry
- * @param conf configuration pollen
- *
- public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration, Configuration conf) {
- configuration.add("SendMail", new SendMail(conf));
- }*/
-
/**
- * Init send mail service.
- *
- * @param conf
+ * Make configuration from a Properties file available as symbols.
+ * @param context
* @return
*/
- @EagerLoad
- public SendMail buildSendMail() {
- SendMail res = new SendMail();
- return res;
- }
-
- /**
- * Make configuration from a Properties file available as symbols.
- */
public PropertiesFileSymbolProvider buildConfigPropertiesFileSymbolProvider(
- Logger logger) {
- return new PropertiesFileSymbolProvider(logger, CONFIGURATION_FILE);
+ @InjectService("PollenContext") PollenContext context) {
+ return new PropertiesFileSymbolProvider(context);
}
/**
@@ -229,22 +222,4 @@
configPropertiesFileSymbolProvider, "after:SystemProperties",
"before:ApplicationDefaults");
}
-
- /*
- * This is a contribution to the RequestHandler service configuration. This
- * is how we extend Tapestry using the timing filter. A common use for this
- * kind of filter is transaction management or security. The @Local
- * annotation selects the desired service by type, but only from the same
- * module. Without @Local, there would be an error due to the other
- * service(s) that implement RequestFilter (defined in other modules).
- *
- public void contributeRequestHandler(
- OrderedConfiguration<RequestFilter> configuration,
- @Local RequestFilter filter) {
- // Each contribution to an ordered configuration has a name, When necessary, you may
- // set constraints to precisely control the invocation order of the contributed filter
- // within the pipeline.
-
- //configuration.add("Timing", filter);
- }*/
}
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 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -23,10 +23,11 @@
import java.util.Timer;
import java.util.TimerTask;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry5.ioc.Messages;
+import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImplementor;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.PollAccountDTO;
@@ -58,11 +59,14 @@
/** Injection du service de gestion de sondages. */
private ServicePoll servicePoll;
+ private PollenContext context;
+
/**
* Constructeur exécuté au lancement de l'application.
*/
public BackgroundWorkerImpl(Messages messages,
- ServicePoll servicePoll) {
+ ServicePoll servicePoll, PollenContext context) {
+ this.context = context;
this.messages = messages;
this.servicePoll = servicePoll;
@@ -74,7 +78,7 @@
* Lancement des tâches en arrière-plan.
*/
public void executeTasks() {
- if (!PollenProperty.SERVER_URL.hasValue()) {
+ if (!context.hasProperty(PollenProperty.SERVER_URL)) {
log.warn("No property siteUrl. Reminder emails would not contain it");
}
@@ -126,12 +130,12 @@
* @param poll sondage concerné
*/
private void sendMailNotification(PollDTO poll, Long timeValue) {
- String voteURL = PollenProperty.SERVER_URL.getValue() + "/poll/VoteFor/"
- + poll.getPollUId();
+ String voteURL = context.getProperty(PollenProperty.SERVER_URL) +
+ "/poll/VoteFor/" + poll.getPollUId();
Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
+ data.put("host", context.getProperty(PollenProperty.EMAIL_HOST));
+ data.put("port", context.getProperty(PollenProperty.EMAIL_PORT));
+ data.put("from", context.getProperty(PollenProperty.EMAIL_FROM));
// Mails aux votants
for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) {
@@ -162,7 +166,7 @@
// 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();
+ ServicePreventRule spr = new ServicePreventRuleImpl((PollenContextImplementor)context);
spr.updatePreventRule(rule);
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -20,6 +20,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenContextImpl;
/**
* Service de gestion de l'arrêt du serveur. Ce service exécute une action à la
@@ -28,24 +29,30 @@
* @author rannou
* @version $Id$
*/
-public class PollenManager implements RegistryShutdownListener, Runnable {
+public class PollenManager implements RegistryShutdownListener /*, Runnable */{
private static final Log log = LogFactory.getLog(PollenManager.class);
- @Override
- public void run() {
- if (log.isInfoEnabled()) {
- log.info("Start Pollen");
- }
- PollenContext.start();
+ private PollenContext context;
+
+ public PollenManager(PollenContext context) {
+ this.context = context;
}
+// @Override
+// public void run() {
+// if (log.isInfoEnabled()) {
+// log.info("Start Pollen");
+// }
+// context.start();
+// }
+
@Override
public void registryDidShutdown() {
if (log.isInfoEnabled()) {
log.info("Stop Pollen");
}
- PollenContext.stop();
+ context.stop();
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PropertiesFileSymbolProvider.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PropertiesFileSymbolProvider.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PropertiesFileSymbolProvider.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -17,6 +17,8 @@
private final Map<String, String> propertiesMap = new CaseInsensitiveMap<String>();
+ private PollenContext context;
+
/**
* Instantiate a new PropertiesFileSymbolProvider using a given resource
* name
@@ -55,11 +57,10 @@
* Instantiate a new PropertiesFileSymbolProvider using a given resource
* name (looking in filesystem and classpath)
*
- * @param logger the logger to log error messages to
- * @param resourceName the name of the resource to load
+ * @param context PollenContext
*/
- public PropertiesFileSymbolProvider(Logger logger, String resourceName) {
- Properties conf = PollenContext.getProperties();
+ public PropertiesFileSymbolProvider(PollenContext context) {
+ Properties conf = context.getConfiguration().getOptions();
initializeProperties(conf);
}
@@ -129,6 +130,7 @@
}
}
+ @Override
public String valueForSymbol(String arg0) {
return propertiesMap.get(arg0);
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-03-20 18:42:04 UTC (rev 2953)
@@ -41,13 +41,15 @@
private static final Logger logger = LoggerFactory.getLogger(ServiceImageImpl.class);
- public ServiceImageImpl() {
-
+ private PollenContext context;
+
+ public ServiceImageImpl(PollenContext context) {
+ this.context = context;
}
@Override
public String getContextPath() {
- return PollenContext.getProperty(PollenProperty.IMG_DIR);
+ return context.getProperty(PollenProperty.IMG_DIR);
}
/**
@@ -75,6 +77,7 @@
@Override
public StreamResponse createImageStream(String filename, String filedir, boolean thumb) {
+ // security : src containing .. are filtered, to not access to full system
if (StringUtils.isEmpty(filename) || filename.contains("..")) {
return null;
}
1
0
Author: fdesbois
Date: 2010-03-20 16:30:29 +0100 (Sat, 20 Mar 2010)
New Revision: 2952
Log:
- Rename pollId by pollUId in PollDTO
- Evo #151 : using i18n tapestry-bundle and use keys from i18n
- Evo #150 : place image managment in a new service
- Refactor VoteForPoll page (70%)
Added:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
trunk/pollen-ui/src/main/webapp/js/confirm.js
trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js
Removed:
trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js
Modified:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataChoiceConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/ChoiceDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.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/ServicePoll.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/resources/pollen.properties
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/ContextLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties
trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties
trunk/pollen-ui/src/main/webapp/WEB-INF/web.xml
trunk/pollen-ui/src/main/webapp/img/1leftarrow.png
trunk/pollen-ui/src/main/webapp/img/1rightarrow.png
trunk/pollen-ui/src/main/webapp/img/2leftarrow.png
trunk/pollen-ui/src/main/webapp/img/2rightarrow.png
trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml
trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenConverter.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -151,7 +151,7 @@
String name = entity.getName();
dto.setHidden(name != null
&& name.startsWith(NumberMethod.HIDDEN_PREFIX));
- dto.setPollId(entity.getPoll().getTopiaId());
+ dto.setPollUId(entity.getPoll().getPollId());
return dto;
}
@@ -166,7 +166,7 @@
public static PollDTO convert(Poll entity, PollDTO dto) {
BinderProvider.getBinder(Poll.class, PollDTO.class).copy(entity, dto);
dto.setId(entity.getTopiaId());
- dto.setPollId(entity.getPollId());
+ dto.setPollUId(entity.getPollId());
dto.setChoiceType(ChoiceType.valueOf(entity.getChoiceType()));
dto.setPollType(PollType.valueOf(entity.getPollType()));
dto.setVoteCounting(VoteCountingType.valueOf(entity.getVoteCounting()));
@@ -244,12 +244,17 @@
//if (!entity.getAnonymous()) {
PollAccount account = entity.getPollAccount();
VotingList list = entity.getVotingList();
+ // Set references
// vote for a list
if (list != null) {
dto.setVotingListId(list.getTopiaId());
// vote for a person (pollAccount)
- } else if (account != null) {
+ } else {/*if (account != null) { must have a pollaccount */
dto.setPollAccountId(account.getTopiaId());
+ dto.setName(account.getVotingId());
+// if (account.getUserAccount() != null) {
+// dto.setUserId(account.getUserAccount().getTopiaId());
+// }
}
//}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataChoiceConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataChoiceConverter.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataChoiceConverter.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -41,13 +41,16 @@
*
* @param choiceDTO Le dto choix
* @param eChoice L'entité choix
+ * @deprecated use {@link org.chorem.pollen.business.PollenConverter}
*/
+ @Deprecated
public void populateChoiceEntity(ChoiceDTO choiceDTO, Choice eChoice)
throws TopiaException {
eChoice.setName(choiceDTO.getName());
eChoice.setDescription(choiceDTO.getDescription());
eChoice.setValidate(choiceDTO.isValidate());
+ // Very bad, must create the choice on the poll not the inverse
if (choiceDTO.getPollId().length() > 0) {
PollDAO pollDAO = PollenModelDAOHelper
.getPollDAO(super.transaction);
@@ -61,7 +64,7 @@
*
* @param eChoice L'entité choix
* @return Le dto choix
- * @deprecated use {@link ConverterHelper}
+ * @deprecated use {@link org.chorem.pollen.business.PollenConverter}
*/
@Deprecated
public ChoiceDTO createChoiceDTO(Choice eChoice) {
@@ -75,7 +78,7 @@
choiceDTO.setValidate(eChoice.getValidate());
if (eChoice.getPoll() != null) {
- choiceDTO.setPollId(eChoice.getPoll().getTopiaId());
+ choiceDTO.setPollUId(eChoice.getPoll().getPollId());
}
return choiceDTO;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/ChoiceDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/ChoiceDTO.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/ChoiceDTO.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -61,6 +61,11 @@
*/
private String pollId = "";
+ /**
+ * pollUId of the poll owner of this choice
+ */
+ private String pollUId;
+
/** used for specific choice in Number VoteCounting **/
private Boolean hidden = false;
@@ -68,14 +73,16 @@
}
+ @Deprecated
public ChoiceDTO(String id) {
this.id = id;
}
+ @Deprecated
public ChoiceDTO(String name, String voteId, String pollId) {
this.name = name;
this.voteId = voteId;
- this.pollId = pollId;
+ //this.pollId = pollId;
}
public String getId() {
@@ -138,6 +145,14 @@
this.pollId = pollId;
}
+ public String getPollUId() {
+ return pollUId;
+ }
+
+ public void setPollUId(String pollUId) {
+ this.pollUId = pollUId;
+ }
+
public Boolean isHidden() {
return hidden;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -37,7 +37,7 @@
private String id = "";
- private String pollId = "";
+ private String pollUId;
private String title = "";
@@ -90,7 +90,7 @@
private List<PreventRuleDTO> preventRuleDTOs = new ArrayList<PreventRuleDTO>();
- private List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
+ private List<ChoiceDTO> choices = new ArrayList<ChoiceDTO>();
private List<ResultDTO> resultDTOs = new ArrayList<ResultDTO>();
@@ -120,12 +120,12 @@
this.id = id;
}
- public String getPollId() {
- return pollId;
+ public String getPollUId() {
+ return pollUId;
}
- public void setPollId(String pollId) {
- this.pollId = pollId;
+ public void setPollUId(String pollId) {
+ this.pollUId = pollId;
}
public String getTitle() {
@@ -384,20 +384,35 @@
}
public List<ChoiceDTO> getChoices() {
- return choiceDTOs;
+ return choices;
}
public void setChoices(List<ChoiceDTO> choiceDTOs) {
- this.choiceDTOs = choiceDTOs;
+ this.choices = choiceDTOs;
}
public void addChoice(ChoiceDTO choice) {
- if (choiceDTOs == null) {
- choiceDTOs = new ArrayList<ChoiceDTO>();
+ if (choices == null) {
+ choices = new ArrayList<ChoiceDTO>();
}
- choiceDTOs.add(choice);
+ choices.add(choice);
}
+ public boolean removeChoice(String choiceId) {
+ if (choices == null) {
+ return false;
+ }
+ Iterator<ChoiceDTO> it = choices.iterator();
+ while (it.hasNext()) {
+ ChoiceDTO choice = it.next();
+ if (choiceId.equals(choice.getId())) {
+ it.remove();
+ return true;
+ }
+ }
+ return false;
+ }
+
public List<ResultDTO> getResultDTOs() {
return resultDTOs;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoice.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -40,17 +40,6 @@
public String createChoice(ChoiceDTO choice);
/**
- * Création des choix du sondage
- *
- * @param choices les dtos choix
- * @param pollId l'identifiant du sondage
- * @param transaction la transaction du sondage
- * @return les choix créés
- */
- public List<Choice> createChoices(List<ChoiceDTO> choices, String pollId,
- TopiaContext transaction);
-
- /**
* Mise à jour d'un choix pour un sondage
*
* @param choiceDTO
@@ -63,7 +52,9 @@
*
* @param choiceId l'identifiant du choix
* @return true si le choix a été mis à jours
+ * @deprecated use {@link org.chorem.pollen.business.services.ServicePoll#deleteChoice(org.chorem.pollen.business.dto.PollDTO, java.lang.String) }
*/
+ @Deprecated
public boolean deleteChoice(String choiceId);
/**
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 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceChoiceImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -81,34 +81,34 @@
}
}
- @Override
- public List<Choice> createChoices(List<ChoiceDTO> choices, String pollId,
- TopiaContext transaction) {
- if (choices.isEmpty() || pollId.length() == 0) {
- return null;
- }
+// @Override
+// public List<Choice> createChoices(List<ChoiceDTO> choices, String pollId,
+// TopiaContext transaction) {
+// if (choices.isEmpty() || pollId.length() == 0) {
+// return null;
+// }
+//
+// List<Choice> result = null;
+// try {
+// choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
+// converter.setTransaction(transaction);
+//
+// result = new ArrayList<Choice>();
+// for (ChoiceDTO choice : choices) {
+// Choice choiceEntity = choiceDAO.create();
+// choice.setId(choiceEntity.getTopiaId());
+// //choice.setPollUId(pollId);
+// converter.populateChoiceEntity(choice, choiceEntity);
+// result.add(choiceEntity);
+// }
+//
+// return result;
+// } catch (Exception e) {
+// ContextUtil.doCatch(e, transaction);
+// return null;
+// }
+// }
- List<Choice> result = null;
- try {
- choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
- converter.setTransaction(transaction);
-
- result = new ArrayList<Choice>();
- for (ChoiceDTO choice : choices) {
- Choice choiceEntity = choiceDAO.create();
- choice.setId(choiceEntity.getTopiaId());
- choice.setPollId(pollId);
- converter.populateChoiceEntity(choice, choiceEntity);
- result.add(choiceEntity);
- }
-
- return result;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- }
- }
-
@Override
public boolean updateChoice(ChoiceDTO choiceDTO) {
TopiaContext transaction = null;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -18,6 +18,7 @@
import java.util.List;
import java.util.Map;
+import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.business.dto.CommentDTO;
import org.chorem.pollen.business.dto.PollAccountDTO;
import org.chorem.pollen.business.dto.PollDTO;
@@ -75,7 +76,7 @@
* @param pollId identifiant du sondage (différent du topiaId)
* @return le sondage
*/
- public PollDTO findPollByPollId(String pollId);
+ public PollDTO getPoll(String pollId);
/**
* Récupération des sondages d'un utilisateur
@@ -154,4 +155,8 @@
* pollAccount in poll restriction for the accountUId in argument
*/
public PollAccountDTO getRestrictedAccount(String accountUId, PollDTO poll);
+
+ public ChoiceDTO getNewHiddenChoice(ChoiceDTO choice, String votingId);
+
+ public void deleteChoice(PollDTO poll, String choiceId);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -17,9 +17,9 @@
package org.chorem.pollen.business.services;
import java.util.List;
-import java.util.Map;
import org.chorem.pollen.business.dto.PollAccountDTO;
+import org.chorem.pollen.business.dto.UserDTO;
import org.chorem.pollen.business.persistence.PollAccount;
import org.nuiton.topia.TopiaContext;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -18,20 +18,17 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.converters.DataPollAccountConverter;
import org.chorem.pollen.business.dto.PollAccountDTO;
+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;
import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.TopiaContext;
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -56,6 +56,7 @@
import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
+import org.chorem.pollen.votecounting.business.NumberMethod;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
@@ -77,7 +78,7 @@
private DataPollConverter converter = new DataPollConverter();
/** log. */
private static final Log log = LogFactory.getLog(ServicePollImpl.class);
-
+
public ServicePollImpl() {
rootContext = PollenContext.getRootContext();
@@ -95,12 +96,17 @@
TopiaContext transaction = null;
String result = null;
try {
+
+ if (log.isInfoEnabled()) {
+ log.info("P:[ createPoll ] : " + pollDTO);
+ }
+
transaction = rootContext.beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
// Create with the pollId from dto
- String pollId = pollDTO.getPollId();
+ String pollId = pollDTO.getPollUId();
Poll entity = pollDAO.create(pollId);
PollenConverter.convert(pollDTO, entity);
@@ -243,6 +249,11 @@
public boolean updatePoll(PollDTO pollDTO) {
TopiaContext transaction = null;
try {
+
+ if (log.isInfoEnabled()) {
+ log.info("P:[ updatePoll ] : " + pollDTO);
+ }
+
transaction = rootContext.beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
@@ -276,7 +287,7 @@
} catch (Exception eee) {
PollenContext.doCatch(transaction, eee,
n_("pollen.error.servicePoll.updatePoll"),
- pollDTO.getTitle(), pollDTO.getPollId());
+ pollDTO.getTitle(), pollDTO.getPollUId());
return false;
} finally {
PollenContext.doFinally(transaction);
@@ -288,7 +299,7 @@
PollDTO newPoll = new PollDTO();
newPoll.setVoteCounting(VoteCountingType.NORMAL);
newPoll.setPollType(PollType.FREE);
- newPoll.setPollId(PollenContext.createPollenUrlId());
+ newPoll.setPollUId(PollenContext.createPollenUrlId());
return newPoll;
}
@@ -302,6 +313,11 @@
public boolean deletePoll(String pollId) {
TopiaContext transaction = null;
try {
+
+ if (log.isInfoEnabled()) {
+ log.info("P:[ deletePoll ] : pollId = " + pollId);
+ }
+
transaction = rootContext.beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
@@ -326,12 +342,12 @@
}
@Override
- public PollDTO findPollByPollId(String pollId) {
+ public PollDTO getPoll(String pollId) {
TopiaContext transaction = null;
PollDTO result = null;
try {
if (log.isInfoEnabled()) {
- log.info("findPollByPollId : pollUId = " + pollId);
+ log.info("P:[ getPoll ] : pollUId = " + pollId);
}
transaction = rootContext.beginTransaction();
@@ -628,7 +644,7 @@
TopiaContext transaction = null;
try {
if (log.isInfoEnabled()) {
- log.info("createComment : pollUId = " + poll.getPollId() +
+ log.info("P:[ createComment ] : pollUId = " + poll.getPollUId() +
" _ comment = " + comment);
}
transaction = rootContext.beginTransaction();
@@ -665,7 +681,7 @@
TopiaContext transaction = null;
try {
if (log.isInfoEnabled()) {
- log.info("deleteComment : pollUId = " + poll.getPollId() +
+ log.info("P:[ deleteComment ] : pollUId = " + poll.getPollUId() +
" _ commentId = " + commentId);
}
transaction = rootContext.beginTransaction();
@@ -702,13 +718,13 @@
List<CommentDTO> results = new ArrayList<CommentDTO>();
try {
if (log.isInfoEnabled()) {
- log.info("getComments : pollUId = " + poll.getPollId());
+ log.info("P:[ getComments ] : pollUId = " + poll.getPollUId());
}
transaction = rootContext.beginTransaction();
CommentDAO dao = PollenModelDAOHelper.getCommentDAO(transaction);
TopiaQuery query = dao.createQuery().
- add(Comment.POLL + "." + Poll.POLL_ID, poll.getPollId());
+ add(Comment.POLL + "." + Poll.POLL_ID, poll.getPollUId());
List<Comment> entities = dao.findAllByQuery(query);
@@ -736,8 +752,8 @@
transaction = rootContext.beginTransaction();
if (log.isInfoEnabled()) {
- log.info("getRestrictedAccount : accountUId = " + accountUId +
- " _ pollUId = " + poll.getPollId());
+ log.info("P:[ getRestrictedAccount ] : accountUId = " + accountUId +
+ " _ pollUId = " + poll.getPollUId());
}
// Use PersonToList association entity to find coherence between
@@ -755,7 +771,7 @@
add(PersonToList.POLL_ACCOUNT + "." +
PollAccount.ACCOUNT_ID, accountUId).
add(PersonToList.VOTING_LIST + "." +
- VotingList.POLL + "." + Poll.POLL_ID, poll.getPollId());
+ VotingList.POLL + "." + Poll.POLL_ID, poll.getPollUId());
PersonToList assoc = dao.findByQuery(query);
@@ -767,10 +783,59 @@
} catch (Exception eee) {
PollenContext.doCatch(transaction, eee,
n_("pollen.error.servicePoll.getRestrictedAccount"),
- accountUId, poll.getPollId());
+ accountUId, poll.getPollUId());
} finally {
PollenContext.doFinally(transaction);
}
return result;
}
+
+ @Override
+ public ChoiceDTO getNewHiddenChoice(ChoiceDTO choice, String votingId) {
+ ChoiceDTO hiddenChoice = new ChoiceDTO();
+ hiddenChoice.setName(NumberMethod.HIDDEN_PREFIX +
+ choice.getName() + "#" + votingId);
+ hiddenChoice.setHidden(true);
+ hiddenChoice.setValue(choice.getValue()); // ??
+ hiddenChoice.setPollUId(choice.getPollUId());
+ hiddenChoice.setVoteId(choice.getVoteId()); // ??
+ hiddenChoice.setValidate(false);
+ return hiddenChoice;
+ }
+
+ @Override
+ public void deleteChoice(PollDTO poll, String choiceId) {
+ TopiaContext transaction = null;
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("P:[ deleteChoice ] : pollUId = " + poll.getPollUId() +
+ " _ choiceId = " + choiceId);
+ }
+ transaction = rootContext.beginTransaction();
+
+ // Find the comment
+ ChoiceDAO dao = PollenModelDAOHelper.getChoiceDAO(transaction);
+ Choice eChoice = dao.findByTopiaId(choiceId);
+
+ // Get the poll entity corresponding
+ Poll ePoll = PollenModelDAOHelper.getPollDAO(transaction).
+ findByTopiaId(poll.getId());
+
+ // The remove will delete the choice because no poll will be
+ // attached to him (delete-orphan)
+ ePoll.removeChoice(eChoice);
+
+ transaction.commitTransaction();
+
+ // Update change in dto
+ poll.removeChoice(choiceId);
+
+ } catch (Exception eee) {
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.deleteChoice"), choiceId,
+ poll.getTitle(), poll.getId());
+ } finally {
+ PollenContext.doFinally(transaction);
+ }
+ }
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVote.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -21,6 +21,7 @@
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.dto.VoteDTO;
/**
@@ -68,6 +69,8 @@
public List<VoteDTO> getVotesByPoll(PollDTO poll,
int startIndex, int endIndex);
+ public PollAccountDTO getNewPollAccount(UserDTO user);
+
/**
* Test if the {@code votingId} has already voted for the {@code poll}.
*
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 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -23,10 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenConverter;
import org.chorem.pollen.business.converters.DataPollAccountConverter;
import org.chorem.pollen.business.converters.DataVoteConverter;
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.dto.VoteDTO;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
@@ -56,6 +58,8 @@
public ServiceVoteImpl() {
rootContext = PollenContext.getRootContext();
+
+ PollenConverter.prepareVoteConverters();
}
@Override
@@ -195,7 +199,8 @@
List<VoteDTO> results = new ArrayList<VoteDTO>();
try {
if (log.isInfoEnabled()) {
- log.info("getVotesByPoll : pollUId = " + poll.getPollId() +
+ log.info("P:[ getVotesByPoll ] : " +
+ "pollUId = " + poll.getPollUId() +
" _ startIndex = " + startIndex +
" _ endIndex = " + endIndex);
}
@@ -221,22 +226,26 @@
// Order the results by creation date (the last vote done will be
// at the end of the list)
TopiaQuery query = voteDAO.createQuery().
- add(Vote.POLL + "." + Poll.POLL_ID, poll.getPollId()).
+ add(Vote.POLL + "." + Poll.POLL_ID, poll.getPollUId()).
addOrder(TopiaEntity.TOPIA_CREATE_DATE).
setLimit(startIndex, endIndex);
- List<Vote> votes = voteDAO.findAllByQuery(query);
+ List<Vote> eVotes = voteDAO.findAllByQuery(query);
if (log.isDebugEnabled()) {
- log.debug("Nb votes found : " + votes.size());
+ log.debug("Nb votes found : " + eVotes.size());
}
- converter.setTransaction(transaction);
- results = converter.createVoteDTOs(votes);
+ for (Vote eVote : eVotes) {
+ VoteDTO vote = PollenConverter.convert(eVote, new VoteDTO());
+ results.add(vote);
+ }
+// converter.setTransaction(transaction);
+// results = converter.createVoteDTOs(votes);
} catch (Exception eee) {
PollenContext.doCatch(transaction, eee,
n_("pollen.error.serviceVote.getVotesByPoll"),
- poll.getPollId());
+ poll.getPollUId());
} finally {
PollenContext.doFinally(transaction);
}
@@ -244,13 +253,32 @@
}
@Override
+ public PollAccountDTO getNewPollAccount(UserDTO user) {
+ PollAccountDTO result = new PollAccountDTO();
+ if (user == null) {
+ return result;
+ }
+ if (user.getFirstName() != null && user.getLastName() != null) {
+ result.setVotingId(
+ user.getFirstName() + " " + user.getLastName());
+
+ } else if (user.getFirstName() != null) {
+ result.setVotingId(user.getFirstName());
+
+ } else if (user.getLastName() != null) {
+ result.setVotingId(user.getLastName());
+ }
+ return result;
+ }
+
+ @Override
public boolean hasAlreadyVoted(String votingId, PollDTO poll) {
TopiaContext transaction = null;
boolean result = false;
try {
if (log.isInfoEnabled()) {
- log.info("hasAlreadyVoted : votingId = " + votingId +
- " _ pollUId = " + poll.getPollId());
+ log.info("P:[ hasAlreadyVoted ] : votingId = " + votingId +
+ " _ pollUId = " + poll.getPollUId());
}
transaction = rootContext.beginTransaction();
@@ -265,7 +293,7 @@
// Test using a count on votes
TopiaQuery query = new TopiaQuery(Vote.class).
- add(Vote.POLL + "." + Poll.POLL_ID, poll.getPollId()).
+ add(Vote.POLL + "." + Poll.POLL_ID, poll.getPollUId()).
add(Vote.POLL_ACCOUNT + "." + PollAccount.VOTING_ID,
votingId);
@@ -278,7 +306,7 @@
} catch (Exception eee) {
PollenContext.doCatch(transaction, eee,
n_("pollen.error.serviceVote.hasAlreadyVoted"),
- votingId, poll.getPollId());
+ votingId, poll.getPollUId());
} finally {
PollenContext.doFinally(transaction);
}
@@ -298,8 +326,7 @@
if (properties == null) {
voteEntities = voteDAO.findAll();
if (log.isWarnEnabled()) {
- log
- .warn("Attention : tous les votes ont été sélectionnés !");
+ log.warn("Attention : tous les votes ont été sélectionnés !");
}
} else {
voteEntities = voteDAO.findAllByProperties(properties);
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -9,6 +9,7 @@
pollen.error.servicePoll.addComment=
pollen.error.servicePoll.createPoll=
pollen.error.servicePoll.delete=
+pollen.error.servicePoll.deleteChoice=
pollen.error.servicePoll.deleteComment=
pollen.error.servicePoll.deletePoll=
pollen.error.servicePoll.getAllPolls=
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -8,6 +8,7 @@
pollen.error.serviceList.deleteAccountFromPersonList=
pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire cr\u00E9\u00E9 par %1$s pour le sondage %2$s (%3$s)
pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s cr\u00E9\u00E9 par %2$s
+pollen.error.servicePoll.deleteChoice=
pollen.error.servicePoll.deleteComment=Impossible de supprimer le commentaire ayant pour identifiant "%1$s", appartenenant au sondage %2$s (%3$s)
pollen.error.servicePoll.deletePoll=Impossible de supprimer le sondage ayant pou identifiant "%1$s"
pollen.error.servicePoll.getAllPolls=
Modified: trunk/pollen-business/src/main/resources/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/resources/pollen.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/main/resources/pollen.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -20,7 +20,7 @@
topia.service.migration.mappingsdir=oldmappings
topia.service.migration.modelnames=pollen
-## Initialisation de la base de donn\u00C3\u00A9es
+## Initialisation de la base de donn\u00E9es
#choiceType=DATE,IMAGE,TEXT
#pollType=RESTRICTED,FREE,GROUP
#voteCounting=NORMAL,PERCENTAGE,CONDORCET,NUMBER
@@ -31,7 +31,7 @@
adminEmail=admin(a)domain.com
## R\u00C3\u00A9pertoire des images transf\u00C3\u00A9r\u00C3\u00A9es
-upImgDir=.pollen/uploadedImages
+upImgDir=${HOME}/.pollen/uploadedImages
## Taille maximal des images transf\u00C3\u00A9r\u00C3\u00A9es (en octets)
upload.filesize-max=1048576
@@ -42,11 +42,11 @@
email_port=25
email_from=bot(a)pollen.org
-## R\u00C3\u00A9pertoire des flux de syndication (Atom)
-feedDir=.pollen/feeds
+## R\u00E9pertoire des flux de syndication (Atom)
+feedDir=${HOME}/.pollen/feeds
## Repertoire de stockage des mails a envoyer
-pollen.emails.directory=.pollen/emails
+pollen.emails.directory=${HOME}/.pollen/emails
## Nombre de votes a afficher par page
pollen.ui.nbVotesPerPage=25
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -47,6 +47,7 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.nuiton.util.beans.BinderProvider;
/**
* Tests du service de gestion des sondages.
@@ -78,6 +79,7 @@
@After
public void tearDown() throws IOException {
TestManager.stop();
+ BinderProvider.clear();
}
/**
@@ -203,9 +205,9 @@
dto.setChoiceType(ChoiceType.TEXT);
dto.setVoteCounting(VoteCountingType.NORMAL);
pollId = instance.createPoll(dto);
- String pollUID = dto.getPollId();
+ String pollUID = dto.getPollUId();
log.debug("pollUID : " + pollUID);
- PollDTO result = instance.findPollByPollId(pollUID);
+ PollDTO result = instance.getPoll(pollUID);
log.debug("title : " + result.getTitle());
assertEquals(pollId, result.getId());
assertEquals(VoteCountingType.NORMAL, result.getVoteCounting());
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/ContextLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/ContextLink.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/ContextLink.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -21,16 +21,16 @@
/**
* ContextPath for the link
+ *
* @return a String contextPath
- * @
*/
public String getContextPath() ;
/**
* Get a file from context with name defined by filename.
+ *
* @param filename name of the file to get
* @return a File with absolutePath corresponding to contextPath + filename
- * @
*/
public File getFile(String filename) ;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -135,7 +135,7 @@
public String getAdminId() {
PollAccountDTO creator = servicePollAccount.findPollAccountById(poll
.getCreatorId());
- return poll.getPollId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountId();
}
/**
@@ -170,7 +170,7 @@
}
confirmPoll.setBackPage(backPage);
confirmPoll.setAction(pollAction);
- confirmPoll.setPoll(servicePoll.findPollByPollId(pollId));
+ confirmPoll.setPoll(servicePoll.getPoll(pollId));
return confirmPoll;
}
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 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -49,7 +49,9 @@
*
* @author rannou
* @version $Id$
+ * @deprecated use links + event + serviceImage depends on page
*/
+@Deprecated
public class Image extends ImageContextLink {
/** Chemin de l'image */
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -34,7 +34,9 @@
*
* Mise a jour: $Date$
* par : $Author$
+ * @deprecated use {@link org.chorem.pollen.ui.services.ServiceImage } instead
*/
+@Deprecated
public class ImageContextLink implements ContextLink {
public static final String THUMB_PREFIX = "thumb_";
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -92,6 +92,7 @@
void beginRender(MarkupWriter writer) {
if (log.isDebugEnabled()) {
log.debug("pager from : " + getFirstValue() + " to " + getLastValue());
+ log.debug("nb rows per page : " + nbRowsPerPage);
log.debug("current page : " + currentPage);
log.debug("max nb rows : " + nbTotalRows);
log.debug("has previous : " + hasPrevious());
@@ -101,7 +102,7 @@
}
writer.element("div", "class", "p-pager");
// If firstPage and lastPage are the same, no need to use the pager
- if (getFirstPage() == getLastPage()) {
+ if (getFirstPage() >= getLastPage()) {
writer.write(noPagerText);
} else {
if (hasPrevious()) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -7,11 +7,13 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.fileupload.FileUploadException;
+import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.upload.services.UploadedFile;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.dto.ChoiceDTO;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.ui.utils.ImageUtil;
+import org.nuiton.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,6 +35,7 @@
*
* @author fdesbois
* @version $Revision$
+ * @since 1.3
*
* Mise a jour: $Date$
* par : $Author$
@@ -43,26 +46,57 @@
protected ChoiceType type;
- protected DateFormat dateFormat;
-
protected Date date;
protected UploadedFile image;
+ protected String imageFileName;
+
protected String imageDir;
protected String text;
+ public ChoiceField() {
+
+ }
+
+ public ChoiceField(ChoiceDTO dto, ChoiceType type) {
+ if (log.isDebugEnabled()) {
+ log.debug("Instanciate ChoiceField : type = " + type +
+ " _ name = " + dto.getName());
+ }
+ switch (type) {
+ case DATE:
+ setDateType();
+ setDate(new Date(Long.parseLong(dto.getName())));
+ break;
+ case TEXT:
+ setTextType();
+ setText(dto.getName());
+ break;
+ case IMAGE:
+ setImageType(dto.getPollUId());
+ setImageFileName(dto.getName());
+ }
+ setDescription(dto.getDescription());
+ setHidden(dto.getHidden());
+ setId(dto.getId());
+ setValidate(dto.getValidate());
+ setPollUId(dto.getPollUId());
+ setName(dto.getName());
+ //setValue(dto.getValue());
+ //setVoteId(dto.getVoteId());
+ }
+
/**
* Instantiate a new choiceField for a Date ChoiceType.
*
- * @param pattern date pattern to format the date when name will be saved
* @return the ChoiceField which is date typed
* @see #setDateType(java.lang.String)
*/
- public static ChoiceField getChoiceDate(String pattern) {
+ public static ChoiceField getChoiceDate() {
ChoiceField result = new ChoiceField();
- result.setDateType(pattern);
+ result.setDateType();
return result;
}
@@ -96,12 +130,10 @@
* Change type of the choice to date type. The date type need a
* {@code pattern} to format the date when saving the choice.
*
- * @param pattern
* @see #saveName()
*/
- public void setDateType(String pattern) {
+ public void setDateType() {
this.type = ChoiceType.DATE;
- dateFormat = new SimpleDateFormat(pattern);
image = null;
}
@@ -149,6 +181,21 @@
return image;
}
+ public void setImageFileName(String filename) {
+ this.imageFileName = filename;
+ }
+
+ public String getImageFileName() {
+ if (imageFileName == null && image != null) {
+ imageFileName = image.getFileName();
+ }
+ return imageFileName;
+ }
+
+ public String getImageDir() {
+ return imageDir;
+ }
+
public void setText(String text) {
this.text = text;
}
@@ -160,7 +207,7 @@
/**
* Save name of the choice depends on ChoiceType :
* <pre>
- * - DATE : the date will be formated ;
+ * - DATE : the date will be formated (only full time is used) ;
* - IMAGE : the image file will be saved and the choice name will
* correspond to the image file name ;
* - TEXT : the text becomes the choice name.
@@ -169,29 +216,29 @@
public void saveName() {
String name = "";
switch (type) {
- case DATE:
- name = dateFormat.format(getDate());
+ case DATE:
+ name = String.valueOf(date.getTime());
break;
case IMAGE:
- // Get directory to save the image using the context from
- // pollen properties.
- File dir = new File(PollenProperty.IMG_DIR.getValue(), imageDir);
- if (!dir.exists()) {
- dir.mkdirs();
- }
- // Save the image file
- File file = new File(dir, image.getFileName());
- image.write(file);
- if (log.isDebugEnabled()) {
- log.debug("Image saved: " + image.getFileName() +
- " (size=" + image.getSize() + ")");
- }
- // Create image thumbnail
- ImageUtil.createThumbnail(dir, file, 100);
- if (log.isDebugEnabled()) {
- log.debug("save name for image : " + file.getName());
- }
- name = file.getName();
+// // Get directory to save the image using the context from
+// // pollen properties.
+// File dir = new File(PollenProperty.IMG_DIR.getValue(), imageDir);
+// if (!dir.exists()) {
+// dir.mkdirs();
+// }
+// // Save the image file
+// File file = new File(dir, getImageFileName());
+// image.write(file);
+// if (log.isDebugEnabled()) {
+// log.debug("Image saved: " + getImageFileName() +
+// " (size=" + image.getSize() + ")");
+// }
+// // Create image thumbnail
+// ImageUtil.createThumbnail(dir, file, 100);
+// if (log.isDebugEnabled()) {
+// log.debug("save name for image : " + file.getName());
+// }
+ //name = serviceImage.saveImage(getImage(), getImageDir());
break;
case TEXT:
name = getText();
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -0,0 +1,47 @@
+package org.chorem.pollen.ui.mixins;
+
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.AfterRender;
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * Confirm.java
+ *
+ * A simple mixin for attaching a javascript confirmation box to the onclick
+ * event of any component that implements ClientElement.
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author: fdesbois $
+ */
+@IncludeJavaScriptLibrary("context:js/confirm.js")
+public class Confirm {
+
+ @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.MESSAGE)
+ private String message;
+
+ @Inject
+ private RenderSupport renderSupport;
+
+ @InjectContainer
+ private ClientElement element;
+
+ @Parameter
+ private boolean wDisabled;
+
+ @AfterRender
+ public void afterRender() {
+ if (!wDisabled) {
+ renderSupport.addScript(String.format("new Confirm('%s', '%s');",
+ element.getClientId(), message));
+ }
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/Confirm.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/mixins/ZoneUpdater.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -43,7 +43,7 @@
* Last update: $Date$
* by : $Author: fdesbois $
*/
-@IncludeJavaScriptLibrary("context:js/ZoneUpdater.js")
+@IncludeJavaScriptLibrary("context:js/zoneUpdater.js")
public class ZoneUpdater {
public static final String PLACEHOLDER = "XXX";
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -103,7 +103,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getPollId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountId();
}
void onActivate() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -103,7 +103,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getPollId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountId();
}
void onActivate() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -103,7 +103,7 @@
* @return l'identifiant.
*/
public String getAdminId() {
- return poll.getPollId() + ":" + creator.getAccountId();
+ return poll.getPollUId() + ":" + creator.getAccountId();
}
void onActivate() {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -73,8 +73,8 @@
import org.chorem.pollen.ui.data.PollStep;
import org.chorem.pollen.ui.data.uio.DateChoiceUIO;
import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
+import org.chorem.pollen.ui.services.ServiceImage;
import org.chorem.pollen.ui.utils.FeedUtil;
-import org.chorem.pollen.ui.utils.ImageUtil;
import org.chorem.pollen.ui.utils.UnitConverter;
import org.slf4j.Logger;
@@ -371,7 +371,7 @@
/**
* Méthode appelée lorsqu'on souhaite valider la création du sondage.
*/
- Object onSuccessFromChoicesCreationForm() {
+ Object onSuccessFromChoicesCreationForm() throws FileUploadException {
if (!addChoiceSelected) {
// Préparation et création du sondage
@@ -741,13 +741,14 @@
return true;
}
+ @Inject
+ private ServiceImage serviceImage;
+
/**
* Création du sondage.
*/
- private void createPoll() {
+ private void createPoll() throws FileUploadException {
- // Création du sondage
- servicePoll.createPoll(poll);
// FD-20100226 : Can't be null, an exception will be thrown if a
// problem comes from createPoll
@@ -755,10 +756,24 @@
// Création des images
if (poll.getChoiceType() == ChoiceType.IMAGE) {
- File dir = imgContext.getImageDir();
- ImageUtil.saveImages(imgTypeChoices, dir);
+ for (ImageChoiceUIO image : imgTypeChoices) {
+ if (image.getImg() != null) {
+// String contentType = image.getImg().getContentType();
+// if (!contentType.equals("image") ||
+// !contentType.equals("IMAGE")) {
+// throw new FileUploadException("wrong type for image upload");
+// }
+ serviceImage.saveImage(image.getImg(), poll.getPollUId());
+ }
+ }
+ //File dir = imgContext.getImageDir();
+ //ImageUtil.saveImages(imgTypeChoices, dir);
}
+
+ // Création du sondage
+ servicePoll.createPoll(poll);
+
// FD-20100226 : not necessary, the service will update
// automatically the poll when it was created
// Mise à jour du sondage :
@@ -790,8 +805,8 @@
/** Ajout d'une entrée dans le flux de syndication */
private void addFeedEntry() {
PollAccountDTO creator = servicePollAccount.findPollAccountById(poll.getCreatorId());
- String voteURL = siteURL + "poll/votefor/" + poll.getPollId();
- File feedFile = feedContext.getFile(poll.getPollId());
+ String voteURL = siteURL + "poll/votefor/" + poll.getPollUId();
+ File feedFile = feedContext.getFile(poll.getPollUId());
FeedUtil.createFeed(feedFile, "atom_1.0", messages.format(
"pollFeed_title", poll.getTitle()), siteURL, messages.format(
@@ -804,8 +819,8 @@
private void sendMailNotification(String siteURL, ServicePollAccount servicePollAccount,
PollDTO poll, Messages messages) {
PollAccountDTO creator = servicePollAccount.findPollAccountById(poll.getCreatorId());
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
- String modifURL = siteURL + "poll/Modification/" + poll.getPollId() + ":" + creator.getAccountId();
+ String voteURL = siteURL + "poll/VoteFor/" + poll.getPollUId();
+ String modifURL = siteURL + "poll/Modification/" + poll.getPollUId() + ":" + creator.getAccountId();
Map<String, String> data = new HashMap<String, String>();
data.put("host", PollenProperty.EMAIL_HOST.getValue());
data.put("port", PollenProperty.EMAIL_PORT.getValue());
@@ -1161,8 +1176,8 @@
// Réinitialisation des variables de session
// Si l'ancien sondage n'existe pas ou est différent de celui fourni
- if (oldPoll == null || !id.equals(oldPoll.getPollId())) {
- oldPoll = servicePoll.findPollByPollId(id);
+ if (oldPoll == null || !id.equals(oldPoll.getPollUId())) {
+ oldPoll = servicePoll.getPoll(id);
if (oldPoll != null) {
initWithExistingPoll(oldPoll);
oldPoll = null;
@@ -1198,7 +1213,8 @@
private void initPoll() {
// Initialisation du sondage
- poll = new PollDTO();
+ //poll = new PollDTO();
+ poll = servicePoll.getNewPoll();
if (userExists) {
poll.setCreatorName(user.getLogin());
poll.setCreatorEmail(user.getEmail());
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -108,7 +108,7 @@
if (log.isDebugEnabled()) {
log.debug("Get existing poll with pollUID = " + pollUID);
}
- poll = servicePoll.findPollByPollId(pollUID);
+ poll = servicePoll.getPoll(pollUID);
// TODO : init advancedOptions
} else {
if (log.isDebugEnabled()) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -532,7 +532,7 @@
/** Envoi du mail de notification */
private void sendMailNotification(List<PollAccountDTO> modifiedAccounts) {
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
+ String voteURL = siteURL + "poll/VoteFor/" + poll.getPollUId();
Map<String, String> data = new HashMap<String, String>();
data.put("host", PollenProperty.EMAIL_HOST.getValue());
data.put("port", PollenProperty.EMAIL_PORT.getValue());
@@ -592,8 +592,8 @@
String pollId = id.split(":", 2)[0];
// Réinitialisation des variables de session
- if (poll == null || !pollId.equals(poll.getPollId())) {
- poll = servicePoll.findPollByPollId(pollId);
+ if (poll == null || !pollId.equals(poll.getPollUId())) {
+ poll = servicePoll.getPoll(pollId);
creator = null;
newRule = null;
}
@@ -649,7 +649,7 @@
// Réinitialisation des variables de session
if (poll != null) {
- poll = servicePoll.findPollByPollId(poll.getPollId());
+ poll = servicePoll.getPoll(poll.getPollUId());
creator = servicePollAccount.findPollAccountById(poll
.getCreatorId());
initNotificationRule();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -366,9 +366,9 @@
ResultListDTO resultListDTO = null;
if (byGroup) {
- resultListDTO = serviceResults.getGroupResults(poll.getPollId());
+ resultListDTO = serviceResults.getGroupResults(poll.getPollUId());
} else {
- resultListDTO = serviceResults.getNormalResults(poll.getPollId());
+ resultListDTO = serviceResults.getNormalResults(poll.getPollUId());
}
results = resultListDTO.getResultDTOs();
@@ -471,7 +471,7 @@
if (id != null && !"".equals(id)) {
pollId = id.split(":", 2)[0];
- poll = servicePoll.findPollByPollId(pollId);
+ poll = servicePoll.getPoll(pollId);
if (poll != null) {
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -25,10 +25,13 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.UUID;
import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.ValidationException;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
@@ -42,11 +45,9 @@
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.corelib.components.Form;
-import org.apache.tapestry5.corelib.components.TextField;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.util.AbstractMessages;
import org.apache.tapestry5.upload.services.UploadedFile;
import org.chenillekit.tapestry.core.components.DateTimeField;
import org.chorem.pollen.business.PollenBusinessException;
@@ -77,14 +78,15 @@
import org.chorem.pollen.ui.components.ImageContextLink;
import org.chorem.pollen.ui.components.Pager;
import org.chorem.pollen.ui.data.AddressBar;
+import org.chorem.pollen.ui.data.ChoiceField;
import org.chorem.pollen.ui.data.EvenOdd;
import org.chorem.pollen.ui.data.PollAction;
import org.chorem.pollen.ui.data.PollUri;
import org.chorem.pollen.ui.data.uio.DateChoiceUIO;
import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
+import org.chorem.pollen.ui.services.ServiceImage;
import org.chorem.pollen.ui.utils.FeedUtil;
import org.chorem.pollen.ui.utils.ImageUtil;
-import org.chorem.pollen.votecounting.business.NumberMethod;
import org.slf4j.Logger;
/**
@@ -112,13 +114,6 @@
@Component(id = "feedback")
private FeedBack feedback;
- /**
- * Objet de session représentant l'utilisateur identifié.
- */
- @SessionState
- private UserDTO user;
- @Property
- private boolean userExists;
/**
* Objet de session représentant l'url du site.
@@ -130,8 +125,8 @@
@Component
private Form voteForm;
- @Component(id = "pollAccountName")
- private TextField nameField;
+// @Component(id = "pollAccountName")
+// private TextField nameField;
/** Composant DateTimeField pour les choix du sondage */
@SuppressWarnings("unused")
@@ -176,8 +171,8 @@
/*@InjectPage
private ImageDisplay imageDisplay;*/
- @InjectComponent
- private Zone pollZone;
+// @InjectComponent
+// private Zone pollZone;
/**
* Objet servant à changer la couleur à chaque ligne de la liste des
@@ -201,11 +196,11 @@
// private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>();
/** Identifiant du compte correspondant à l'adresse forgée */
- private String pollAccountId;
+// private String pollAccountId;
/** Compte du votant */
- @Property
- private PollAccountDTO pollAccount;
+// @Property
+// private PollAccountDTO pollAccount;
/** Nouveau choix de type texte */
@Property
@@ -275,239 +270,236 @@
}
/** Méthode appelée après la soumission du vote. */
- @Log
- Object onSuccessFromVoteForm() throws PollenBusinessException {
- if (initPollAccount()) {
- List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
- if (getPoll().getVoteCounting() == VoteCountingType.NORMAL) {
- int nbChoices = 0;
- for (ChoiceDTO choice : getPoll().getChoices()) {
- if (choice.getValue() == 1) {
- nbChoices++;
- }
- choiceDTOs.add(choice);
- }
- if (nbChoices > getPoll().getMaxChoiceNb()) {
- voteForm.recordError(messages.format(("tooManyChoices"),
- getPoll().getMaxChoiceNb()));
- return pollZone.getBody();
- }
-
- } else if (getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE) {
- int total = 0;
- for (ChoiceDTO choice : getPoll().getChoices()) {
- total = total + choice.getValue();
- choiceDTOs.add(choice);
- }
- if (total != 100) {
- voteForm.recordError(messages.get("not100percent"));
- return pollZone.getBody();
- }
-
- } else if (getPoll().getVoteCounting() == VoteCountingType.CONDORCET) {
- for (ChoiceDTO choice : getPoll().getChoices()) {
- if (choice.getValue() == 0) {
- choice.setValue(100);
- }
- choiceDTOs.add(choice);
- }
-
- } else if (getPoll().getVoteCounting() == VoteCountingType.NUMBER) {
- String votingId = pollAccount.getVotingId();
- if (anonymousVote) {
- votingId = "anonymous" + UUID.randomUUID().toString().replaceAll("-", "");
- }
-
- for (ChoiceDTO choice : getPoll().getChoices()) {
- if (!choice.isHidden()) {
- choiceDTOs.add(choice);
-
- // creates a new hidden choice
- ChoiceDTO hiddenChoice = new ChoiceDTO();
- hiddenChoice.setName(NumberMethod.HIDDEN_PREFIX +
- choice.getName() + "#" + votingId);
- hiddenChoice.setHidden(true);
- hiddenChoice.setValue(choice.getValue());
- hiddenChoice.setPollId(choice.getPollId());
- hiddenChoice.setVoteId(choice.getVoteId());
- hiddenChoice.setValidate(false);
-
- String choiceId = serviceChoice.createChoice(hiddenChoice);
- hiddenChoice.setId(choiceId);
- choiceDTOs.add(hiddenChoice);
- }
- }
- }
-
- VoteDTO vote = new VoteDTO(null, getPoll().getId(), null);
- vote.setChoiceDTOs(choiceDTOs);
- vote.setWeight(pollAccount.getWeight());
- vote.setAnonymous(anonymousVote);
-
- // mise à jour du vote ou création d'un nouveau vote
- if (alreadyVoted) {
- for (VoteDTO v : getVotes()) {
- PollAccountDTO voteAccount = servicePollAccount
- .findPollAccountById(v.getPollAccountId());
-
- if (voteAccount.getVotingId().equals(pollAccount.getVotingId())) {
- vote.setId(v.getId());
- deleteVote(vote.getId());
- serviceVote.createVote(vote, pollAccount);
- }
- }
- } else {
- serviceVote.createVote(vote, pollAccount);
- }
-
- // Mise à jour du sondage et des résultats
- //poll = servicePoll.findPollByPollId(getPoll().getPollId());
- poll = null;
- countPoll();
-
- addFeedEntry(PollAction.ADDVOTE, pollAccount.getVotingId(),
- getResultsAsString());
- sendMailNotification();
- voteFeedback.addInfo(messages.get("vote-success"));
- page = pager.getLastPage();
- // Reset votes to reload them depends on page change.
- votes = null;
- return this;
- }
-// voteChoices.clear();
- return pollZone.getBody();
- }
+// @Log
+// Object onSuccessFromVoteForm() throws PollenBusinessException {
+// if (initPollAccount()) {
+// List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
+// if (getPoll().getVoteCounting() == VoteCountingType.NORMAL) {
+// int nbChoices = 0;
+// for (ChoiceDTO choice : getPoll().getChoices()) {
+// if (choice.getValue() == 1) {
+// nbChoices++;
+// }
+// choiceDTOs.add(choice);
+// }
+// if (nbChoices > getPoll().getMaxChoiceNb()) {
+// voteForm.recordError(messages.format(("tooManyChoices"),
+// getPoll().getMaxChoiceNb()));
+// return pollZone.getBody();
+// }
+//
+// } else if (getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE) {
+// int total = 0;
+// for (ChoiceDTO choice : getPoll().getChoices()) {
+// total = total + choice.getValue();
+// choiceDTOs.add(choice);
+// }
+// if (total != 100) {
+// voteForm.recordError(messages.get("not100percent"));
+// return pollZone.getBody();
+// }
+//
+// } else if (getPoll().getVoteCounting() == VoteCountingType.CONDORCET) {
+// for (ChoiceDTO choice : getPoll().getChoices()) {
+// if (choice.getValue() == 0) {
+// choice.setValue(100);
+// }
+// choiceDTOs.add(choice);
+// }
+//
+// } else if (getPoll().getVoteCounting() == VoteCountingType.NUMBER) {
+// String votingId = pollAccount.getVotingId();
+// if (anonymousVote) {
+// votingId = "anonymous" + UUID.randomUUID().toString().replaceAll("-", "");
+// }
+//
+// for (ChoiceDTO choice : getPoll().getChoices()) {
+// if (!choice.isHidden()) {
+// choiceDTOs.add(choice);
+//
+// // creates a new hidden choice
+//// ChoiceDTO hiddenChoice = new ChoiceDTO();
+//// hiddenChoice.setName(NumberMethod.HIDDEN_PREFIX +
+//// choice.getName() + "#" + votingId);
+//// hiddenChoice.setHidden(true);
+//// hiddenChoice.setValue(choice.getValue());
+//// hiddenChoice.setPollId(choice.getPollId());
+//// hiddenChoice.setVoteId(choice.getVoteId());
+//// hiddenChoice.setValidate(false);
+// ChoiceDTO hiddenChoice =
+// servicePoll.getNewHiddenChoice(choice, votingId);
+//
+// String choiceId =
+// serviceChoice.createChoice(hiddenChoice);
+// hiddenChoice.setId(choiceId);
+// choiceDTOs.add(hiddenChoice);
+// }
+// }
+// }
+//
+// VoteDTO vote = new VoteDTO(null, getPoll().getId(), null);
+// vote.setChoiceDTOs(choiceDTOs);
+// vote.setWeight(pollAccount.getWeight());
+// vote.setAnonymous(anonymousVote);
+//
+// // mise à jour du vote ou création d'un nouveau vote
+// if (alreadyVoted) {
+// for (VoteDTO v : getVotes()) {
+// PollAccountDTO voteAccount = servicePollAccount
+// .findPollAccountById(v.getPollAccountId());
+//
+// if (voteAccount.getVotingId().equals(getPollAccount().getVotingId())) {
+// vote.setId(v.getId());
+// deleteVote(vote.getId());
+// serviceVote.createVote(vote, getPollAccount());
+// }
+// }
+// } else {
+// serviceVote.createVote(vote, getPollAccount());
+// }
+//
+// // Mise à jour du sondage et des résultats
+// //poll = servicePoll.findPollByPollId(getPoll().getPollId());
+// poll = null;
+// countPoll();
+//
+// addFeedEntry(PollAction.ADDVOTE, getPollAccount().getVotingId(),
+// getResultsAsString());
+// sendMailNotification();
+// voteFeedback.addInfo(messages.get("vote-success"));
+// page = pager.getLastPage();
+// // Reset votes to reload them depends on page change.
+// votes = null;
+// return this;
+// }
+//// voteChoices.clear();
+// return pollZone.getBody();
+// }
- private void deleteVote(String voteId) throws PollenBusinessException {
- for (VoteDTO vote : getVotes()) {
- if (vote.getId().equals(voteId)) {
+// private void deleteVote(String voteId) throws PollenBusinessException {
+// for (VoteDTO vote : getVotes()) {
+// if (vote.getId().equals(voteId)) {
+//
+// List<ChoiceDTO> choiceDTOs = vote.getChoiceDTOs();
+// for (ChoiceDTO choiceDTO : choiceDTOs) {
+//
+// if (choiceDTO.isHidden()) {
+// serviceChoice.deleteChoice(choiceDTO.getId());
+// }
+// }
+//
+// break;
+// }
+// }
+//
+// serviceVote.deleteVote(voteId);
+// }
+//
+// /** Méthode appelée lors de la suppression d'un vote. */
+// Object onActionFromDeleteVote(String voteId) throws PollenBusinessException {
+// deleteVote(voteId);
+//
+// // Mise à jour du sondage et des résultats
+//// poll = servicePoll.findPollByPollId(poll.getPollId());
+// poll = null;
+// countPoll();
+//
+// return pollZone.getBody();
+// }
- List<ChoiceDTO> choiceDTOs = vote.getChoiceDTOs();
- for (ChoiceDTO choiceDTO : choiceDTOs) {
-
- if (choiceDTO.isHidden()) {
- serviceChoice.deleteChoice(choiceDTO.getId());
- }
- }
-
- break;
- }
- }
-
- serviceVote.deleteVote(voteId);
- }
-
- /** Méthode appelée lors de la suppression d'un vote. */
- Object onActionFromDeleteVote(String voteId) throws PollenBusinessException {
- deleteVote(voteId);
-
- // Mise à jour du sondage et des résultats
-// poll = servicePoll.findPollByPollId(poll.getPollId());
- poll = null;
- countPoll();
-
- return pollZone.getBody();
- }
-
- /** Méthode appelée lors de l'édition d'un vote. */
- Object onActionFromEditVote(String votingId) {
- pollAccount.setVotingId(votingId);
- return pollZone.getBody();
- }
-
/** Initialisation du pollAccount et contrôle du nom. */
- private boolean initPollAccount() throws PollenBusinessException {
-
- //// Contrôle et définition du votingId
- alreadyVoted = false;
- boolean modifAllowed = false;
- boolean restrictedListsForbidden = false;
-
- // Suppression des espaces pouvant provoquer un double vote
- String votingId = pollAccount.getVotingId().trim();
- pollAccount.setVotingId(votingId);
-
- // Contrôle de la présence du votant dans les listes de votants
- // du sondage (si le sondage n'est pas libre)
-// if (!isFreePoll()) {
-// restrictedListsForbidden = true;
-// for (VotingListDTO list : poll.getVotingListDTOs()) {
-// for (PollAccountDTO account : list.getPollAccountDTOs()) {
-// if (pollAccount.getVotingId().equals(account.getVotingId())) {
-// restrictedListsForbidden = false;
-// pollAccount = servicePollAccount
-// .findPollAccountById(account.getId());
-// pollAccount.setVotingListId(list.getId());
-// pollAccount.setWeight(account.getWeight());
-// logger.debug("Compte \"" + account.getVotingId()
-// + "\" présent dans la liste \""
-// + list.getName() + "\" (poids="
-// + account.getWeight() + ")");
-// }
+// private boolean initPollAccount() throws PollenBusinessException {
+//
+// //// Contrôle et définition du votingId
+// alreadyVoted = false;
+// boolean modifAllowed = false;
+// boolean restrictedListsForbidden = false;
+//
+// // Suppression des espaces pouvant provoquer un double vote
+// String votingId = getPollAccount().getVotingId().trim();
+// getPollAccount().setVotingId(votingId);
+//
+// // Contrôle de la présence du votant dans les listes de votants
+// // du sondage (si le sondage n'est pas libre)
+//// if (!isFreePoll()) {
+//// restrictedListsForbidden = true;
+//// for (VotingListDTO list : poll.getVotingListDTOs()) {
+//// for (PollAccountDTO account : list.getPollAccountDTOs()) {
+//// if (pollAccount.getVotingId().equals(account.getVotingId())) {
+//// restrictedListsForbidden = false;
+//// pollAccount = servicePollAccount
+//// .findPollAccountById(account.getId());
+//// pollAccount.setVotingListId(list.getId());
+//// pollAccount.setWeight(account.getWeight());
+//// logger.debug("Compte \"" + account.getVotingId()
+//// + "\" présent dans la liste \""
+//// + list.getName() + "\" (poids="
+//// + account.getWeight() + ")");
+//// }
+//// }
+//// }
+//// }
+//
+// // The calcul of alreadyVoted will be needed for no double votingId
+// // Carefull, not correct for an anonymous vote
+// alreadyVoted = serviceVote.hasAlreadyVoted(votingId, getPoll());
+//
+// // Check for restricted poll
+// if (!alreadyVoted && !isFreePoll()) {
+// if (uri.getAccountUId() != null) {
+// // The accountUId must be valid for the poll
+// PollAccountDTO restrictedAccount =
+// servicePoll.getRestrictedAccount(uri.getAccountUId(), getPoll());
+//
+// if (restrictedAccount != null) {
+// // PollAccount is replaced by the good account from db
+// pollAccount = restrictedAccount;
+// // Refresh alreadyVoted value depends on getPollAccount()
+// alreadyVoted = getPollAccount().isHasVoted();
+// // Existing account is null is forbidden for a restricted poll
+// } else {
+// restrictedListsForbidden = true;
// }
+// // Not allowed to vote without an accountUId
+// } else {
+// restrictedListsForbidden = true;
// }
+//
+// if (restrictedListsForbidden) {
+//// voteForm.recordError(nameField,
+//// messages.get("restrictedListsForbidden"));
+// }
// }
+//
+// // Génération d'un identifiant de vote (si le sondage est libre et anonyme)
+// if (getPoll().isAnonymous()) {
+// anonymousVote = true;
+// if (isFreePoll()) {
+// getPollAccount().setVotingId("anonymous"
+// + UUID.randomUUID().toString().replaceAll("-", ""));
+// }
+// }
+//
+// //// Définition de l'userId
+// if (userExists) {
+// getPollAccount().setUserId(user.getId());
+// } else {
+// getPollAccount().setUserId("");
+// }
+//
+// modifAllowed = isModifAllowed(getPollAccount().getVotingId());
+// if (alreadyVoted && !modifAllowed) {
+//// voteForm.recordError(nameField, messages.format("alreadyVoted",
+//// getPollAccount().getVotingId()));
+// }
+//
+// logger.debug("votingId: " + getPollAccount().getVotingId());
+// logger.debug("alreadyVoted: " + alreadyVoted);
+// logger.debug("modifAllowed: " + modifAllowed);
+// logger.debug("restrictedListsForbidden: " + restrictedListsForbidden);
+// return ((!alreadyVoted || modifAllowed) && !restrictedListsForbidden);
+// }
- // The calcul of alreadyVoted will be needed for no double votingId
- // Carefull, not correct for an anonymous vote
- alreadyVoted = serviceVote.hasAlreadyVoted(votingId, getPoll());
-
- // Check for restricted poll
- if (!alreadyVoted && !isFreePoll()) {
- if (uri.getAccountUId() != null) {
- // The accountUId must be valid for the poll
- PollAccountDTO restrictedAccount =
- servicePoll.getRestrictedAccount(uri.getAccountUId(), getPoll());
-
- if (restrictedAccount != null) {
- // PollAccount is replaced by the good account from db
- pollAccount = restrictedAccount;
- // Refresh alreadyVoted value depends on pollAccount
- alreadyVoted = pollAccount.isHasVoted();
- // Existing account is null is forbidden for a restricted poll
- } else {
- restrictedListsForbidden = true;
- }
- // Not allowed to vote without an accountUId
- } else {
- restrictedListsForbidden = true;
- }
-
- if (restrictedListsForbidden) {
- voteForm.recordError(nameField,
- messages.get("restrictedListsForbidden"));
- }
- }
-
- // Génération d'un identifiant de vote (si le sondage est libre et anonyme)
- if (getPoll().isAnonymous()) {
- anonymousVote = true;
- if (isFreePoll()) {
- pollAccount.setVotingId("anonymous"
- + UUID.randomUUID().toString().replaceAll("-", ""));
- }
- }
-
- //// Définition de l'userId
- if (userExists) {
- pollAccount.setUserId(user.getId());
- } else {
- pollAccount.setUserId("");
- }
-
- modifAllowed = isModifAllowed(pollAccount.getVotingId());
- if (alreadyVoted && !modifAllowed) {
- voteForm.recordError(nameField, messages.format("alreadyVoted",
- pollAccount.getVotingId()));
- }
-
- logger.debug("votingId: " + pollAccount.getVotingId());
- logger.debug("alreadyVoted: " + alreadyVoted);
- logger.debug("modifAllowed: " + modifAllowed);
- logger.debug("restrictedListsForbidden: " + restrictedListsForbidden);
- return ((!alreadyVoted || modifAllowed) && !restrictedListsForbidden);
- }
-
/**
* Retourne vrai si la modification du vote est autorisée. C'est à dire si
* l'utilisateur connecté est l'auteur du vote ou si le votant défini par
@@ -516,50 +508,50 @@
* @param votingId le votant a rechercher
* @return vrai si la modification du vote est autorisée
*/
- public boolean isModifAllowed(String votingId) throws PollenBusinessException {
- boolean modifAllowed = false;
- int i = 0;
+// public boolean isModifAllowed(String votingId) throws PollenBusinessException {
+// boolean modifAllowed = false;
+// int i = 0;
+//
+// // parcours des votes pour trouver celui correspondant au votingId
+// // et contrôle du droit de modification
+// while (i < getVotes().size() && !modifAllowed) {
+//
+// // account : compte associé au vote courant
+// //String id = getVotes().get(i).getPollAccountId();
+// //PollAccountDTO account = servicePollAccount.findPollAccountById(id);
+// VoteDTO curr = getVotes().get(i);
+//
+// // si le votant du vote correspond au votingId
+// if (curr.getName().equals(votingId)) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("vote name: " + curr.getName());
+// logger.debug("vote account: " + curr.getPollAccountId());
+//// logger.debug("voting account: " + pollAccountId);
+// }
+//
+// // si le votant du vote correspond au votant actuel (pollAccountId)
+//// if (pollAccountId != null
+//// && pollAccountId.equals(curr.getPollAccountId())) {
+//// modifAllowed = true;
+//// }
+//
+// // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
+// if (userExists && user.getId().length() > 0) {
+// modifAllowed = user.getId().equals(curr.getUserId());
+// }
+// }
+//
+// i++;
+// }
+//
+// return modifAllowed;
+// }
- // parcours des votes pour trouver celui correspondant au votingId
- // et contrôle du droit de modification
- while (i < getVotes().size() && !modifAllowed) {
-
- // account : compte associé au vote courant
- //String id = getVotes().get(i).getPollAccountId();
- //PollAccountDTO account = servicePollAccount.findPollAccountById(id);
- VoteDTO curr = getVotes().get(i);
-
- // si le votant du vote correspond au votingId
- if (curr.getName().equals(votingId)) {
- if (logger.isDebugEnabled()) {
- logger.debug("vote name: " + curr.getName());
- logger.debug("vote account: " + curr.getPollAccountId());
- logger.debug("voting account: " + pollAccountId);
- }
-
- // si le votant du vote correspond au votant actuel (pollAccountId)
- if (pollAccountId != null
- && pollAccountId.equals(curr.getPollAccountId())) {
- modifAllowed = true;
- }
-
- // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
- if (userExists && user.getId().length() > 0) {
- modifAllowed = user.getId().equals(curr.getUserId());
- }
- }
-
- i++;
- }
-
- return modifAllowed;
- }
-
/** Ajout d'une entrée dans le flux de syndication */
private void addFeedEntry(PollAction pollAction, String titleStr,
String contentStr) throws PollenBusinessException {
- String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollId();
- File feedFile = getFeedContext().getFile(getPoll().getPollId());
+ String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUId();
+ File feedFile = getFeedContext().getFile(getPoll().getPollUId());
String title = null;
String content = null;
@@ -591,8 +583,8 @@
/** Envoi du mail de notification */
private void sendMailNotification() throws PollenBusinessException {
- String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollId();
- String modifURL = siteURL + "poll/Modification/" + getPoll().getPollId()
+ String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollUId();
+ String modifURL = siteURL + "poll/Modification/" + getPoll().getPollUId()
+ ":" + MD5.encode(getPoll().getCreatorId());
Map<String, String> data = new HashMap<String, String>();
data.put("host", PollenProperty.EMAIL_HOST.getValue());
@@ -702,7 +694,7 @@
*/
@Log
public boolean isFeedFileExisting() throws PollenBusinessException {
- File feedFile = getFeedContext().getFile(getPoll().getPollId());
+ File feedFile = getFeedContext().getFile(getPoll().getPollUId());
if (log.isDebugEnabled()) {
log.debug("feed context path : " + getFeedContext().getContextPath());
log.debug("feed absolute path : " + feedFile.getAbsolutePath());
@@ -810,7 +802,7 @@
if (isTextType()) {
if (newChoice.getName() != null) {
newChoice.setValidate(true);
- newChoice.setPollId(getPoll().getId());
+ newChoice.setPollUId(getPoll().getPollUId());
getPoll().getChoices().add(newChoice);
choiceName = newChoice.getName();
choiceDesc = newChoice.getDescription();
@@ -818,7 +810,7 @@
} else if (isDateType()) {
if (newDateChoice.getDate() != null) {
newDateChoice.setValidate(true);
- newDateChoice.setPollId(getPoll().getId());
+ newDateChoice.setPollUId(getPoll().getPollUId());
newDateChoice.setName(String.valueOf(newDateChoice.getDate()
.getTime()));
getPoll().getChoices().add(newDateChoice);
@@ -829,7 +821,7 @@
} else if (isImageType()) {
if (newImageChoice.getImg() != null) {
newImageChoice.setValidate(true);
- newImageChoice.setPollId(getPoll().getId());
+ newImageChoice.setPollUId(getPoll().getPollUId());
newImageChoice.setName(newImageChoice.getImg().getFileName()
.replace(' ', '_'));
getPoll().getChoices().add(newImageChoice);
@@ -851,32 +843,10 @@
return this;
}
- /** Méthode appelée lors de la suppression d'un choix. */
- Object onActionFromDeleteChoice(String choiceId) throws PollenBusinessException {
- Iterator<ChoiceDTO> itChoice = getPoll().getChoices().iterator();
- while (itChoice.hasNext()) {
- ChoiceDTO choice = itChoice.next();
- if (choiceId.equals(choice.getId())) {
- itChoice.remove();
- }
- }
- servicePoll.updatePoll(getPoll());
- poll = null;
-// poll = servicePoll.findPollByPollId(poll.getPollId());
- return pollZone.getBody();
- }
-
// public boolean isPollNull() {
// return poll == null;
// }
- public boolean isPollChoiceStarted() throws PollenBusinessException {
- Date now = new Date();
- boolean started = getPoll().getBeginChoiceDate() == null || getPoll().getBeginChoiceDate().before(now);
- boolean ended = getPoll().getEndChoiceDate() != null && getPoll().getEndChoiceDate().before(now);
- return started && !ended;
- }
-
public boolean isPollStarted() throws PollenBusinessException {
Date now = new Date();
return getPoll().getBeginDate() == null || getPoll().getBeginDate().before(now);
@@ -891,19 +861,14 @@
return isPollChoiceStarted() || isPollStarted();
}
- public boolean isPollChoiceRunning() throws PollenBusinessException {
- return getPoll().isChoiceAddAllowed() && isPollChoiceStarted();
- //&& !isPollStarted();
- }
-
public boolean isPollRunning() throws PollenBusinessException {
return isPollStarted() && !isPollFinished() && !getPoll().isClosed();
}
- public boolean isDescNull() {
- return choiceOfPoll.getDescription() == null
- || "".equals(choiceOfPoll.getDescription());
- }
+// public boolean isDescNull() {
+// return choiceOfPoll.getDescription() == null
+// || "".equals(choiceOfPoll.getDescription());
+// }
/** Retourne vrai si le champs pollAccount doit apparaître. */
public boolean isAccountFieldDisplayed() throws PollenBusinessException {
@@ -949,14 +914,6 @@
public boolean isNumberVoteCounting() throws PollenBusinessException {
return getPoll().getVoteCounting() == VoteCountingType.NUMBER;
}
-
- /** retourne vrai si l'utilisateur est le créateur du sondage */
- public boolean isCreatorUser() throws PollenBusinessException {
- if (userExists && user.getId().equals(getPoll().getUserId())) {
- return true;
- }
- return false;
- }
/** Retourne le message d'aide correspondant au type de sondage. */
public String getHelpMessage() throws PollenBusinessException {
@@ -989,9 +946,9 @@
if (getPoll().getContinuousResults()) {
if (isGroupPoll()) {
- resultListDTO = serviceResults.getGroupResults(getPoll().getPollId());
+ resultListDTO = serviceResults.getGroupResults(getPoll().getPollUId());
} else {
- resultListDTO = serviceResults.getNormalResults(getPoll().getPollId());
+ resultListDTO = serviceResults.getNormalResults(getPoll().getPollUId());
}
results = resultListDTO.getResultDTOs();
@@ -1006,9 +963,26 @@
}
}
+
+
+
+
+
+
+
+
+ ////////////////// NEW IMPLEMENTATION
+
+
+
+
+
@Property
private PollUri uri;
+ @InjectComponent
+ private Border border;
+
/**
* Sondage pour lequel l'utilisateur vote
*/
@@ -1017,9 +991,17 @@
@Property
private boolean pollNull;
+
+ /**
+ * Objet de session représentant l'utilisateur identifié.
+ */
+ @SessionState
+ private UserDTO user;
+ @Property
+ private boolean userExists;
- @InjectComponent
- private Border border;
+ /** Compte du votant */
+ private PollAccountDTO pollAccount;
/** Format des dates */
private DateFormat dateFormat;
@@ -1029,7 +1011,6 @@
*
* @param id l'identifiant du sondage et du votant
*/
- @Log
void onActivate(EventContext ec) throws PollenBusinessException {
uri = ec.get(PollUri.class, 0);
if (ec.getCount() > 1) {
@@ -1079,8 +1060,6 @@
* @return the address bar of the page.
*/
public AddressBar getAddress() {
-// address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
-// new AddressBarItem(title, null) };
return new AddressBar().appendCurrent(title);
}
@@ -1099,33 +1078,10 @@
public PollDTO getPoll() throws PollenBusinessException {
if (poll == null) {
- poll = servicePoll.findPollByPollId(uri.getPollUId());
+ poll = servicePoll.getPoll(uri.getPollUId());
if (poll != null) {
- // Identification du votant
- if (uri.getAccountUId() != null) {
- pollAccount = servicePollAccount
- .findPollAccountByAccountId(uri.getAccountUId());
- pollAccountId = pollAccount.getId();
- }
-
- if (pollAccount == null) {
- pollAccount = new PollAccountDTO();
- if (userExists) {
- if (user.getFirstName() != null && user.getLastName() != null) {
- pollAccount.setVotingId(
- user.getFirstName() + " " + user.getLastName());
-
- } else if (user.getFirstName() != null) {
- pollAccount.setVotingId(user.getFirstName());
-
- } else if (user.getLastName() != null) {
- pollAccount.setVotingId(user.getLastName());
- }
- }
- }
-
// Initialisations pour les formulaires
newChoice = new ChoiceDTO();
newDateChoice = new DateChoiceUIO();
@@ -1138,13 +1094,197 @@
return poll;
}
- /************** PAGER AND VOTES MANAGMENT *********************************/
+ /**
+ * Use a PollAccount to represent the current session user.
+ * The existing account is used if accountUId is present in the uri.
+ * Otherwise a new account is instanciate with user properties
+ * (for vote name).
+ *
+ * @return
+ */
+ public PollAccountDTO getPollAccount() {
+ if (pollAccount == null) {
+ // Identification du votant
+ if (uri.getAccountUId() != null) {
+ pollAccount = servicePollAccount
+ .findPollAccountByAccountId(uri.getAccountUId());
+// pollAccountId = pollAccount.getId();
+ }
+ if (pollAccount == null) {
+ pollAccount = serviceVote.getNewPollAccount(user);//new PollAccountDTO();
+// if (userExists) {
+// if (user.getFirstName() != null && user.getLastName() != null) {
+// pollAccount.setVotingId(
+// user.getFirstName() + " " + user.getLastName());
+//
+// } else if (user.getFirstName() != null) {
+// pollAccount.setVotingId(user.getFirstName());
+//
+// } else if (user.getLastName() != null) {
+// pollAccount.setVotingId(user.getLastName());
+// }
+// }
+ }
+ }
+ return pollAccount;
+ }
+
+ /**
+ * Test if the current connected user is the poll creator.
+ *
+ * @return true if connected user is the poll creator
+ * @throws PollenBusinessException
+ */
+ public boolean isCreatorUser() throws PollenBusinessException {
+ return userExists && user.getId().equals(getPoll().getUserId());
+ }
+
+ /************** CHOICES ***************************************************/
+
+ private List<ChoiceField> choices;
+
+ @Property
+ private ChoiceField choice;
+
+ @Inject
+ private Block choiceText;
+
+ @Inject
+ private Block choiceImage;
+
+ @Inject
+ private Block choiceDate;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private ServiceImage serviceImage;
+
+ /**
+ * Get choices of the poll. The ChoiceDTO from poll will be converted
+ * to ChoiceField to easily managed different type of choice (image,
+ * date, text).
+ *
+ * @return a list of ChoiceField corresponding to poll choices
+ * @throws PollenBusinessException
+ */
+ public List<ChoiceField> getChoices() throws PollenBusinessException {
+ if (choices == null) {
+ if (log.isInfoEnabled()) {
+ log.info("Prepare choices for render");
+ }
+ choices = new ArrayList<ChoiceField>();
+ for (ChoiceDTO curr : getPoll().getChoices()) {
+ ChoiceField field = new ChoiceField(curr,
+ getPoll().getChoiceType());
+ choices.add(field);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("nb choices loaded : " + choices.size());
+ }
+ return choices;
+ }
+
+ /**
+ * Delegator : return the correct choice block depends on poll choiceType.
+ *
+ * @return the choice block to display
+ * @throws PollenBusinessException
+ */
+ public Block getChoiceBlock() throws PollenBusinessException {
+ switch(getPoll().getChoiceType()) {
+ case IMAGE:
+ return choiceImage;
+ case DATE:
+ return choiceDate;
+ case TEXT:
+ default:
+ return choiceText;
+ }
+ }
+
+ /**
+ * Image link to show the miniature (thumb) of current choice image.
+ *
+ * @return the image link for current choice image.
+ */
+ public Link getImageThumb() {
+ return getImageLink(true);
+ }
+
+ /**
+ * Image link to show the normal (not thumb) image of current choice image.
+ *
+ * @return the image link for current choice image.
+ */
+ public Link getImageLink() {
+ return getImageLink(false);
+ }
+
+ private Link getImageLink(boolean thumb) {
+ return resources.createEventLink("showImage",
+ choice.getImageFileName(), choice.getImageDir(), thumb);
+ }
+
+ /**
+ * Event for showing image.
+ *
+ * @param src of the image
+ * @param imageDir directory of the image
+ * @param thumb to show the thumb image or not
+ * @return the streamResponse to display
+ * @see ServiceImage#createImageStream(String, String, boolean)
+ */
+ @Log
+ public StreamResponse onShowImage(String src, String imageDir,
+ boolean thumb) {
+ return serviceImage.createImageStream(src, imageDir, thumb);
+ }
+
+ public boolean isPollChoiceRunning() throws PollenBusinessException {
+ return getPoll().isChoiceAddAllowed() && isPollChoiceStarted();
+ }
+
+ /**
+ * TODO : whithout DTO, this method can be place in PollEntity
+ *
+ * @return true if adding choice is started, false otherwise
+ * @throws PollenBusinessException
+ */
+ public boolean isPollChoiceStarted() throws PollenBusinessException {
+ Date now = new Date();
+ boolean started = getPoll().getBeginChoiceDate() == null
+ || getPoll().getBeginChoiceDate().before(now);
+ boolean ended = getPoll().getEndChoiceDate() != null
+ && getPoll().getEndChoiceDate().before(now);
+ return started && !ended;
+ }
+
+ public boolean canDeleteChoice() throws PollenBusinessException {
+ return isPollChoiceRunning() && isCreatorUser();
+ }
+
+ /**
+ * ACTION EVENT :: delete selected choice
+ */
+ void onActionFromDeleteChoice(String choiceId)
+ throws PollenBusinessException {
+ if (canDeleteChoice()) {
+ servicePoll.deleteChoice(getPoll(), choiceId);
+ // Reset choices (ChoiceField list) to retrieve the updated one
+ // from poll
+ choices = null;
+ }
+ }
+
+ /************** PAGER *****************************************************/
+
@InjectComponent
private Pager pager;
- private List<VoteDTO> votes;
-
private Integer page;
@Persist
@@ -1183,9 +1323,20 @@
}
public String getNoPagerText() throws PollenBusinessException {
- return messages.format("vote-noPagerText", getPoll().getNbVotes());
+ if (getPoll().getNbVotes() == 0) {
+ return messages.get("pollen.ui.vote.noVotes");
+ }
+ return messages.format("pollen.ui.vote.noPager",
+ getPoll().getNbVotes());
}
+ /************** VOTES *****************************************************/
+
+ private List<VoteDTO> votes;
+
+ @Property
+ private int voteIndex;
+
/**
* Retrieve votes of the current poll from business module.
* The votes are ordered by creation date, only the ones to display are
@@ -1202,6 +1353,28 @@
return votes;
}
+ public boolean canEditVote() throws PollenBusinessException {
+ // If the current account exist from uri and equals to the current vote
+ String newAccountId = getPollAccount().getId();
+ if (newAccountId != null && newAccountId.equals(vote.getPollAccountId())) {
+ return true;
+ // If the connected user is an admin
+ } else if (userExists && user.isAdministrator()) {
+ return true;
+ // If the connected user is the poll creator
+ } else if (isCreatorUser()) {
+ return true;
+ }
+ return false;
+ }
+
+ /** Méthode appelée lors de l'édition d'un vote. */
+// Object onActionFromEditVote(int voteIndex) throws PollenBusinessException {
+//// getPollAccount().setVotingId(votingId);
+// vote = getVotes().get(voteIndex);
+// return pollZone.getBody();
+// }
+
/************** COMMENTS **************************************************/
@InjectComponent
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -74,11 +74,11 @@
for (VotingListDTO list : poll.getVotingListDTOs()) {
for (PollAccountDTO account : list.getPollAccountDTOs()) {
if (account.getEmail().equals(user.getEmail())) {
- return poll.getPollId() + ":" + account.getAccountId();
+ return poll.getPollUId() + ":" + account.getAccountId();
}
}
}
- return poll.getPollId();
+ return poll.getPollUId();
}
/**
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -72,6 +72,7 @@
binder.bind(ServiceResults.class);
binder.bind(ServiceVote.class);
binder.bind(ServiceChoice.class);
+ binder.bind(ServiceImage.class);
}
public static void contributeApplicationDefaults(
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 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -127,7 +127,7 @@
*/
private void sendMailNotification(PollDTO poll, Long timeValue) {
String voteURL = PollenProperty.SERVER_URL.getValue() + "/poll/VoteFor/"
- + poll.getPollId();
+ + poll.getPollUId();
Map<String, String> data = new HashMap<String, String>();
data.put("host", PollenProperty.EMAIL_HOST.getValue());
data.put("port", PollenProperty.EMAIL_PORT.getValue());
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -0,0 +1,63 @@
+
+package org.chorem.pollen.ui.services;
+
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.upload.services.UploadedFile;
+
+/**
+ * This service is used to manage images in pollen application.
+ *
+ * Saving process :
+ * <pre>
+ * - Use the upload component of Tapestry to retrieve the uploaded file
+ * - After file type validation use saveImage method to create the image,
+ * folders and thumbnail
+ * </pre>
+ * Display process :
+ * <pre>
+ * - Create eventLink for the src property of an img tag
+ * (<img src=${myLink}... />)
+ * - On event method, return the streamResponse created by createImageStream
+ * method
+ * </pre>
+ *
+ * Created: 20 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ * @since 1.3
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public interface ServiceImage {
+
+ /**
+ * Return the context path for pollen image managment.
+ *
+ * @return the context path for images
+ */
+ String getContextPath();
+
+ /**
+ * Create a StreamResponse represent the image to display.
+ *
+ * @param filename the filename of the image
+ * @param filedir the directory where the image is defined
+ * @param thumb to return a stream for the thumb image
+ * @return the StreamResponse to display (using eventLink)
+ */
+ StreamResponse createImageStream(String filename, String filedir,
+ boolean thumb);
+
+ /**
+ * Save an image in {@code filedir} from uploaded {@code tmpfile}.
+ *
+ * @param tmpfile which contains the image stream
+ * @param filedir where the image will be saved (not need to precise
+ * the context)
+ * @return the filename of the saved file
+ */
+ String saveImage(UploadedFile tmpfile, String filedir);
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImage.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -0,0 +1,162 @@
+
+package org.chorem.pollen.ui.services;
+
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import javax.activation.MimetypesFileTypeMap;
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.services.Response;
+import org.apache.tapestry5.upload.services.UploadedFile;
+import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenProperty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceImageImpl
+ *
+ * Created: 20 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ * @since 1.3
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceImageImpl implements ServiceImage {
+
+ private static final String THUMB_PREFIX = "thumb_";
+
+ private static final int THUMB_WIDTH = 100;
+
+ private static final Logger logger = LoggerFactory.getLogger(ServiceImageImpl.class);
+
+ public ServiceImageImpl() {
+
+ }
+
+ @Override
+ public String getContextPath() {
+ return PollenContext.getProperty(PollenProperty.IMG_DIR);
+ }
+
+ /**
+ * Get the directory where are uploaded the images from the context.
+ *
+ * @param imageDir
+ * @return a File corresponding to the image directory
+ */
+ public File getImagePathDir(String imageDir) {
+ File result = null;
+ if (StringUtils.isNotEmpty(imageDir)) {
+ result = new File(getContextPath(), imageDir);
+ } else {
+ result = new File(getContextPath());
+ }
+ return result;
+ }
+
+ public File getImageFile(String filename, String imageDir, boolean thumb) {
+ if (thumb) {
+ filename = THUMB_PREFIX + filename;
+ }
+ return new File(getImagePathDir(imageDir), filename);
+ }
+
+ @Override
+ public StreamResponse createImageStream(String filename, String filedir, boolean thumb) {
+ if (StringUtils.isEmpty(filename) || filename.contains("..")) {
+ return null;
+ }
+
+ final File file = getImageFile(filename, filedir, thumb);
+ if (!file.exists()) {
+ logger.error("Fichier inexistant : " + file.getAbsolutePath());
+ }
+
+ return new StreamResponse() {
+
+ @Override
+ public String getContentType() {
+ MimetypesFileTypeMap mimes = new MimetypesFileTypeMap();
+ return mimes.getContentType(file);
+ }
+
+ @Override
+ public InputStream getStream() throws IOException {
+ return new FileInputStream(file);
+ }
+
+ @Override
+ public void prepareResponse(Response response) {
+
+ }
+ };
+ }
+
+ @Override
+ public String saveImage(UploadedFile tmpfile, String filedir) {
+ File dir = getImagePathDir(filedir);
+ if (!dir.exists()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Create image directory : " +
+ dir.getAbsolutePath());
+ }
+ dir.mkdirs();
+ }
+ String filename = tmpfile.getFileName();
+
+ File image = new File(dir, filename);
+ tmpfile.write(image);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Image saved: " + filename +
+ " (size=" + tmpfile.getSize() + ")");
+ }
+
+ createThumbnail(image, dir);
+ return image.getName();
+ }
+
+ /**
+ * Création d'une miniature.
+ *
+ * @param img
+ * @param dir Le répertoire de destination.
+ */
+ public void createThumbnail(File img, File dir) {
+
+ ImageIcon ii = new ImageIcon(img.getAbsolutePath());
+ Image image = ii.getImage();
+ double imageRatio = (double) image.getHeight(null)
+ / (double) image.getWidth(null);
+ int height = (int) (THUMB_WIDTH * imageRatio);
+
+ BufferedImage thumbImage = new BufferedImage(THUMB_WIDTH, height,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics2D graphics2D = thumbImage.createGraphics();
+ graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+ graphics2D.drawImage(image, 0, 0, THUMB_WIDTH, height, null);
+ File thumbCopied = new File(dir, THUMB_PREFIX + img.getName());
+ try {
+ ImageIO.write(thumbImage, "jpg", thumbCopied);
+ } catch (IOException e) {
+ logger.error("Erreur à l'enregistrement de la miniature", e);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Thumbnail created: " + thumbCopied.getName() + " " +
+ "(size=" + thumbCopied.length() + ")");
+ }
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
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 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java 2010-03-20 15:30:29 UTC (rev 2952)
@@ -39,7 +39,9 @@
*
* @author rannou
* @version $Id$
+ * @deprecated use {@link org.chorem.pollen.ui.services.ServiceImage} instead
*/
+@Deprecated
public class ImageUtil {
/** log. */
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-en_GB.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -39,4 +39,9 @@
validate=Validate
cancel=Cancel
return=Return
-help=Help
\ No newline at end of file
+help=Help
+
+pollen.ui.choice.delete.confirm=Are you sure you want to delete this choice ?
+pollen.ui.choice.delete.title=Delete this choice
+pollen.ui.vote.noVotes=Aucune personne n'a encore particip\u00E9 au sondage
+pollen.ui.vote.noPager=%d existing votes
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/resources/i18n/pollen-ui-fr_FR.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -1,35 +1,35 @@
# User registration emails
-registerEmail_subject=[Pollen] Confirmation de cr\u00e9ation du compte %s
-registerEmail_msg=Bienvenue %s %s. Vous venez de cr\u00e9er un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant : %s\nMot de passe : %s\n\nVous pouvez d\u00e8s maintenant g\u00e9rer vos sondages en vous identifiant sur le site : \n%s
+registerEmail_subject=[Pollen] Confirmation de cr\u00E9ation du compte %s
+registerEmail_msg=Bienvenue %s %s. Vous venez de cr\u00E9er un compte sur l'application de sondage en ligne Pollen.\n\nIdentifiant : %s\nMot de passe : %s\n\nVous pouvez d\u00E8s maintenant g\u00E9rer vos sondages en vous identifiant sur le site : \n%s
# Poll creation emails
-creatorEmail_subject=[Pollen] Cr\u00e9ation d'un sondage (%s)
-creatorEmail_msg=Vous venez de cr\u00e9er le sondage "%s".\nVous pouvez y acc\u00e9der en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
+creatorEmail_subject=[Pollen] Cr\u00E9ation d'un sondage (%s)
+creatorEmail_msg=Vous venez de cr\u00E9er le sondage "%s".\nVous pouvez y acc\u00E9der en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
votingEmail_subject=[Pollen] Invitation au vote (%s)
-votingEmail_msg=Un nouveau sondage a \u00e9t\u00e9 cr\u00e9\u00e9 : "%s".\nVous pouvez y participer avec l'identifiant %s \u00e0 l'adresse suivante : \n%s
+votingEmail_msg=Un nouveau sondage a \u00E9t\u00E9 cr\u00E9\u00E9 : "%s".\nVous pouvez y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s
# Notification emails
voteEmail_subject=[Pollen] Notification de vote (%s)
-voteEmail_msg=Un vote vient d'\u00eatre enregistr\u00e9 pour le sondage "%s". Ce sondage compte d\u00e9sormais %d votes.\nVous pouvez acc\u00e9der \u00e0 ce sondage en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
+voteEmail_msg=Un vote vient d'\u00EAtre enregistr\u00E9 pour le sondage "%s". Ce sondage compte d\u00E9sormais %d votes.\nVous pouvez acc\u00E9der \u00E0 ce sondage en suivant les liens ci-dessous.\n\nPage de vote : \n%s\nPage de modification : \n%s
# Reminder emails
reminderEmail_subject=[Pollen] Rappel (%s)
-reminderEmail_msg=Vous n'avez pas encore vot\u00e9 pour le sondage "%s".\nVous pouvez encore y participer avec l'identifiant %s \u00e0 l'adresse suivante : \n%s
+reminderEmail_msg=Vous n'avez pas encore vot\u00E9 pour le sondage "%s".\nVous pouvez encore y participer avec l'identifiant %s \u00E0 l'adresse suivante : \n%s
# Poll feed
pollFeed_title=Pollen : %s
pollFeed_desc=%s
-pollFeed_createTitle=Sondage cr\u00e9\u00e9 par %s
+pollFeed_createTitle=Sondage cr\u00E9\u00E9 par %s
pollFeed_createContent=
pollFeed_voteTitle=Nouveau vote de %s
-pollFeed_voteContent=\u00c9tat du sondage : %s
+pollFeed_voteContent=\u00C9tat du sondage : %s
pollFeed_choiceTitle=Nouveau choix : %s
pollFeed_choiceContent=%s
pollFeed_commentTitle=Nouveau commentaire de %s
pollFeed_commentContent=%s
# Actions
-create=Cr\u00e9er
+create=Cr\u00E9er
edit=Modifier
delete=Supprimer
add=Ajouter
@@ -40,3 +40,8 @@
cancel=Annuler
return=Retour
help=Aide
+
+pollen.ui.choice.delete.confirm=Etes-vous s\u00FBr de vouloir d\u00E9finitivement supprimer ce choix ?
+pollen.ui.choice.delete.title=Supprimer ce choix
+pollen.ui.vote.noVotes=Aucune personne n'a encore particip\u00E9 au sondage
+pollen.ui.vote.noPager=%d votes existants
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -20,7 +20,7 @@
anonymousVote-label=Anonymous vote
submitVote=Vote
vote-success=Your vote has been correctly saved
-vote-noPagerText=%d existing votes
+#vote-noPagerText=%d existing votes
#choices
addChoice=Adding a choice
@@ -59,4 +59,4 @@
pollNotStarted=This poll has not started yet.
pollFinished=This poll is finished. You can not vote anymore.
pollClosed=This poll is closed. You can not vote anymore.
-pollChoiceRunning=Adding choices is allowed.
\ No newline at end of file
+pollChoiceRunning=Adding choices is allowed.
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties 2010-03-20 15:30:29 UTC (rev 2952)
@@ -20,7 +20,7 @@
anonymousVote-label=Vote anonyme
submitVote=Voter
vote-success=Votre vote a bien \u00E9t\u00E9 enregistr\u00E9
-vote-noPagerText=%d votes existants
+#vote-noPagerText=%d votes existants
#choices
addChoice=Ajout d'un choix
@@ -59,4 +59,4 @@
pollNotStarted=Ce sondage n'a pas encore commenc\u00E9.
pollFinished=Ce sondage est termin\u00E9. Vous ne pouvez plus voter.
pollClosed=Ce sondage est clos. Vous ne pouvez plus voter.
-pollChoiceRunning=L'ajout de choix est possible.
\ No newline at end of file
+pollChoiceRunning=L'ajout de choix est possible.
Modified: trunk/pollen-ui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/pollen-ui/src/main/webapp/WEB-INF/web.xml 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/webapp/WEB-INF/web.xml 2010-03-20 15:30:29 UTC (rev 2952)
@@ -30,14 +30,14 @@
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
- <filter>
+<!-- <filter>
<filter-name>appExceptions</filter-name>
<filter-class>org.chorem.pollen.ui.filters.PollenExceptionsFilter</filter-class>
- </filter>
- <filter-mapping>
+ </filter>-->
+<!-- <filter-mapping>
<filter-name>appExceptions</filter-name>
<url-pattern>/*</url-pattern>
- </filter-mapping>
+ </filter-mapping>-->
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
Modified: trunk/pollen-ui/src/main/webapp/img/1leftarrow.png
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/webapp/img/1rightarrow.png
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/webapp/img/2leftarrow.png
===================================================================
(Binary files differ)
Modified: trunk/pollen-ui/src/main/webapp/img/2rightarrow.png
===================================================================
(Binary files differ)
Deleted: trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js 2010-03-20 15:30:29 UTC (rev 2952)
@@ -1,103 +0,0 @@
-var ZoneUpdater = Class.create();
-
-ZoneUpdater.prototype = {
-
- initialize: function(zoneElementId, listeningElement, event, link, zone, placeholder) {
-
- this.zoneElement = $(zoneElementId);
-
- this.event = event;
-
- this.link = link;
-
- this.placeholder = placeholder;
-
- $T(this.zoneElement).zoneId = zone;
-
- listeningElement.observe(this.event, this.updateZone.bindAsEventListener(this));
-
- },
-
- updateZone: function(event) {
-
- var zoneObject = Tapestry.findZoneManager(this.zoneElement);
-
- if ( !zoneObject ) return;
-
- var param;
-
- if (this.zoneElement.value) {
-
- param = this.zoneElement.value;
-
- }
-
- if (!param) param = ' ';
-
- param = this.encodeForUrl(param);
-
- var updatedLink = this.link.gsub(this.placeholder, param);
-
- zoneObject.updateFromURL(updatedLink);
-
- },
-
- encodeForUrl: function(string) {
-
- /**
-
- * See equanda.js for updated version of this
-
- */
-
- string = string.replace(/\r\n/g,"\n");
-
- var res = "";
-
- for (var n = 0; n < string.length; n++)
-
- {
-
- var c = string.charCodeAt( n );
-
- if ( '$' == string.charAt( n ) )
-
- {
-
- res += '$$';
-
- }
-
- else if ( this.inRange( c, "AZ" ) || this.inRange( c, "az" ) || this.inRange( c, "09" ) || this.inRange( c, ".." ) )
-
- {
-
- res += string.charAt( n )
-
- }
-
- else
-
- {
-
- var tmp = c.toString(16);
-
- while ( tmp.length < 4 ) tmp = "0" + tmp;
-
- res += '$' + tmp;
-
- }
-
- }
-
- return res;
-
- },
-
- inRange: function(code, range) {
-
- return code >= range.charCodeAt( 0 ) && code <= range.charCodeAt( 1 );
-
- }
-
-}
\ No newline at end of file
Added: trunk/pollen-ui/src/main/webapp/js/confirm.js
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/confirm.js (rev 0)
+++ trunk/pollen-ui/src/main/webapp/js/confirm.js 2010-03-20 15:30:29 UTC (rev 2952)
@@ -0,0 +1,20 @@
+/**
+ * Dialogue de confirmation
+ */
+var Confirm = Class.create({
+ /**
+ * element : Element DOM depuis lequel le dialogue de confirmation va s'ouvrir
+ * message : Message à afficher dans la boîte de dialogue
+ */
+ initialize: function(element, message) {
+ this.message = message;
+ Event.observe($(element), 'click', this.doConfirm.bindAsEventListener(this));
+ },
+ doConfirm: function(e) {
+ //Tapestry.debug('click ' + element);
+ if(! confirm(this.message)) {
+ //Tapestry.debug('STOP ' + e);
+ Event.stop(e);
+ }
+ }
+});
\ No newline at end of file
Copied: trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js (from rev 2950, trunk/pollen-ui/src/main/webapp/js/ZoneUpdater.js)
===================================================================
--- trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js (rev 0)
+++ trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js 2010-03-20 15:30:29 UTC (rev 2952)
@@ -0,0 +1,103 @@
+var ZoneUpdater = Class.create();
+
+ZoneUpdater.prototype = {
+
+ initialize: function(zoneElementId, listeningElement, event, link, zone, placeholder) {
+
+ this.zoneElement = $(zoneElementId);
+
+ this.event = event;
+
+ this.link = link;
+
+ this.placeholder = placeholder;
+
+ $T(this.zoneElement).zoneId = zone;
+
+ listeningElement.observe(this.event, this.updateZone.bindAsEventListener(this));
+
+ },
+
+ updateZone: function(event) {
+
+ var zoneObject = Tapestry.findZoneManager(this.zoneElement);
+
+ if ( !zoneObject ) return;
+
+ var param;
+
+ if (this.zoneElement.value) {
+
+ param = this.zoneElement.value;
+
+ }
+
+ if (!param) param = ' ';
+
+ param = this.encodeForUrl(param);
+
+ var updatedLink = this.link.gsub(this.placeholder, param);
+
+ zoneObject.updateFromURL(updatedLink);
+
+ },
+
+ encodeForUrl: function(string) {
+
+ /**
+
+ * See equanda.js for updated version of this
+
+ */
+
+ string = string.replace(/\r\n/g,"\n");
+
+ var res = "";
+
+ for (var n = 0; n < string.length; n++)
+
+ {
+
+ var c = string.charCodeAt( n );
+
+ if ( '$' == string.charAt( n ) )
+
+ {
+
+ res += '$$';
+
+ }
+
+ else if ( this.inRange( c, "AZ" ) || this.inRange( c, "az" ) || this.inRange( c, "09" ) || this.inRange( c, ".." ) )
+
+ {
+
+ res += string.charAt( n )
+
+ }
+
+ else
+
+ {
+
+ var tmp = c.toString(16);
+
+ while ( tmp.length < 4 ) tmp = "0" + tmp;
+
+ res += '$' + tmp;
+
+ }
+
+ }
+
+ return res;
+
+ },
+
+ inRange: function(code, range) {
+
+ return code >= range.charCodeAt( 0 ) && code <= range.charCodeAt( 1 );
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/pollen-ui/src/main/webapp/js/zoneUpdater.js
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/webapp/poll/CreationValidation.tml 2010-03-20 15:30:29 UTC (rev 2952)
@@ -8,8 +8,8 @@
<img src="${asset:context:img/vote.png}" alt="${message:vote}" style="margin-right: 18px;"/>
${message:votePage}
<br />
- <t:PageLink t:context="poll.pollId" t:page="poll/VoteForPoll" style="margin-left:50px;">
- ${siteURL}poll/VoteFor/${poll.pollId}
+ <t:PageLink t:context="poll.pollUId" t:page="poll/VoteForPoll" style="margin-left:50px;">
+ ${siteURL}poll/VoteFor/${poll.pollUId}
</t:PageLink>
</div>
<div style="margin-top: 10px;">
Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-03-20 15:30:29 UTC (rev 2952)
@@ -275,7 +275,7 @@
</div>
</t:formfragment>
<t:formfragment t:id="imgChoiceFragment" visible="isImgChoices()">
- <t:ImageContextLink t:id="imgContext" t:dir="poll.pollId" />
+ <t:ImageContextLink t:id="imgContext" t:dir="poll.pollUId" />
<div t:type="loop" t:source="imgTypeChoices" t:value="imgTypeChoice" t:volatile="true">
<div class="fleft choiceName">
<t:label for="imgFile" />
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-19 15:05:04 UTC (rev 2951)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-20 15:30:29 UTC (rev 2952)
@@ -14,13 +14,13 @@
<legend>${message:about}</legend>
<div style="float: right">
<t:if test="poll.publicResults">
- <t:PageLink t:page="poll/Results" t:context="poll.pollId">
+ <t:PageLink t:page="poll/Results" t:context="poll.pollUId">
<img src="${asset:context:img/count.png}" title="${message:results-help}" alt="${message:results}"/>
</t:PageLink>
</t:if>
<t:FeedContextLink t:id="feedContext" />
<t:if test="feedFileExisting">
- <t:FileLink filename="${poll.pollId}" type="literal:application/atom+xml" t:context="feedContext">
+ <t:FileLink filename="${poll.pollUId}" type="literal:application/atom+xml" t:context="feedContext">
<img src="${asset:context:img/feed.png}" title="Atom" alt="Atom"/>
</t:FileLink>
</t:if>
@@ -44,7 +44,7 @@
<!-- Sondage -->
- <t:zone t:id="pollZone" t:show="show" t:update="show">
+ <!--<t:zone t:id="pollZone" t:show="show" t:update="show">-->
<t:if t:test="poll.anonymous">
<p>${voteSizeMessage}</p>
<t:feedback t:id="voteFeedback"/>
@@ -63,72 +63,42 @@
<th></th>
</p:else>
</t:if>
- <t:if test="textType">
- <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
- <t:if test="!isChoiceHidden()">
- <th>
- <t:unless test="isDescNull()">
- <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind">
- <span class="desc">${choiceOfPoll.name}</span>
- </span>
- <p:else>
- ${choiceOfPoll.name}
- </p:else>
- </t:unless>
- <t:if test="${pollChoiceRunning}">
- <t:if test="creatorUser">
- <t:actionlink t:id="deleteChoice" context="choiceOfPoll.id" t:zone="pollZone">
- <img src="${asset:context:img/delete.png}" title="${message:delete}" alt="${message:delete}"/>
- </t:actionlink>
- </t:if>
- </t:if>
- </th>
- </t:if>
- </t:loop>
- </t:if>
- <t:if test="dateType">
- <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
- <t:unless test="choiceHidden">
- <t:unless test="isDescNull()">
- <th class="desc">
- <span t:type="ck/Tooltip" t:value="choiceOfPoll.description" t:effect="blind">
- <t:output value="choiceNameAsDate" format="dateFormat"/>
- </span>
- </th>
- <p:else>
- <th>
- <t:output value="choiceNameAsDate" format="dateFormat"/>
- </th>
- </p:else>
- </t:unless>
- </t:unless>
- </t:loop>
- </t:if>
- <t:if test="imageType">
-
- <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
- <t:if test="!isChoiceHidden()">
- <t:unless test="isDescNull()">
- <th class="desc">
- <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind">
- <t:image t:src="choiceOfPoll.name" alt="choiceOfPoll.description" t:dir="poll.pollId"/>
- </span>
- </th>
- <p:else>
- <th>
- <t:image t:src="choiceOfPoll.name" alt="choiceOfPoll.name" t:dir="poll.pollId"/>
- </th>
- </p:else>
- </t:unless>
- </t:if>
- </t:loop>
- </t:if>
+ <th t:type="loop" t:source="choices" t:value="choice" t:volatile="true">
+ <t:unless test="choice.hidden">
+ <t:block t:id="choiceText">
+ <span class="desc">${choice.text}</span>
+ </t:block>
+ <t:block t:id="choiceImage">
+ <a rel="lightbox[pollChoiceImages]" href="${imageLink}">
+ <img src="${imageThumb}" alt="${choice.description}"/>
+ </a>
+ </t:block>
+ <t:block t:id="choiceDate">
+ <t:output value="choice.date" format="dateFormat"/>
+ </t:block>
+ <t:if t:test="choice.description">
+ <span t:type="ck/Tooltip" t:value="choice.description" t:effect="blind">
+ <t:delegate to="choiceBlock" />
+ </span>
+ <p:else>
+ <t:delegate to="choiceBlock" />
+ </p:else>
+ </t:if>
+ <t:if test="canDeleteChoice()">
+ <t:actionlink t:id="deleteChoice" context="choice.id"
+ t:mixins="confirm" t:message="message:pollen.ui.choice.delete.confirm">
+ <img src="${asset:context:img/delete.png}" title="message:pollen.ui.choice.delete.title"
+ alt="message:pollen.ui.choice.delete.title"/>
+ </t:actionlink>
+ </t:if>
+ </t:unless>
+ </th>
</tr>
- </thead>
- <t:if test="pollRunning">
- <tfoot>
+ </thead><!--
+ <t:if test="pollRunning">-->
+<!-- <tfoot>
<tr>
- <t:if test="${accountFieldDisplayed}">
+ <t:if test="accountFieldDisplayed">
<th id="voterName">
<t:textField t:value="pollAccount.votingId" t:id="pollAccountName" t:validate="required"/>
</th>
@@ -136,7 +106,7 @@
<th></th>
</p:else>
</t:if>
- <t:loop t:source="poll.choices" t:value="choiceOfVote" volatile="true">
+ <t:loop t:source="choices" t:value="choice" volatile="true">
<t:if test="!choiceOfVote.hidden">
<th>
<t:if test="isNormalVoteCounting()">
@@ -155,24 +125,24 @@
</t:if>
</t:loop>
</tr>
- </tfoot>
- </t:if>
+ </tfoot>-->
+ <!--</t:if>-->
<tbody>
<t:unless t:test="poll.anonymous">
- <t:loop t:source="votes" t:value="vote" volatile="true">
+ <t:loop t:source="votes" t:value="vote" t:rowIndex="voteIndex" volatile="true">
<tr>
<td class="${evenodd.next}">
<t:if test="${AccountFieldDisplayed}">
<t:unless test="${currentVoteAnonymous}">
- ${currentVotingId}
+ ${vote.name}
<p:else>
?
</p:else>
</t:unless>
</t:if>
<t:unless test="${poll.anonymous}">
- <t:if test="isModifAllowed(currentVotingId)">
- <t:actionlink t:id="editVote" context="${currentVotingId}" t:zone="pollZone">
+ <t:if test="canEditVote()">
+ <t:actionlink t:id="editVote" context="voteIndex" t:zone="pollZone">
<img src="${asset:context:img/editSmall.png}" title="${message:edit}" alt="${message:edit}"/>
</t:actionlink>
</t:if>
@@ -231,7 +201,7 @@
<t:if test="poll.continuousResults">
<tr>
<td>
- <t:PageLink t:page="poll/results" t:context="${poll.pollId}">${message:results}</t:PageLink>
+ <t:PageLink t:page="poll/results" t:context="${poll.pollUId}">${message:results}</t:PageLink>
</td>
<t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
<t:if test="!isChoiceHidden()">
@@ -256,11 +226,11 @@
</div>
</t:if>
</t:form>
- </t:zone>
+ <!--</t:zone>-->
<!-- Ajout de choix -->
- <t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollId"/>
+ <t:ImageContextLink t:id="imgContext" t:thumb="true" t:dir="poll.pollUId"/>
<t:if test="${pollChoiceRunning}">
<h4>${message:addChoice}</h4>
<div id="choiceFormDiv">
1
0
Author: fdesbois
Date: 2010-03-19 16:05:04 +0100 (Fri, 19 Mar 2010)
New Revision: 2951
Log:
- Move SendMail thread in business module (started from PollenContext)
- Evo #148 : improve pager (with icons)
- Improve i18n managment for Tapestry integration (using tapestry-bundle goal from i18n plugin)
- Continue refactor of VoteForPoll page
Added:
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
trunk/pollen-ui/src/main/webapp/img/1leftarrow.png
trunk/pollen-ui/src/main/webapp/img/1rightarrow.png
trunk/pollen-ui/src/main/webapp/img/2leftarrow.png
trunk/pollen-ui/src/main/webapp/img/2rightarrow.png
Removed:
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java.orig
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/SendMail.java
trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/SendMailTest.java
Modified:
trunk/
trunk/doc/presentation-2010-03-11/Presentation-Pollen.odp
trunk/pollen-business/pom.xml
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenException.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteCountingConverter.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.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/main/java/org/chorem/pollen/business/utils/ContextUtil.java
trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
trunk/pollen-business/src/main/resources/pollen.properties
trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
trunk/pollen-business/src/test/resources/pollen.properties
trunk/pollen-ui/pom.xml
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollHelper.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_fr.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties
trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties
trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
trunk/pom.xml
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- target
nbactions.xml
.settings
.classpath
.project
*.ipr
*.iws
*.iml
+ target
nbactions.xml
.settings
.classpath
.project
*.ipr
*.iws
*.iml
.pollen
Modified: trunk/doc/presentation-2010-03-11/Presentation-Pollen.odp
===================================================================
(Binary files differ)
Modified: trunk/pollen-business/pom.xml
===================================================================
--- trunk/pollen-business/pom.xml 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/pom.xml 2010-03-19 15:05:04 UTC (rev 2951)
@@ -27,6 +27,10 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
@@ -38,6 +42,10 @@
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ </dependency>
<!-- <dependency>
<groupId>org.chorem</groupId>
<artifactId>chorem-commons</artifactId>
@@ -138,6 +146,15 @@
<goal>gen</goal>
</goals>
</execution>
+ <execution>
+ <id>make-bundle</id>
+ <goals>
+ <goal>bundle</goal>
+ </goals>
+ <configuration>
+ <bundleOutputName>pollen-business</bundleOutputName>
+ </configuration>
+ </execution>
</executions>
</plugin>
<!--<plugin>
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenBusinessException.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,6 +1,7 @@
package org.chorem.pollen.business;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* PollenBusinessException
@@ -18,13 +19,21 @@
private static final long serialVersionUID = 1L;
protected PollenExceptionType type;
+
+ protected Object[] args;
public PollenBusinessException(PollenExceptionType type) {
super(type.getMessage());
}
+ public PollenBusinessException(PollenExceptionType type, Object... args) {
+ super(type.getMessage());
+ this.args = args;
+ }
+
public enum PollenExceptionType {
- LOAD_CONFIGURATION(_("pollen.exception.load_configuration"));
+ //LOAD_CONFIGURATION(n_("pollen.exception.load_configuration")),
+ POLL_NOT_EXIST(n_("pollen.exception.poll_not_exist"));
private String message;
@@ -35,6 +44,9 @@
public String getMessage() {
return message;
}
+ }
+ public Object[] getArgs() {
+ return args;
}
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -7,6 +7,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
+import org.chorem.pollen.business.services.SendMail;
import org.chorem.pollen.business.services.ServiceUserImpl;
import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContext;
@@ -16,6 +17,8 @@
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
/**
* PollenContext
@@ -39,6 +42,8 @@
private static Date currentDate;
+ private static SendMail sendMail;
+
/**
* Default configuration file will be loaded using
* {@link org.nuiton.util.ApplicationConfig }.
@@ -59,8 +64,8 @@
loadConfiguration(conf);
} catch (ArgumentsParserException eee) {
- doCatch(eee,
- _("pollen.error.context.parse", PollenContext.DEFAULT_FILENAME));
+ doCatch(eee, n_("pollen.error.context.parse"),
+ PollenContext.DEFAULT_FILENAME);
}
}
@@ -94,7 +99,11 @@
*
*/
public static void start() {
- try {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Initialize i18n bundle");
+ }
+ I18n.setInitializer(new DefaultI18nInitializer("pollen-business"));
I18n.init();
ServiceUserImpl serviceUser = new ServiceUserImpl();
@@ -104,12 +113,15 @@
PollenProperty.ADMIN_EMAIL.getValue()
);
+ sendMail = new SendMail();
+ sendMail.start();
+
if (log.isInfoEnabled()) {
log.info("pollen is started !");
}
} catch (Exception eee) {
- doCatch(eee, _("pollen.error.context.start"));
+ doCatch(eee, n_("pollen.error.context.start"));
}
}
@@ -119,11 +131,16 @@
public static void stop() {
try {
getRootContext().closeContext();
+ sendMail.stopExec();
} catch (Exception eee) {
- doCatch(eee, _("pollen.error.context.stop"));
+ doCatch(eee, n_("pollen.error.context.stop"));
}
}
+ public static SendMail getSendMail() {
+ return sendMail;
+ }
+
/**
* Get a property from the configuration.
*
@@ -179,7 +196,7 @@
try {
return TopiaContextFactory.getContext(getProperties());
} catch (TopiaNotFoundException eee) {
- doCatch(eee, _("pollen.error.context.getRootContext"));
+ doCatch(eee, n_("pollen.error.context.getRootContext"));
}
return null;
}
@@ -191,10 +208,11 @@
*
* @param eee the exception to manage
* @param message the message to add to the new PollenException
+ * @param args for message
* @throws PollenException which contains the exception as the cause
*/
- public static void doCatch(Exception eee, String message) throws PollenException {
- doCatch(eee, message, null);
+ public static void doCatch(Exception eee, String message, Object... args) throws PollenException {
+ doCatch(null, eee, message);
}
/**
@@ -203,14 +221,15 @@
* {@code transaction} will be rollback.
* Used in catch statement in services.
*
+ * @param transaction the current TopiaContext
* @param eee the exception to manage
* @param message the message to add to the new PollenException
- * @param transaction the current TopiaContext
+ * @param args for message
* @throws PollenException
*/
- public static void doCatch(Exception eee, String message, TopiaContext transaction) throws PollenException {
+ public static void doCatch(TopiaContext transaction, Exception eee, String message, Object... args) throws PollenException {
if (log.isErrorEnabled()) {
- log.error(message, eee);
+ log.error(_(message, args), eee);
}
// rollback de la transaction courante
@@ -225,7 +244,7 @@
}
// PollenBusinessException must be managed (catch and throw) when needed
// if (! (eee instanceof PollenBusinessException)) {
- throw new PollenException(message, eee);
+ throw new PollenException(eee, message, args);
// }
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenException.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenException.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenException.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -16,8 +16,19 @@
private static final long serialVersionUID = 1L;
- public PollenException(String message, Throwable eee) {
+ protected Object[] args;
+
+// public PollenException(Throwable eee, String message) {
+// super(message, eee);
+// }
+
+ public PollenException(Throwable eee, String message, Object... args) {
super(message, eee);
+ this.args = args;
}
+ public Object[] getArgs() {
+ return args;
+ }
+
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPollConverter.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -88,7 +88,7 @@
pollDTO.setCreatorEmail(ePoll.getCreator().getEmail());
}
if (ePoll.getChoice().size() > 0) {
- pollDTO.setChoiceDTOs(choiceConverter.createChoiceDTOs(ePoll
+ pollDTO.setChoices(choiceConverter.createChoiceDTOs(ePoll
.getChoice()));
}
// if (ePoll.getVote().size() > 0) {
@@ -146,7 +146,7 @@
// mise à jour ou création des choix
ServiceChoice sChoice = new ServiceChoiceImpl();
- for (ChoiceDTO choiceDTO : pollDTO.getChoiceDTOs()) {
+ for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
boolean updated = sChoice.updateChoice(choiceDTO);
if (!updated) {
choiceDTO.setId(sChoice.createChoice(choiceDTO));
@@ -163,7 +163,7 @@
Iterator<Choice> itChoice = ePoll.getChoice().iterator();
while (itChoice.hasNext()) {
Choice currentChoice = itChoice.next();
- for (ChoiceDTO choiceDTO : pollDTO.getChoiceDTOs()) {
+ for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
if (currentChoice.getTopiaId().equals(choiceDTO.getId())) {
validChoice = true;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteCountingConverter.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteCountingConverter.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteCountingConverter.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -188,7 +188,7 @@
bPollDTO.getComments().add(createPollCommentDTO(comment));
}
for (PollChoiceDTO choice : pollDTO.getChoices()) {
- bPollDTO.getChoiceDTOs().add(createPollChoiceDTO(choice));
+ bPollDTO.getChoices().add(createPollChoiceDTO(choice));
}
// TODO conversion des groupes et des votes
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PollDTO.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -86,8 +86,6 @@
private List<VotingListDTO> votingListDTOs = new ArrayList<VotingListDTO>();
- private List<VoteDTO> voteDTOs = new ArrayList<VoteDTO>();
-
private int nbVotes;
private List<PreventRuleDTO> preventRuleDTOs = new ArrayList<PreventRuleDTO>();
@@ -362,14 +360,6 @@
this.votingListDTOs = votingListDTOs;
}
- public List<VoteDTO> getVoteDTOs() {
- return voteDTOs;
- }
-
- public void setVoteDTOs(List<VoteDTO> voteDTOs) {
- this.voteDTOs = voteDTOs;
- }
-
public int getNbVotes() {
return nbVotes;
}
@@ -378,13 +368,6 @@
this.nbVotes = nbVotes;
}
- public void addVote(VoteDTO vote) {
- if (voteDTOs == null) {
- voteDTOs = new ArrayList<VoteDTO>();
- }
- voteDTOs.add(vote);
- }
-
public List<PreventRuleDTO> getPreventRuleDTOs() {
return preventRuleDTOs;
}
@@ -400,11 +383,11 @@
preventRuleDTOs.add(rule);
}
- public List<ChoiceDTO> getChoiceDTOs() {
+ public List<ChoiceDTO> getChoices() {
return choiceDTOs;
}
- public void setChoiceDTOs(List<ChoiceDTO> choiceDTOs) {
+ public void setChoices(List<ChoiceDTO> choiceDTOs) {
this.choiceDTOs = choiceDTOs;
}
Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java (from rev 2943, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/SendMail.java)
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java (rev 0)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -0,0 +1,248 @@
+/* *##% 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 java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.chorem.pollen.business.utils.MailUtil;
+import org.nuiton.util.FileUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import au.com.bytecode.opencsv.CSVReader;
+import au.com.bytecode.opencsv.CSVWriter;
+import org.apache.commons.io.IOUtils;
+import org.chorem.pollen.business.PollenProperty;
+
+/**
+ * Mass mail management class.
+ *
+ * This class store email to send in a csv file, and send it (one per second) in
+ * a second time.
+ * This class can restart to send mail at application restart.
+ *
+ * For a mass mail sending to start, following files must be present:
+ * <ul>
+ * <li>xxx.emails : CSV file ("email", "subject", "body")</li>
+ * <li>xxx.index : next index to manage ( inited at 0)</li>
+ * </ul>
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SendMail extends Thread {
+
+ /** logger. */
+ private static final Logger log = LoggerFactory.getLogger(SendMail.class);
+
+ public static final String EXTENSION_MAIL = ".mail";
+ public static final String EXTENSION_INDEX = ".index";
+
+ /** Mail storage directory. */
+ protected File mailStorageDirectory;
+
+ protected volatile boolean stop;
+
+ public SendMail() {
+
+ // get email directory in configuration
+ // create it if not exists
+ String filename = PollenProperty.EMAIL_DIR.getValue();
+ mailStorageDirectory = new File(filename);
+ if (!mailStorageDirectory.exists()) {
+ if (mailStorageDirectory.mkdirs()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Email storage directory created in : " + mailStorageDirectory.getAbsolutePath());
+ }
+ }
+ }
+ }
+
+ public synchronized void stopExec() {
+ stop = true;
+ }
+
+ /*
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+
+ // try to find existing files
+ while (!stop) {
+ try {
+ sendAllMails();
+
+ // bloque thread until next notify
+ sleep();
+ }
+ catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error during SendMail main loop", ex);
+ }
+ }
+ }
+ }
+
+ protected synchronized void sleep() throws InterruptedException {
+ wait();
+ }
+
+ public synchronized void wakeUp() {
+ notifyAll();
+ }
+
+ /**
+ * Look for all xx.index file, and restart mail sending on
+ * non ending mass mail sending.
+ *
+ * After execution, delete mail and index file.
+ * @throws IOException
+ */
+ protected void sendAllMails() throws IOException {
+
+ // don't do for, allways take the first found
+ // a new one can be created when managing one other
+ List<File> indexFiles = null;
+ do {
+
+ // filter is java valid : .*\\.index
+ indexFiles = FileUtil.find(mailStorageDirectory, ".*\\" + EXTENSION_INDEX, false);
+
+ if (!indexFiles.isEmpty()) {
+ File indexFile = indexFiles.get(0);
+ // convert index content to int
+ String indexContent = FileUtils.readFileToString(indexFile, "UTF-8");
+ int index = Integer.parseInt(indexContent);
+
+ // get mail content file
+ File mailFile = new File(indexFile.getAbsolutePath().replaceAll(EXTENSION_INDEX + "$", EXTENSION_MAIL));
+
+ if (log.isDebugEnabled()) {
+ log.debug("Managing mail file : " + mailFile + " (from index " + indexContent + ")");
+ }
+
+ Reader indexFileReader = new BufferedReader(new FileReader(mailFile));
+ CSVReader cvsReader = new CSVReader(indexFileReader);
+
+ int currentIndex = 0;
+ String[] currentLine = cvsReader.readNext();
+ while (currentLine != null) {
+ String receiver = currentLine[0];
+ String subject = currentLine[1];
+ String body = currentLine[2];
+
+ // index contains next index to treat so == is ok
+ if (currentIndex >= index) {
+ String host = PollenProperty.EMAIL_HOST.getValue();
+ int port = Integer.parseInt(
+ PollenProperty.EMAIL_PORT.getValue());
+ String from = PollenProperty.EMAIL_FROM.getValue();
+ MailUtil.sendMail(host, port, from,
+ receiver, subject, body);
+
+ // index contains next index to treat
+ FileUtils.writeStringToFile(indexFile, String.valueOf(currentIndex + 1));
+
+ // wait 2 secondes between each mail to not
+ // load smtp server
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't wait between mail", ex);
+ }
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("Mail to " + receiver + " already sent in a previous execution, skip.");
+ }
+ }
+
+ currentIndex++;
+ currentLine = cvsReader.readNext();
+ }
+
+ // delete woth index and mail file
+ mailFile.delete();
+ indexFile.delete();
+ }
+ else {
+ if (log.isInfoEnabled()) {
+ log.info("No more index mail index file found, go to sleep a while :)");
+ }
+ }
+ } while (!indexFiles.isEmpty());
+ }
+
+ /**
+ * Prepare mail list.
+ *
+ * TODO : improve configuration reading
+ *
+ * @param id
+ * @param mailData
+ * @throws IOException
+ */
+ public void prepareMails(String id, List<Map<String, String>> mailData) throws IOException {
+
+ Writer fileWriter = null;
+ CSVWriter cvsWriter = null;
+ try {
+
+ // write CSV datas
+ File emailFile = new File(mailStorageDirectory, id + EXTENSION_MAIL);
+ fileWriter = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(emailFile)));
+ cvsWriter = new CSVWriter(fileWriter);
+
+ for (Map<String, String> singleMailData : mailData) {
+ String[] nextLine = new String[] {
+ singleMailData.get("receiver"),
+ singleMailData.get("subject"),
+ singleMailData.get("body")
+ };
+ cvsWriter.writeNext(nextLine);
+ }
+
+ // write index (default to 0)
+ File indexFile = new File(mailStorageDirectory, id + EXTENSION_INDEX);
+ FileUtil.writeString(indexFile, "0");
+ }
+ finally {
+ if (cvsWriter != null) {
+ cvsWriter.close();
+ }
+ IOUtils.closeQuietly(fileWriter);
+ }
+
+ }
+}
Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/SendMail.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -40,7 +40,7 @@
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.TopiaContext;
-import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* Implémentation du service de gestion des listes.
@@ -210,11 +210,9 @@
personList.addPollAccount(account);
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.serviceList.createAccountForPersonList",
- personList.getName(), account.getVotingId()),
- transaction
- );
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.serviceList.createAccountForPersonList"),
+ personList.getName(), account.getVotingId());
} finally {
PollenContext.doFinally(transaction);
}
@@ -247,11 +245,9 @@
personList.removePollAccount(accountId);
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.serviceList.deleteAccountFromPersonList",
- accountId, personList.getName(), personList.getId()),
- transaction
- );
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.serviceList.deleteAccountFromPersonList"),
+ accountId, personList.getName(), personList.getId());
} finally {
PollenContext.doFinally(transaction);
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePoll.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -78,16 +78,6 @@
public PollDTO findPollByPollId(String pollId);
/**
- * Récupération d'un sondage par son nom
- *
- * @param pollName nom du sondage
- * @return liste de sondages
- * @deprecated useless method : only used in tests
- */
- @Deprecated
- public List<PollDTO> findPollsByName(String pollName);
-
- /**
* Récupération des sondages d'un utilisateur
*
* @param userId Le créateur du sondage
@@ -137,7 +127,7 @@
public void createComment(PollDTO poll, CommentDTO comment);
/**
- * Delete a comment from a poll.
+ * Delete a comment from a {@code poll}.
*
* @param poll owner of the comment
* @param commentId id of the comment to delete
@@ -145,6 +135,15 @@
public void deleteComment(PollDTO poll, String commentId);
/**
+ * Retrieve all comments for the {@code poll}
+ *
+ * @param poll owner of the comment
+ * @return the list of comments of the poll
+ */
+ public List<CommentDTO> getComments(PollDTO poll);
+
+
+ /**
* Return the pollAccount corresponding to the {@code accountUId} for the
* restricted {@code poll}.
* TODO : need JUnit test, must be done for 1.3
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -53,6 +53,7 @@
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.nuiton.topia.TopiaContext;
@@ -60,6 +61,7 @@
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* Implémentation du service de gestion des sondages.
@@ -108,7 +110,7 @@
// ** Create new choices
ChoiceDAO choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
- for (ChoiceDTO choiceDTO : pollDTO.getChoiceDTOs()) {
+ for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
Choice choice =
PollenConverter.convert(choiceDTO, choiceDAO.create());
choice.setPoll(entity);
@@ -143,9 +145,9 @@
PollenConverter.convert(entity, pollDTO);
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.createPoll",
- pollDTO.getTitle(), pollDTO.getCreatorId()), transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.createPoll"),
+ pollDTO.getTitle(), pollDTO.getCreatorId());
} finally {
PollenContext.doFinally(transaction);
}
@@ -252,7 +254,7 @@
ChoiceDAO choiceDAO = PollenModelDAOHelper.getChoiceDAO(transaction);
// ** Update choices (no add, no remove)
- for (ChoiceDTO choiceDTO : pollDTO.getChoiceDTOs()) {
+ for (ChoiceDTO choiceDTO : pollDTO.getChoices()) {
Choice choice = choiceDAO.findByTopiaId(choiceDTO.getId());
PollenConverter.convert(choiceDTO, choice);
choice.update();
@@ -272,9 +274,9 @@
return true;
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.updatePoll",
- pollDTO.getTitle(), pollDTO.getPollId()), transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.updatePoll"),
+ pollDTO.getTitle(), pollDTO.getPollId());
return false;
} finally {
PollenContext.doFinally(transaction);
@@ -315,9 +317,8 @@
return true;
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.deletePoll", pollId),
- transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.deletePoll"), pollId);
return false;
} finally {
PollenContext.doFinally(transaction);
@@ -329,6 +330,10 @@
TopiaContext transaction = null;
PollDTO result = null;
try {
+ if (log.isInfoEnabled()) {
+ log.info("findPollByPollId : pollUId = " + pollId);
+ }
+
transaction = rootContext.beginTransaction();
pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
@@ -371,11 +376,11 @@
// }
// Load comments
- for (Comment comment : pollEntity.getComment()) {
- CommentDTO dto =
- PollenConverter.convert(comment, new CommentDTO());
- result.addComment(dto);
- }
+// for (Comment comment : pollEntity.getComment()) {
+// CommentDTO dto =
+// PollenConverter.convert(comment, new CommentDTO());
+// result.addComment(dto);
+// }
// Load preventRules
for (PreventRule rule : pollEntity.getPreventRule()) {
@@ -399,8 +404,8 @@
return result;
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.getPoll", pollId), transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.getPoll"), pollId);
return null;
} finally {
PollenContext.doFinally(transaction);
@@ -408,36 +413,6 @@
}
@Override
- public List<PollDTO> findPollsByName(String pollName) {
- TopiaContext transaction = null;
- List<PollDTO> results = null;
- List<Poll> pollEntities = null;
- try {
- transaction = rootContext.beginTransaction();
-
- pollDAO = PollenModelDAOHelper.getPollDAO(transaction);
-
- pollEntities = pollDAO.findAllByTitle(pollName);
-
- converter.setTransaction(transaction);
- results = converter.createPollDTOs(pollEntities);
-
- transaction.commitTransaction();
-
- if (log.isDebugEnabled()) {
- log.debug("Entities found: " + ((results == null) ? "null" : results.size()));
- }
-
- return results;
- } catch (Exception e) {
- ContextUtil.doCatch(e, transaction);
- return null;
- } finally {
- PollenContext.doFinally(transaction);
- }
- }
-
- @Override
public List<PollDTO> findPollsByUser(String userId) {
TopiaContext transaction = null;
List<PollDTO> results = null;
@@ -640,8 +615,8 @@
return results;
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.getAllPolls"), transaction);
+ ContextUtil.doCatch(eee, transaction,
+ _("pollen.error.servicePoll.getAllPolls"));
return null;
} finally {
PollenContext.doFinally(transaction);
@@ -652,6 +627,10 @@
public void createComment(PollDTO poll, CommentDTO comment) {
TopiaContext transaction = null;
try {
+ if (log.isInfoEnabled()) {
+ log.info("createComment : pollUId = " + poll.getPollId() +
+ " _ comment = " + comment);
+ }
transaction = rootContext.beginTransaction();
// Create the new comment
@@ -673,10 +652,9 @@
poll.addComment(comment);
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.addComment",
- comment.getAuthor(), poll.getTitle(), poll.getId()),
- transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.addComment"),
+ comment.getAuthor(), poll.getTitle(), poll.getId());
} finally {
PollenContext.doFinally(transaction);
}
@@ -686,6 +664,10 @@
public void deleteComment(PollDTO poll, String commentId) {
TopiaContext transaction = null;
try {
+ if (log.isInfoEnabled()) {
+ log.info("deleteComment : pollUId = " + poll.getPollId() +
+ " _ commentId = " + commentId);
+ }
transaction = rootContext.beginTransaction();
// Find the comment
@@ -706,15 +688,47 @@
poll.removeComment(commentId);
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.servicePoll.deleteComment", commentId,
- poll.getTitle(), poll.getId()), transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.deleteComment"), commentId,
+ poll.getTitle(), poll.getId());
} finally {
PollenContext.doFinally(transaction);
}
}
@Override
+ public List<CommentDTO> getComments(PollDTO poll) {
+ TopiaContext transaction = null;
+ List<CommentDTO> results = new ArrayList<CommentDTO>();
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("getComments : pollUId = " + poll.getPollId());
+ }
+ transaction = rootContext.beginTransaction();
+
+ CommentDAO dao = PollenModelDAOHelper.getCommentDAO(transaction);
+ TopiaQuery query = dao.createQuery().
+ add(Comment.POLL + "." + Poll.POLL_ID, poll.getPollId());
+
+ List<Comment> entities = dao.findAllByQuery(query);
+
+ for (Comment entity : entities) {
+ CommentDTO dto =
+ PollenConverter.convert(entity, new CommentDTO());
+ results.add(dto);
+ }
+
+ } catch (Exception eee) {
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.getComments"),
+ poll.getTitle(), poll.getId());
+ } finally {
+ PollenContext.doFinally(transaction);
+ }
+ return results;
+ }
+
+ @Override
public PollAccountDTO getRestrictedAccount(String accountUId, PollDTO poll) {
TopiaContext transaction = null;
PollAccountDTO result = null;
@@ -728,26 +742,34 @@
// Use PersonToList association entity to find coherence between
// the poll and votingId
- List<PersonToList> tmp = transaction.find(
- "FROM " + PersonToList.class.getName() +
- " WHERE pollAccount.accountId = :accountUId" +
- " AND votingList.poll.pollId = :pollUId",
- "accountUId", accountUId,
- "pollUId", poll.getPollId());
+// List<PersonToList> tmp = transaction.find(
+// "FROM " + PersonToList.class.getName() +
+// " WHERE pollAccount.accountId = :accountUId" +
+// " AND votingList.poll.pollId = :pollUId",
+// "accountUId", accountUId,
+// "pollUId", poll.getPollId());
- //PersonToListDAO dao = PollenModel
+ PersonToListDAO dao =
+ PollenModelDAOHelper.getPersonToListDAO(transaction);
+ TopiaQuery query = dao.createQuery().
+ add(PersonToList.POLL_ACCOUNT + "." +
+ PollAccount.ACCOUNT_ID, accountUId).
+ add(PersonToList.VOTING_LIST + "." +
+ VotingList.POLL + "." + Poll.POLL_ID, poll.getPollId());
- if (tmp.size() > 0) {
- PollAccount account = tmp.get(0).getPollAccount();
+ PersonToList assoc = dao.findByQuery(query);
+
+ if (assoc != null) {
+ PollAccount account = assoc.getPollAccount();
PollenConverter.convert(account, result);
}
} catch (Exception eee) {
- ContextUtil.doCatch(eee, transaction,
- "Unable to retrieve restricted account with accountUId = " +
- accountUId + " and poll with uid = " + poll.getPollId());
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.servicePoll.getRestrictedAccount"),
+ accountUId, poll.getPollId());
} finally {
- ContextUtil.doFinally(transaction);
+ PollenContext.doFinally(transaction);
}
return result;
}
Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java
===================================================================
--- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceResultsImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -45,7 +45,7 @@
import org.chorem.pollen.votecounting.services.ServiceVoteCounting;
import org.chorem.pollen.votecounting.services.ServiceVoteCountingImpl;
import org.nuiton.topia.TopiaContext;
-import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* Implémentation du service de gestion des résultats.
@@ -297,7 +297,7 @@
} catch (Exception eee) {
PollenContext.doCatch(eee,
- _("pollen.error.serviceResults.importPoll"));
+ n_("pollen.error.serviceResults.importPoll"));
}
return topiaId;
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 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceUserImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -31,7 +31,7 @@
import org.chorem.pollen.business.utils.ContextUtil;
import org.chorem.pollen.business.utils.MD5;
import org.nuiton.topia.TopiaContext;
-import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* Implémentation du service de gestion des utilisateurs.
@@ -335,9 +335,9 @@
transaction.commitTransaction();
}
} catch (Exception eee) {
- PollenContext.doCatch(eee,
- _("pollen.error.serviceUser.createDefaultAdmin",
- login, email), transaction);
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.serviceUser.createDefaultAdmin"),
+ login, email);
} finally {
PollenContext.doFinally(transaction);
}
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 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceVoteImpl.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -22,13 +22,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.business.PollenBusinessException;
import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.converters.DataPollAccountConverter;
import org.chorem.pollen.business.converters.DataVoteConverter;
import org.chorem.pollen.business.dto.PollAccountDTO;
import org.chorem.pollen.business.dto.PollDTO;
import org.chorem.pollen.business.dto.VoteDTO;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountDAO;
import org.chorem.pollen.business.persistence.PollenModelDAOHelper;
@@ -36,6 +36,9 @@
import org.chorem.pollen.business.persistence.VoteDAO;
import org.chorem.pollen.business.utils.ContextUtil;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaEntity;
+import static org.nuiton.i18n.I18n.n_;
/**
* Implémentation du service de gestion des votes.
@@ -46,7 +49,6 @@
public class ServiceVoteImpl implements ServiceVote {
private TopiaContext rootContext;
- private VoteDAO voteDAO = null;
private DataVoteConverter converter = new DataVoteConverter();
/** log. */
@@ -77,7 +79,8 @@
// .getId());
if (pollAccountEntity == null) {
log.debug("Nouveau compte associé au vote");
- pollAccountEntity = pollAccountDAO.create(ContextUtil.createPollenUrlId());
+ pollAccountEntity = pollAccountDAO.create(
+ PollenContext.createPollenUrlId());
// EVO #108 : Migration to ToPIA 2.3, the entity must be
// commited because an other findBy is called in the
// converter (wtf ?! :/). This behavior doesn't work
@@ -107,7 +110,7 @@
voteDTO.setPollAccountId(null);
}
- voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
+ VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
Vote voteEntity = voteDAO.create();
converter.setTransaction(transaction);
@@ -139,7 +142,7 @@
try {
transaction = rootContext.beginTransaction();
- voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
+ VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
Vote voteEntity = voteDAO.findByTopiaId(voteDTO.getId());
converter.setTransaction(transaction);
converter.populateVoteEntity(voteDTO, voteEntity);
@@ -166,7 +169,7 @@
try {
transaction = rootContext.beginTransaction();
- voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
+ VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
Vote voteEntity = voteDAO.findByTopiaId(voteId);
voteEntity.delete();
@@ -191,33 +194,39 @@
TopiaContext transaction = null;
List<VoteDTO> results = new ArrayList<VoteDTO>();
try {
+ if (log.isInfoEnabled()) {
+ log.info("getVotesByPoll : pollUId = " + poll.getPollId() +
+ " _ startIndex = " + startIndex +
+ " _ endIndex = " + endIndex);
+ }
+
// No need to load votes for an anonymous poll
if (poll.isAnonymous()) {
return results;
}
- // FIXME-FD20100309 : change model to suppress link from poll to vote
+ // FIXME-FD20100309 : change dto to suppress link from poll to vote
// It's not necessary to have votes when retrieving the poll, this
// method do this job only when it's needed
+ transaction = rootContext.beginTransaction();
- if (log.isDebugEnabled()) {
- log.debug("Load votes for poll with uid = " + poll.getPollId());
- log.debug("LIMIT : startIndex = " + startIndex + " _ " +
- "endIndex = " + endIndex);
- }
+// List<Vote> votes = transaction.find(
+// "FROM " + Vote.class.getName() +
+// " WHERE poll.pollId = :pollUId" +
+// " ORDER BY topiaCreateDate",
+// startIndex, endIndex,
+// "pollUId", poll.getPollId());
- transaction = rootContext.beginTransaction();
-
- // FIXME : refactor this to use TopiaQuery from ToPIA 2.3
+ VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
// Order the results by creation date (the last vote done will be
// at the end of the list)
- List<Vote> votes = transaction.find(
- "FROM " + Vote.class.getName() +
- " WHERE poll.pollId = :pollUId" +
- " ORDER BY topiaCreateDate",
- startIndex, endIndex,
- "pollUId", poll.getPollId());
+ TopiaQuery query = voteDAO.createQuery().
+ add(Vote.POLL + "." + Poll.POLL_ID, poll.getPollId()).
+ addOrder(TopiaEntity.TOPIA_CREATE_DATE).
+ setLimit(startIndex, endIndex);
+ List<Vote> votes = voteDAO.findAllByQuery(query);
+
if (log.isDebugEnabled()) {
log.debug("Nb votes found : " + votes.size());
}
@@ -225,11 +234,11 @@
results = converter.createVoteDTOs(votes);
} catch (Exception eee) {
- ContextUtil.doCatch(eee, transaction,
- "Unable to load votes from poll with uid = " +
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.serviceVote.getVotesByPoll"),
poll.getPollId());
} finally {
- ContextUtil.doFinally(transaction);
+ PollenContext.doFinally(transaction);
}
return results;
}
@@ -239,30 +248,39 @@
TopiaContext transaction = null;
boolean result = false;
try {
+ if (log.isInfoEnabled()) {
+ log.info("hasAlreadyVoted : votingId = " + votingId +
+ " _ pollUId = " + poll.getPollId());
+ }
transaction = rootContext.beginTransaction();
+
+// List<Long> tmp = transaction.find(
+// "SELECT COUNT(*)" +
+// " FROM " + Vote.class.getName() +
+// " WHERE poll.pollId = :pollUId" +
+// " AND pollAccount.votingId = :votingId",
+// "pollUId", poll.getPollId(),
+// "votingId", votingId);
- // Test using a count(*) on votes
- List<Long> tmp = transaction.find(
- "SELECT COUNT(*)" +
- " FROM " + Vote.class.getName() +
- " WHERE poll.pollId = :pollUId" +
- " AND pollAccount.votingId = :votingId",
- "pollUId", poll.getPollId(),
- "votingId", votingId);
+ // Test using a count on votes
+ TopiaQuery query = new TopiaQuery(Vote.class).
+ add(Vote.POLL + "." + Poll.POLL_ID, poll.getPollId()).
+ add(Vote.POLL_ACCOUNT + "." + PollAccount.VOTING_ID,
+ votingId);
- int count = tmp.get(0).intValue();
+ int count = query.executeCount(transaction);
// If the count is greater than 0, there is an existing votingId
// who has already voted for the poll
result = count > 0;
} catch (Exception eee) {
- ContextUtil.doCatch(eee, transaction,
- "Unable test vote existing for account with votingId = " +
- votingId + " and poll with uid = " + poll.getPollId());
+ PollenContext.doCatch(transaction, eee,
+ n_("pollen.error.serviceVote.hasAlreadyVoted"),
+ votingId, poll.getPollId());
} finally {
- ContextUtil.doFinally(transaction);
+ PollenContext.doFinally(transaction);
}
return result;
}
@@ -275,7 +293,7 @@
try {
transaction = rootContext.beginTransaction();
- voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
+ VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction);
if (properties == null) {
voteEntities = voteDAO.findAll();
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 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/utils/ContextUtil.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -353,7 +353,7 @@
}
// PollenBusinessException must be managed (catch and throw) when needed
// if (! (eee instanceof PollenBusinessException)) {
- throw new PollenException(message, eee);
+ throw new PollenException(eee, message);
// }
}
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -12,8 +12,13 @@
pollen.error.servicePoll.deleteComment=
pollen.error.servicePoll.deletePoll=
pollen.error.servicePoll.getAllPolls=
+pollen.error.servicePoll.getComments=
pollen.error.servicePoll.getPoll=
+pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUId \= %1$s and poll with uid \= %2$s
pollen.error.servicePoll.updatePoll=
pollen.error.serviceResults.importPoll=
pollen.error.serviceUser.createDefaultAdmin=
+pollen.error.serviceVote.getVotesByPoll=Unable to load votes from poll with uid \= %1$s
+pollen.error.serviceVote.hasAlreadyVoted=Unable test vote existing for account with votingId \= %1$s and poll with uid \= %2$s
pollen.exception.load_configuration=
+pollen.exception.poll_not_exist=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
Modified: trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties
===================================================================
--- trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -9,10 +9,15 @@
pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire cr\u00E9\u00E9 par %1$s pour le sondage %2$s (%3$s)
pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s cr\u00E9\u00E9 par %2$s
pollen.error.servicePoll.deleteComment=Impossible de supprimer le commentaire ayant pour identifiant "%1$s", appartenenant au sondage %2$s (%3$s)
-pollen.error.servicePoll.deletePoll=Impossible de supprimer le sondage ayant pour identifiant "%1$s"
+pollen.error.servicePoll.deletePoll=Impossible de supprimer le sondage ayant pou identifiant "%1$s"
pollen.error.servicePoll.getAllPolls=
+pollen.error.servicePoll.getComments=
pollen.error.servicePoll.getPoll=
+pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUId \= %1$s and poll with uid \= %2$s
pollen.error.servicePoll.updatePoll=Impossible de mettre \u00E0 jour le sondage %1$s (%2$s)
pollen.error.serviceResults.importPoll=
pollen.error.serviceUser.createDefaultAdmin=Impossible de cr\u00E9er l'administrateur par d\u00E9faut \: %1$s (%2$s)
+pollen.error.serviceVote.getVotesByPoll=
+pollen.error.serviceVote.hasAlreadyVoted=
pollen.exception.load_configuration=La configuration n'a pas \u00E9t\u00E9 charg\u00E9e correctement \! Veuillez v\u00E9rifier le d\u00E9marrage de l'application.
+pollen.exception.poll_not_exist=Il n'y a pas de sondage \u00E0 cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le compl\u00E8tement dans le champ d'adresse de votre navigateur.
Modified: trunk/pollen-business/src/main/resources/pollen.properties
===================================================================
--- trunk/pollen-business/src/main/resources/pollen.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/main/resources/pollen.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -49,7 +49,7 @@
pollen.emails.directory=.pollen/emails
## Nombre de votes a afficher par page
-pollen.ui.nbVotesPerPage=50
+pollen.ui.nbVotesPerPage=25
## Adresse du site (utilis\u00C3\u00A9e pour les emails de rappel)
siteUrl=
Copied: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java (from rev 2943, trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/SendMailTest.java)
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java (rev 0)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -0,0 +1,103 @@
+/* *##% Pollen
+ * Copyright (C) 2010 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 org.chorem.pollen.business.services.SendMail;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.chorem.pollen.business.PollenContext;
+import org.chorem.pollen.business.PollenProperty;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * Class for send mail storage class.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Ignore
+public class SendMailTest {
+
+ protected static SendMail sendMail;
+
+ @BeforeClass
+ public static void init() throws InterruptedException {
+
+ ApplicationConfig config = new ApplicationConfig();
+ config.setOption(PollenProperty.EMAIL_DIR.getKey(), "target" + File.separator + "massmail");
+ config.setOption(PollenProperty.EMAIL_HOST.getKey(), "smtp");
+ config.setOption(PollenProperty.EMAIL_PORT.getKey(), "25");
+ config.setOption(PollenProperty.EMAIL_FROM.getKey(), "pollenreminder(a)codelutin.com");
+
+ PollenContext.loadConfiguration(config);
+
+ sendMail = new SendMail();
+ sendMail.start();
+ Thread.sleep(3000);
+ }
+
+ /**
+ * Test to add mail and send mail.
+ *
+ * WARNING : This test really send mail, don't set it automatic.
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ @Test
+ public void testAddMail() throws IOException, InterruptedException {
+ List<Map<String, String>> mailList = new ArrayList<Map<String,String>>();
+
+ Map<String, String> mailMap = new HashMap<String, String>();
+ mailMap.put("receiver", "chatellier+test(a)codelutin.com");
+ mailMap.put("subject", "Test 18:00");
+ mailMap.put("body", "Test body");
+
+ Map<String, String> mailMap2 = new HashMap<String, String>();
+ mailMap2.put("receiver", "chorlet+test(a)codelutin.com");
+ mailMap2.put("subject", "CR, CR CR !!! 18:00");
+ mailMap2.put("body", "Des cr, encore des \"CRs\" !!!");
+
+ mailList.add(mailMap);
+ mailList.add(mailMap2);
+
+ sendMail.prepareMails("test", mailList);
+
+ String emailDir = PollenProperty.EMAIL_DIR.getValue();
+
+ Assert.assertTrue(new File(emailDir, "test.mail").exists());
+ Assert.assertTrue(new File(emailDir, "test.index").exists());
+ sendMail.wakeUp();
+
+ // TODO , en 5 secondes, il aura le temps d'envoyer 2 mails ?
+ Thread.sleep(5000);
+ Assert.assertFalse(new File(emailDir, "test.mail").exists());
+ Assert.assertFalse(new File(emailDir, "test.index").exists());
+ }
+}
Property changes on: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/SendMailTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java
===================================================================
--- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServicePollImplTest.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -116,7 +116,7 @@
choice3.setName("choice3");
choices.add(choice3);
- dto.setChoiceDTOs(choices);
+ dto.setChoices(choices);
final String result = instance.createPoll(dto);
if (log.isDebugEnabled()) {
@@ -214,24 +214,24 @@
/**
* Test of findPollsByName method, of class ServicePollImpl.
*/
- @Test
- public void testFindPollsByName() throws Exception {
- TestManager.start("testFindPollsByName");
- instance = new ServicePollImpl();
+// @Test
+// public void testFindPollsByName() throws Exception {
+// TestManager.start("testFindPollsByName");
+// instance = new ServicePollImpl();
+//
+// PollDTO dto = instance.getNewPoll();
+// dto.setDescription("Test_findPollsByName");
+// dto.setCreatorId("erwan");
+// dto.setAnonymous(false);
+// dto.setPollType(PollType.FREE);
+// dto.setChoiceType(ChoiceType.TEXT);
+// dto.setVoteCounting(VoteCountingType.NORMAL);
+// dto.setTitle("Test_findPollsByName");
+// String pollId = instance.createPoll(dto);
+// List<PollDTO> result = instance.findPollsByName("Test_findPollsByName");
+// assertEquals(result.size(), 1);
+// }
- PollDTO dto = instance.getNewPoll();
- dto.setDescription("Test_findPollsByName");
- dto.setCreatorId("erwan");
- dto.setAnonymous(false);
- dto.setPollType(PollType.FREE);
- dto.setChoiceType(ChoiceType.TEXT);
- dto.setVoteCounting(VoteCountingType.NORMAL);
- dto.setTitle("Test_findPollsByName");
- String pollId = instance.createPoll(dto);
- List<PollDTO> result = instance.findPollsByName("Test_findPollsByName");
- assertEquals(result.size(), 1);
- }
-
/**
* Test of findPollsByUser method, of class ServicePollImpl.
*/
@@ -474,4 +474,28 @@
test.execute();
}
+
+ /**
+ * Test of getRestrictedAccount method, of class ServicePollImpl.
+ */
+ //@Test
+ public void testGetRestrictedAccount() throws IOException {
+ TestManager.start("testGetRestrictedAccount");
+ instance = new ServicePollImpl();
+
+ /** PREPARE DATA **/
+ PollDTO poll = instance.getNewPoll();
+ poll.setTitle("restrictedAccount");
+ poll.setPollType(PollType.RESTRICTED);
+ poll.setChoiceType(ChoiceType.TEXT);
+ poll.setVoteCounting(VoteCountingType.NORMAL);
+ String id = instance.createPoll(poll);
+ poll.setId(id);
+
+ PollAccountDTO account = new PollAccountDTO();
+ account.setVotingId("toto");
+
+ // TODO
+
+ }
}
Modified: trunk/pollen-business/src/test/resources/pollen.properties
===================================================================
--- trunk/pollen-business/src/test/resources/pollen.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-business/src/test/resources/pollen.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,4 +1,4 @@
-# Configuration de la base de données
+# Configuration de la base de donn\u00C3\u00A9es
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.dialect=org.hibernate.dialect.H2Dialect
@@ -7,9 +7,11 @@
hibernate.connection.driver_class=org.h2.Driver
hibernate.connection.url=jdbc:h2:file:target/test-base/pollen
-# Initialisation de la base de données
+# Initialisation de la base de donn\u00C3\u00A9es
choiceType=DATE,IMAGE,TEXT
pollType=RESTRICTED,FREE,GROUP
voteCounting=NORMAL,PERCENTAGE,CONDORCET
adminLogin=admin
-adminPassword=admin
\ No newline at end of file
+adminPassword=admin
+
+pollen.emails.directory=target/test-emails
\ No newline at end of file
Modified: trunk/pollen-ui/pom.xml
===================================================================
--- trunk/pollen-ui/pom.xml 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/pom.xml 2010-03-19 15:05:04 UTC (rev 2951)
@@ -132,7 +132,6 @@
<goal>tapestry-bundle</goal>
</goals>
</execution>
-
</executions>
</plugin>
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Pager.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,13 +1,13 @@
package org.chorem.pollen.ui.components;
+import org.apache.tapestry5.Asset;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.slf4j.Logger;
@@ -42,11 +42,21 @@
private int currentPage;
/**
- * Number of rows to show per page.
+ * Number of rows to show per page, the page which contains the pager have
+ * to manage this property (using @Persist for exemple) to ensure that
+ * the pager will done its work correctly.
*/
@Parameter(required = true)
private int nbRowsPerPage;
+ /**
+ * Number of rows for each range. Static value different from variable
+ * nbRowsPerPage. This parameter is used to show some links to change
+ * nbRowsPerPage.
+ */
+ @Parameter("25")
+ private int range;
+
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String noPagerText;
@@ -59,6 +69,26 @@
@Inject
private Logger log;
+ @Inject
+ @Path("context:img/1leftarrow.png")
+ private Asset leftarrow1;
+
+ @Inject
+ @Path("context:img/2leftarrow.png")
+ private Asset leftarrow2;
+
+ @Inject
+ @Path("context:img/1rightarrow.png")
+ private Asset rightarrow1;
+
+ @Inject
+ @Path("context:img/2rightarrow.png")
+ private Asset rightarrow2;
+
+ private static final String ACTION_CHANGE_PAGE = "changePage";
+
+ private static final String ACTION_CHANGE_NB_ROWS = "changeNbRows";
+
void beginRender(MarkupWriter writer) {
if (log.isDebugEnabled()) {
log.debug("pager from : " + getFirstValue() + " to " + getLastValue());
@@ -77,10 +107,12 @@
if (hasPrevious()) {
int previousPage = currentPage - 1;
if (previousPage != getFirstPage()) {
- writeLink(writer, getFirstPage(), "<<", "p-pager-first");
+ writeChangePageLink(writer, getFirstPage(), leftarrow2,
+ "p-pager-first");
writer.write(" ");
}
- writeLink(writer, previousPage, "<", "p-pager-previous");
+ writeChangePageLink(writer, previousPage, leftarrow1,
+ "p-pager-previous");
writer.write(" ");
}
// Text display for current page
@@ -88,19 +120,32 @@
messages.format("rows-title",
getFirstValue(), getLastValue(), nbTotalRows));
writer.element("strong");
- writer.write(messages.format("page", currentPage));
+ writer.write(messages.format("page", currentPage, getLastPage()));
writer.end();
writer.end();
if (hasNext()) {
int nextPage = currentPage + 1;
writer.write(" ");
- writeLink(writer, nextPage, ">", "p-pager-next");
+ writeChangePageLink(writer, nextPage, rightarrow1, "p-pager-next");
if (nextPage != getLastPage()) {
writer.write(" ");
- writeLink(writer, getLastPage(), ">>", "p-pager-last");
+ writeChangePageLink(writer, getLastPage(),
+ rightarrow2, "p-pager-last");
}
}
+
+ int doubleNbPerPage = range * 2;
+ int quadrupleNbPerPage = range * 4;
+ writer.element("div", "class", "p-pager-nbrows");
+ writer.write(messages.format("showPerPage"));
+ writer.write(" ");
+ writeChangeNbRowsLink(writer, range);
+ writer.write(", ");
+ writeChangeNbRowsLink(writer, doubleNbPerPage);
+ writer.write(", ");
+ writeChangeNbRowsLink(writer, quadrupleNbPerPage);
+ writer.end();
}
writer.end();
}
@@ -110,25 +155,43 @@
}
/**
- * Use an action event to change the current page. The link refresh the
+ * Use an changePage event to change the current page. The link refresh the
* entire page, no zone is managed yet.
*
- * @param writer used to write a element
+ * @param writer used to write an element
* @param index new page to change (argument of onAction method)
- * @param text to write inside the a tag
+ * @param asset for action
* @param style of the css (class) for the a tag
*/
- protected void writeLink(MarkupWriter writer, int index,
- String text, String style) {
- Link link = resources.createEventLink(EventConstants.ACTION,
+ protected void writeChangePageLink(MarkupWriter writer, int index,
+ Asset asset, String style) {
+ Link link = resources.createEventLink(ACTION_CHANGE_PAGE,
new Object[] {index});
String title = messages.format("go-to", index);
writer.element("a", "href", link, "class", style, "title", title);
- writer.write(text);
+ writer.element("img", "src", asset,
+ "alt", style);
writer.end();
+ writer.end();
}
/**
+ * Use an changeNbRows event to change the number of rows per page. The link
+ * refresh the entire page, no zone is managed yet.
+ *
+ * @param writer used to write an element
+ * @param nbRows to show and needed for the link
+ */
+ protected void writeChangeNbRowsLink(MarkupWriter writer, int nbRows) {
+ Link link = resources.createEventLink(ACTION_CHANGE_NB_ROWS,
+ new Object[] {nbRows});
+ String title = messages.format("change-nbrows", nbRows);
+ writer.element("a", "href", link, "title", title);
+ writer.write(String.valueOf(nbRows));
+ writer.end();
+ }
+
+ /**
* Get the start index of the range shown.
*
* @return the start index for elements to show
@@ -190,8 +253,20 @@
*
* @param newPage to set
*/
- void onAction(int newPage) {
+ void onChangePage(int newPage) {
currentPage = newPage;
}
+ /**
+ * Action event for changing nb rows. The nbRowsPerPage is changed to
+ * {@code nbRows}.
+ *
+ * @param nbRows to set
+ */
+ void onChangeNbRows(int nbRows) {
+ nbRowsPerPage = nbRows;
+ // Reset to first page to avoid strange text like (Page 8/2)
+ currentPage = getFirstPage();
+ }
+
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollHelper.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollHelper.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollHelper.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -101,7 +101,7 @@
public static List<ChoiceDTO> getTextChoices(PollDTO oldPoll) {
List<ChoiceDTO> choices = new ArrayList<ChoiceDTO>();
if (oldPoll.getChoiceType() == ChoiceType.TEXT) {
- for (ChoiceDTO oldChoice : oldPoll.getChoiceDTOs()) {
+ for (ChoiceDTO oldChoice : oldPoll.getChoices()) {
ChoiceDTO choice = new ChoiceDTO();
choice.setName(oldChoice.getName());
choice.setDescription(oldChoice.getDescription());
@@ -120,7 +120,7 @@
public static List<DateChoiceUIO> getDateChoices(PollDTO oldPoll) {
List<DateChoiceUIO> choices = new ArrayList<DateChoiceUIO>();
if (oldPoll.getChoiceType() == ChoiceType.DATE) {
- for (ChoiceDTO oldChoice : oldPoll.getChoiceDTOs()) {
+ for (ChoiceDTO oldChoice : oldPoll.getChoices()) {
DateChoiceUIO choice = new DateChoiceUIO();
choice.setName(oldChoice.getName());
choice.setDescription(oldChoice.getDescription());
Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java (rev 0)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -0,0 +1,49 @@
+
+package org.chorem.pollen.ui.data;
+
+import org.apache.tapestry5.ValueEncoder;
+
+/**
+ * PollUri
+ *
+ * Created: 15 mars 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class PollUri {
+
+ private static final String SEPARATOR = ":";
+
+ protected String pollUId;
+
+ protected String accountUId;
+
+ public PollUri(String uri) {
+ String[] tab = uri.split(SEPARATOR);
+ pollUId = tab[0];
+ if (tab.length == 2) {
+ accountUId = tab[1];
+ }
+ }
+
+ public String getAccountUId() {
+ return accountUId;
+ }
+
+ public String getPollUId() {
+ return pollUId;
+ }
+
+ public String getUri() {
+ String uri = getPollUId();
+ if (getAccountUId() != null) {
+ uri += SEPARATOR + getAccountUId();
+ }
+ return uri;
+ }
+
+}
Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollUri.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -114,7 +114,7 @@
* @return la page de validation de cloture
*/
private Object closePoll() {
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ for (ChoiceDTO choice : poll.getChoices()) {
choice.setValidate(true);
}
Date now = new Date();
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -106,7 +106,7 @@
*/
void onActivate() {
choice = new ChoiceDTO();
- for (ChoiceDTO c : poll.getChoiceDTOs()) {
+ for (ChoiceDTO c : poll.getChoices()) {
if (choiceId.equals(c.getId())) {
choice = c;
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -48,6 +48,7 @@
import org.apache.tapestry5.ioc.services.PropertyAccess;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.upload.services.UploadSymbols;
+import org.chorem.pollen.business.PollenContext;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -74,7 +75,6 @@
import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
import org.chorem.pollen.ui.utils.FeedUtil;
import org.chorem.pollen.ui.utils.ImageUtil;
-import org.chorem.pollen.ui.utils.SendMail;
import org.chorem.pollen.ui.utils.UnitConverter;
import org.slf4j.Logger;
@@ -315,9 +315,6 @@
@Inject
private ServiceList serviceList;
-// @Inject
-// private SendMail sendMailService;
-
/**
* Méthode appelée lorsqu'on souhaite accéder à l'étape suivante de la
* création de sondage.
@@ -700,7 +697,7 @@
for (ChoiceDTO choice : choices) {
if (choice.getName() != null) {
choice.setValidate(true);
- poll.getChoiceDTOs().add(choice);
+ poll.getChoices().add(choice);
}
}
} else if (isDateChoices()) {
@@ -708,7 +705,7 @@
if (choice.getDate() != null) {
choice.setValidate(true);
choice.setName(String.valueOf(choice.getDate().getTime()));
- poll.getChoiceDTOs().add(choice);
+ poll.getChoices().add(choice);
}
}
} else if (isImgChoices()) {
@@ -719,7 +716,7 @@
"IMAGE")) {
imgChoice.setValidate(true);
imgChoice.setName(imgChoice.getImg().getFileName().replace(' ', '_'));
- poll.getChoiceDTOs().add(imgChoice);
+ poll.getChoices().add(imgChoice);
} else {
return false;
}
@@ -737,8 +734,8 @@
if (poll.isContinuousResults()) {
poll.setPublicResults(true);
}
- if (poll.getMaxChoiceNb() < 1 || poll.getMaxChoiceNb() > poll.getChoiceDTOs().size()) {
- poll.setMaxChoiceNb(poll.getChoiceDTOs().size());
+ if (poll.getMaxChoiceNb() < 1 || poll.getMaxChoiceNb() > poll.getChoices().size()) {
+ poll.setMaxChoiceNb(poll.getChoices().size());
}
return true;
@@ -854,14 +851,14 @@
}
// send mail preparation
-// try {
-// sendMailService.prepareMails(poll.getId(), mailList);
-// sendMailService.wakeUp();
-// } catch (IOException ex) {
-// if (log.isErrorEnabled()) {
-// log.error("Can't prepare send mail on disk, mail won't be send !!!", ex);
-// }
-// }
+ try {
+ PollenContext.getSendMail().prepareMails(poll.getId(), mailList);
+ PollenContext.getSendMail().wakeUp();
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't prepare send mail on disk, mail won't be send !!!", ex);
+ }
+ }
}
}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java.orig
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java.orig 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java.orig 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,1252 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.ui.pages.poll;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.ValidationException;
-import org.apache.tapestry5.annotations.Component;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.InjectPage;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.corelib.components.Form;
-import org.apache.tapestry5.corelib.components.Select;
-import org.apache.tapestry5.corelib.components.Zone;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.json.JSONObject;
-import org.apache.tapestry5.upload.services.UploadSymbols;
-import org.chorem.pollen.business.PollenProperty;
-import org.chorem.pollen.business.business.PreventRuleManager;
-import org.chorem.pollen.business.dto.ChoiceDTO;
-import org.chorem.pollen.business.dto.PersonListDTO;
-import org.chorem.pollen.business.dto.PollAccountDTO;
-import org.chorem.pollen.business.dto.PollDTO;
-import org.chorem.pollen.business.dto.PreventRuleDTO;
-import org.chorem.pollen.business.dto.UserDTO;
-import org.chorem.pollen.business.dto.VotingListDTO;
-import org.chorem.pollen.business.services.ServiceList;
-import org.chorem.pollen.business.services.ServicePoll;
-import org.chorem.pollen.business.services.ServicePollAccount;
-import org.chorem.pollen.common.ChoiceType;
-import org.chorem.pollen.common.PollType;
-import org.chorem.pollen.common.VoteCountingType;
-import org.chorem.pollen.ui.base.ContextLink;
-import org.chorem.pollen.ui.components.FeedBack;
-import org.chorem.pollen.ui.components.ImageContextLink;
-import org.chorem.pollen.ui.data.GenericSelectModel;
-import org.chorem.pollen.ui.data.AddressBarItem;
-import org.chorem.pollen.ui.data.PollHelper;
-import org.chorem.pollen.ui.data.PollStep;
-import org.chorem.pollen.ui.data.uio.DateChoiceUIO;
-import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
-import org.chorem.pollen.ui.utils.FeedUtil;
-import org.chorem.pollen.ui.utils.ImageUtil;
-import org.chorem.pollen.ui.utils.UnitConverter;
-import org.slf4j.Logger;
-
-/**
- * Classe de la page de création d'un sondage.
- *
- * @author kmorin
- * @author rannou
- * @version $Id: PollCreation.java 2893 2010-03-02 20:14:34Z fdesbois $
- */
-@IncludeStylesheet("context:css/pollCreation.css")
-public class PollCreation {
-
- @Inject
- private Logger log;
-
- /** Étape courante du formulaire */
- @Persist
- private PollStep step;
-
- /**
- * Objet de session représentant l'utilisateur identifié.
- */
- @SessionState
- private UserDTO user;
- @Property
- private boolean userExists;
-
- /**
- * Objet de session représentant l'url du site.
- */
- @SessionState
- @Property
- private String siteURL;
-
- /** Date de début du sondage (utilisée pour la validation). */
- private Date beginDateValidation;
-
- /** Date de début d'ajout des choix (utilisée pour la validation). */
- private Date beginChoiceDateValidation;
-
- /** Mixin de selection de liste de favoris */
- @SuppressWarnings("unused")
- private Select listSelect;
-
- @InjectComponent
- private Zone pollCreationZone;
-
- /**
- * Sondage créé par le formulaire
- */
- @Property
- @Persist
- private PollDTO poll;
-
- /**
- * Sondage copié pour créer un nouveau sondage
- */
- @Persist
- private PollDTO oldPoll;
-
- /**
- * Sondage copié existe.
- */
- private boolean oldPollExists = false;
-
- /**
- * variable utilisée pour déterminer si le bouton cliqué mène à l'étape
- * suivante
- */
- private boolean noStepSubmitSelected = false;
-
- /**
- * variable utilisée pour déterminer si le bouton d'ajout de choix a été
- * cliqué
- */
- @Persist
- private boolean addChoiceSelected;
-
- /**
- * variable utilisée pour déterminer le groupe à supprimer
- */
- private int deleteGroupId = -1;
-
- /**
- * variable utilisée pour déterminer s'il y a eu une exception lors de
- * l'upload des images
- */
- @Persist
- private boolean uploadExceptionCatched;
-
- /** variable utilisée pour l'affichage de la choiceNbCheckBox */
- @Property
- @Persist
- private boolean choiceNbCheckBox;
-
- /** variable utilisée pour l'affichage de la notificationCheckBox */
- @Property
- @Persist
- private boolean notificationCheckBox;
-
- /** variable utilisée pour l'affichage de la reminderCheckBox */
- @Property
- @Persist
- private boolean reminderCheckBox;
-
- /** Règle de notification de vote */
- @Property
- @Persist
- private PreventRuleDTO notificationPreventRule;
-
- /** Règle de notification pour le rappel des votants */
- @Property
- @Persist
- private PreventRuleDTO reminderPreventRule;
-
- /**
- * Groupes de votants à créer
- */
- @Property
- @Persist
- private List<VotingListDTO> votingLists;
-
- /**
- * Objet utilisé dans la boucle de parcours des listes de votants
- */
- @Property
- private VotingListDTO votingList;
-
- /**
- * Objet utilisé dans la boucle de parcours de la liste de votants courante
- */
- @SuppressWarnings("unused")
- @Property
- private PollAccountDTO votingListPerson;
-
- /**
- * Nombre de votants affichés initialement
- */
- @Property
- private int nbVotingListPersons = 5;
-
- /**
- * Liste modifiée actuellement
- */
- @Persist
- private int currentList;
-
- /**
- * Listes de favoris de l'utilisateur.
- */
- @Property
- @Persist
- private GenericSelectModel<PersonListDTO> personLists;
-
- /**
- * Liste de favoris sélectionnée.
- */
- @Property
- private PersonListDTO personList;
-
- /**
- * Nombre de choix affichés initialement
- */
- @Property
- private int nbChoices = 5;
-
- /**
- * Objet utilisé dans la boucle de parcours de la liste des choix
- */
- @SuppressWarnings("unused")
- @Property
- private ChoiceDTO choice;
-
- /**
- * Objet utilisé dans la boucle de parcours de la liste des choix
- */
- @SuppressWarnings("unused")
- @Property
- private DateChoiceUIO dateTypeChoice;
-
- /**
- * Objet utilisé dans la boucle de parcours de la liste des choix
- */
- @SuppressWarnings("unused")
- @Property
- private ImageChoiceUIO imgTypeChoice;
-
- /**
- * Liste des choix à créer
- */
- @Property
- @Persist
- private List<ChoiceDTO> choices;
-
- /**
- * Liste des choix à créer
- */
- @Property
- @Persist
- private List<DateChoiceUIO> dateTypeChoices;
-
- /**
- * Liste des choix à créer
- */
- @Property
- @Persist
- private List<ImageChoiceUIO> imgTypeChoices;
-
- /**
- * Contexte pour l'upload des images (parametres definis dans .tml)
- */
- @InjectComponent
- private ImageContextLink imgContext;
-
- /**
- * Contexte pour la gestion du flux RSS
- */
- @InjectComponent
- private ContextLink feedContext;
-
- /**
- * Formulaire de création de sondage
- */
- @Component(id = "pollCreationForm")
- private Form pollCreationForm;
- @Component(id = "choicesCreationForm")
- private Form choicesCreationForm;
-
- @InjectPage
- private CreationValidation creationValidation;
-
- @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title")
- @Property
- private String title;
-
- @SuppressWarnings("unused")
- @Property
- private AddressBarItem[] address;
-
- @Inject
- private PropertyAccess _propertyAccess;
-
- @Inject
- private ComponentResources resources;
-
- /** Affichage des messages pour l'utilisateur */
- @Component(id = "feedback")
- private FeedBack feedback;
-
- /** Tailles maximales des fichiers uploadés */
- @Inject
- @Symbol(UploadSymbols.FILESIZE_MAX)
- private int fileSizeMax;
- @Inject
- @Symbol(UploadSymbols.REQUESTSIZE_MAX)
- private int requestSizeMax;
-
- @Inject
- private Messages messages;
-
- @Inject
- private Logger logger;
-
- /** Injection des services */
- @Inject
- private ServicePoll servicePoll;
- @Inject
- private ServicePollAccount servicePollAccount;
- @Inject
- private ServiceList serviceList;
-
- /**
- * Méthode appelée lorsqu'on souhaite accéder à l'étape suivante de la
- * création de sondage.
- */
- @Log
- Object onSuccessFromPollCreationForm() {
- if (log.isDebugEnabled()) {
- log.debug("Step : " + step);
- }
- switch (step) {
- case POLL:
- adaptStepPoll();
- step = PollStep.OPTIONS;
- break;
- case OPTIONS:
- adaptStepOptions();
- if (isFreePoll()) {
- step = PollStep.CHOICES;
- } else {
- step = PollStep.LISTS;
- }
- break;
- case LISTS:
- if (deleteGroupId >= 0) {
- votingLists.remove(deleteGroupId);
- }
- if (!noStepSubmitSelected) {
- step = PollStep.CHOICES;
- }
- break;
- case CHOICES:
- break;
- default:
- step = PollStep.POLL;
- break;
- }
- // Cas particulier, autre formulaire pour les choix
- if (step.equals(PollStep.CHOICES)) {
- return choicesCreationForm;
- }
- return pollCreationForm;
- }
-
- /**
- * Méthode appelée que le formulaire soit valide ou non. Il est nécessaire
- * de la redéfinir pour qu'en cas d'erreur de validation, la zone soit tout
- * de même mise à jour pour afficher l'erreur.
- */
- @Log
- Object onSubmitFromPollCreationForm() {
- return pollCreationForm;
- }
-
- /**
- * Méthode appelée lorsqu'on souhaite valider la création du sondage.
- */
- Object onSuccessFromChoicesCreationForm() {
- if (!addChoiceSelected) {
-
- // Préparation et création du sondage
- if (!preparePoll()) {
- return this;
- }
- createPoll();
-
- creationValidation.setPoll(poll);
- return creationValidation;
- }
-
- return this;
- }
-
- /**
- * Méthode appelée lorsqu'on souhaite accéder à l'étape précédente de la
- * création de sondage.
- */
- Object onPrevious() {
- switch (step) {
- case OPTIONS:
- step = PollStep.POLL;
- break;
- case LISTS:
- step = PollStep.OPTIONS;
- break;
- case CHOICES:
- if (isFreePoll()) {
- step = PollStep.OPTIONS;
- } else {
- step = PollStep.LISTS;
- }
- break;
- default:
- step = PollStep.POLL;
- break;
- }
- return pollCreationForm; // Pas de gestion du formulaire des choix car derniere etape
- }
-
- /**
- * Méthode appelée lors de la validation du formulaire. Validation du champs
- * beginDate.
- *
- * @throws ValidationException
- */
- void onValidateFromBeginDate(Date value) throws ValidationException {
- beginDateValidation = value;
- if (value != null && value.before(new Date())) {
- throw new ValidationException(messages.get("beginDate-validate"));
- }
- }
-
- /**
- * Méthode appelée lors de la validation du formulaire. Validation du champs
- * endDate.
- *
- * @throws ValidationException
- */
- void onValidateFromEndDate(Date value) throws ValidationException {
- if (beginDateValidation == null) {
- beginDateValidation = new Date();
- }
-
- if (value != null && value.before(beginDateValidation)) {
- throw new ValidationException(messages.get("endDate-validate"));
- }
- }
-
- /**
- * Méthode appelée lors de la validation du formulaire. Validation du champs
- * beginChoiceDate.
- *
- * @throws ValidationException
- */
- void onValidateFromBeginChoiceDate(Date value) throws ValidationException {
- if (beginDateValidation == null) {
- beginDateValidation = new Date();
- }
- beginChoiceDateValidation = value;
- if (value != null && value.after(beginDateValidation)) {
- throw new ValidationException(messages
- .get("beginChoiceDate-validate"));
- }
- }
- /**
- * Méthode appelée lors de la validation du formulaire. Validation du champs
- * endChoiceDate.
- *
- * @throws ValidationException
- */
- void onValidateFromEndChoiceDate(Date value) throws ValidationException {
- if (beginChoiceDateValidation == null) {
- beginChoiceDateValidation = new Date();
- }
-
- if (value != null && value.before(beginChoiceDateValidation)) {
- throw new ValidationException(messages.get("endChoiceDate-validate"));
- }
- }
-
- /**
- * Méthode appelée lors de la validation du formulaire. Validation des
- * listes de votants.
- *
- * @throws ValidationException
- */
- void onValidateFormFromPollCreationForm() throws ValidationException {
- if (noStepSubmitSelected) {
- return;
- }
-
- // Validation des votants
- if (step == PollStep.LISTS) {
- int nbListEqual = 0;
- int nbEqual = 0;
- int nbNotNull = 0;
-
- // Repérage des doublons (listes)
- for (VotingListDTO list1 : votingLists) {
- for (VotingListDTO list2 : votingLists) {
- if (list1.getName().equals(list2.getName())) {
- nbListEqual++;
- }
- }
- }
-
- if (nbListEqual > votingLists.size()) {
- throw new ValidationException(messages.get("lists-validate"));
- }
-
- // Repérage des doublons (votants)
- for (VotingListDTO list1 : votingLists) {
- int nbLocalNotNull = 0;
- for (PollAccountDTO account1 : list1.getPollAccountDTOs()) {
- if (account1.getVotingId() != null
- && account1.getVotingId() != "") {
- nbNotNull++;
- nbLocalNotNull++;
-
- // comparaison avec les autres votants
- for (VotingListDTO list2 : votingLists) {
- for (PollAccountDTO account2 : list2
- .getPollAccountDTOs()) {
- if (account2.getVotingId() != null
- && account1.getVotingId() != "") {
- if (account1.getVotingId().equals(
- account2.getVotingId())) {
- nbEqual++;
- }
- }
- }
- }
- }
- }
- if (nbLocalNotNull == 0) {
- throw new ValidationException(messages
- .get("noList-validate"));
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Votants (equal/notNull) : " + nbEqual + "/"
- + nbNotNull);
- }
- if (nbEqual > nbNotNull) {
- throw new ValidationException(messages.get("list-validate"));
- }
- }
- }
-
- /**
- * Méthode appelée lors de la validation du formulaire. Validation de la
- * liste de choix.
- *
- * @throws ValidationException
- */
- void onValidateFormFromChoicesCreationForm() throws ValidationException {
- int nbEqual = 0;
- int nbNotNull = 0;
-
- // Validation des choix
- if (step == PollStep.CHOICES) {
-
- // Repérage des doublons (type Texte)
- if (isTextChoices()) {
- for (ChoiceDTO choice1 : choices) {
- if (choice1.getName() != null) {
- nbNotNull++;
- for (ChoiceDTO choice2 : choices) {
- if (choice2.getName() != null) {
- if (choice1.getName().equals(choice2.getName())) {
- nbEqual++;
- }
- }
- }
- }
- }
- // Repérage des doublons (type Date)
- } else if (isDateChoices()) {
- for (DateChoiceUIO choice1 : dateTypeChoices) {
- if (choice1.getDate() != null) {
- nbNotNull++;
- for (DateChoiceUIO choice2 : dateTypeChoices) {
- if (choice2.getDate() != null) {
- if (choice1.getDate().equals(choice2.getDate())) {
- nbEqual++;
- }
- }
- }
- }
- }
- // Repérage des doublons (type Image)
- } else if (isImgChoices()) {
- for (ImageChoiceUIO choice1 : imgTypeChoices) {
- if (choice1.getImg() != null) {
- nbNotNull++;
- for (ImageChoiceUIO choice2 : imgTypeChoices) {
- if (choice2.getImg() != null) {
- if (choice1.getImg().getFileName().equals(
- choice2.getImg().getFileName())) {
- nbEqual++;
- }
- }
- }
- }
- }
- }
-
- if (nbNotNull == 0) {
- throw new ValidationException(messages.get("noChoice-validate"));
- }
- if (nbEqual > nbNotNull) {
- throw new ValidationException(messages.get("choice-validate"));
- }
- }
- }
-
- /** Echec lors du téléchargement */
- Object onUploadException(FileUploadException e) {
- logger.error(e.getMessage());
- String fSize = UnitConverter.getFormattedFileSize(fileSizeMax);
- String rSize = UnitConverter.getFormattedFileSize(requestSizeMax);
- feedback.addError(messages.format("uploadError", fSize, rSize));
- uploadExceptionCatched = true;
- return this;
- }
-
- /**
- * Réinitialisation des options en fonction des autres options.
- */
- private void adaptStepOptions() {
- if (poll.isAnonymous()) {
- poll.setAnonymousVoteAllowed(true);
- }
- if (poll.isContinuousResults()) {
- poll.setPublicResults(true);
- }
- }
-
- /**
- * Réinitialisation des listes de votants en fonction du type de sondage.
- */
- @Log
- private void adaptStepPoll() {
-
- // Sondage libre : suppression de toutes les listes
- if (isFreePoll()) {
- votingLists.clear();
- }
-
- // Sondage restreint : suppression des listes supplémentaires
- else if (isRestrictedPoll() && votingLists.size() > 1) {
- for (int i = 1; i < votingLists.size(); i++) {
- votingLists.remove(i);
- }
- currentList = 0;
- }
-
- // Sondage non libre : création d'une liste initiale
- else if (votingLists.isEmpty()) {
- votingList = new VotingListDTO();
- for (int i = 0; i < nbVotingListPersons; i++) {
- votingList.getPollAccountDTOs().add(new PollAccountDTO());
- }
- votingLists.add(votingList);
- currentList = getVotingListIndex();
- }
-
- if (poll.getBeginDate() != null) {
- poll.setEndChoiceDate(poll.getBeginDate());
- }
- }
-
- /**
- * Préparation du sondage.
- */
- @Log
- private boolean preparePoll() {
-
- // Ajout de l'identifiant du créateur
- if (userExists) {
- poll.setUserId(user.getId());
- }
-
- // Ajout des règles de notification au sondage
- if (notificationCheckBox) {
- poll.getPreventRuleDTOs().add(notificationPreventRule);
- }
- if (reminderCheckBox) {
- poll.getPreventRuleDTOs().add(reminderPreventRule);
- }
-
- // Ajout des groupes de votants au sondage
- // après suppression des entrées vides
- if (!isFreePoll()) {
- for (VotingListDTO list : votingLists) {
- Iterator<PollAccountDTO> it = list.getPollAccountDTOs()
- .iterator();
- while (it.hasNext()) {
- if (it.next().getVotingId() == null) {
- it.remove();
- }
- }
- }
- poll.setVotingListDTOs(votingLists);
- }
-
-
- // Ajout des choix au sondage
- if (isTextChoices()) {
- for (ChoiceDTO choice : choices) {
- if (choice.getName() != null) {
- choice.setValidate(true);
- poll.getChoiceDTOs().add(choice);
- }
- }
- } else if (isDateChoices()) {
- for (DateChoiceUIO choice : dateTypeChoices) {
- if (choice.getDate() != null) {
- choice.setValidate(true);
- choice.setName(String.valueOf(choice.getDate().getTime()));
- poll.getChoiceDTOs().add(choice);
- }
- }
- } else if (isImgChoices()) {
- for (ImageChoiceUIO imgChoice : imgTypeChoices) {
- if (imgChoice.getImg() != null) {
- logger.debug("Image: " + imgChoice.getImg().getFileName()
- + ", type: " + imgChoice.getImg().getContentType());
- if (imgChoice.getImg().getContentType().contains("image")
- || imgChoice.getImg().getContentType().contains(
- "IMAGE")) {
- imgChoice.setValidate(true);
- imgChoice.setName(imgChoice.getImg().getFileName()
- .replace(' ', '_'));
- poll.getChoiceDTOs().add(imgChoice);
- } else {
- return false;
- }
- }
- }
- }
-
- // Retouche des attributs dépendants l'un de l'autre
- if (poll.getBeginDate() == null) {
- poll.setBeginDate(new Date());
- }
- if (poll.isAnonymous()) {
- poll.setAnonymousVoteAllowed(true);
- }
- if (poll.isContinuousResults()) {
- poll.setPublicResults(true);
- }
- if (poll.getMaxChoiceNb() < 1
- || poll.getMaxChoiceNb() > poll.getChoiceDTOs().size()) {
- poll.setMaxChoiceNb(poll.getChoiceDTOs().size());
- }
-
- return true;
- }
-
- /**
- * Création du sondage.
- */
- private void createPoll() {
-
- // Création du sondage
- servicePoll.createPoll(poll);
-
- // FD-20100226 : Can't be null, an exception will be thrown if a
- // problem comes from createPoll
- //if (poll.getId() != null) {
-
- // Création des images
- if (poll.getChoiceType() == ChoiceType.IMAGE) {
- File dir = imgContext.getImageDir();
- ImageUtil.saveImages(imgTypeChoices, dir);
- }
-
- // FD-20100226 : not necessary, the service will update
- // automatically the poll when it was created
- // Mise à jour du sondage :
- //poll = servicePoll.findPollById(poll.getId());
-
- // Mise à jour du flux Atom et envoi d'un mail de confirmation
- addFeedEntry();
- sendMailNotification();
- //}
- }
-
- /** Ajout d'une entrée dans le flux de syndication */
- private void addFeedEntry() {
- PollAccountDTO creator = servicePollAccount.findPollAccountById(poll
- .getCreatorId());
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
- File feedFile = feedContext.getFile(poll.getPollId());
-
- FeedUtil.createFeed(feedFile, "atom_1.0", messages.format(
- "pollFeed_title", poll.getTitle()), siteURL, messages.format(
- "pollFeed_desc", poll.getDescription()));
- FeedUtil.feedFeed(feedFile, messages.format("pollFeed_createTitle",
- creator.getVotingId()), voteURL, messages
- .get("pollFeed_createContent"));
- }
-
- /** Envoi du mail de notification */
- private void sendMailNotification() {
- PollAccountDTO creator = servicePollAccount.findPollAccountById(poll
- .getCreatorId());
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
- String modifURL = siteURL + "poll/Modification/" + poll.getPollId()
- + ":" + creator.getAccountId();
- Map<String, String> data = new HashMap<String, String>();
- data.put("host", PollenProperty.EMAIL_HOST.getValue());
- data.put("port", PollenProperty.EMAIL_PORT.getValue());
- data.put("from", PollenProperty.EMAIL_FROM.getValue());
-
- // Mail au créateur
- if (poll.getCreatorEmail() != null) {
- data.put("to", poll.getCreatorEmail());
- data.put("title", messages.format("creatorEmail_subject", poll
- .getTitle()));
- data.put("msg", messages.format("creatorEmail_msg",
- poll.getTitle(), voteURL, modifURL));
-
- PreventRuleManager.emailAction(data);
- }
-
- // Mails aux votants
- for (VotingListDTO list : poll.getVotingListDTOs()) {
- for (PollAccountDTO account : list.getPollAccountDTOs()) {
- if (account.getEmail() != null) {
- String accountVoteURL = voteURL + ":"
- + account.getAccountId();
-
- data.put("to", account.getEmail());
- data.put("title", messages.format("votingEmail_subject",
- poll.getTitle()));
- data
- .put("msg", messages.format("votingEmail_msg", poll
- .getTitle(), account.getVotingId(),
- accountVoteURL));
-
- PreventRuleManager.emailAction(data);
- }
- }
- }
- }
-
- public String getChoiceDateDisplay() {
- return poll.isChoiceAddAllowed() ? "display: block;" : "display: none;";
- }
-
- public String getChoiceNbDisplay() {
- return choiceNbCheckBox ? "display: block;" : "display: none;";
- }
-
- public String getNotificationDisplay() {
- return notificationCheckBox ? "display: block;" : "display: none;";
- }
-
- public String getReminderDisplay() {
- return reminderCheckBox ? "display: block;" : "display: none;";
- }
-
- /** Retourne l'index de la liste courante */
- public int getVotingListIndex() {
- return votingLists.indexOf(votingList);
- }
-
- /** Retourne le numéro de la liste courante (index+1) */
- public int getVotingListNumber() {
- return votingLists.indexOf(votingList) + 1;
- }
-
- /** Retourne la chaîne correspondant à l'étape courante */
- public String getStepLegend() {
- Integer index = step.getIndex();
-
- // corrections selon le type de sondage
- if (isFreePoll()) {
- if (step == PollStep.CHOICES) {
- index--;
- }
- }
-
- // mise en forme du message
- switch (step) {
- case POLL:
- return messages.format("pollLegend", index);
- case OPTIONS:
- return messages.format("optionsLegend", index);
- case LISTS:
- return messages.format("listsLegend", index);
- case CHOICES:
- return messages.format("choicesLegend", index);
- default:
- return "";
- }
- }
-
- /** Retourne la classe CSS correspondant au groupe courant */
- public String getCurrentListClass() {
- if (votingLists.size() > 1 && getVotingListIndex() == currentList) {
- return "currentGroupDiv";
- }
- return "groupDiv";
- }
-
- /**
- * Retourne s'il existe plusieurs groupes.
- */
- public boolean isSeveralGroups() {
- return votingLists.size() > 1;
- }
-
- public boolean isInPoll() {
- return step == PollStep.POLL;
- }
-
- public boolean isInLists() {
- return step == PollStep.LISTS;
- }
-
- public boolean isInChoices() {
- return step == PollStep.CHOICES;
- }
-
- public boolean isInOptions() {
- return step == PollStep.OPTIONS;
- }
-
- public boolean isNormalVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.NORMAL;
- }
-
- public boolean isPercentageVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.PERCENTAGE;
- }
-
- public boolean isCondorcetVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.CONDORCET;
- }
-
- public boolean isNumberVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.NUMBER;
- }
-
- public boolean isFreePoll() {
- return poll.getPollType() == PollType.FREE;
- }
-
- public boolean isRestrictedPoll() {
- return poll.getPollType() == PollType.RESTRICTED;
- }
-
- public boolean isGroupPoll() {
- return poll.getPollType() == PollType.GROUP;
- }
-
- public boolean isTextChoices() {
- return poll.getChoiceType() == ChoiceType.TEXT;
- }
-
- public boolean isDateChoices() {
- return poll.getChoiceType() == ChoiceType.DATE;
- }
-
- public boolean isImgChoices() {
- return poll.getChoiceType() == ChoiceType.IMAGE;
- }
-
- /**
- * Méthode appelée à la sélection d'une liste de votants. Le mixin
- * ck/OnEvent ne permet pas de retourner le contenu d'une zone. Il faut donc
- * passer par une fonction JavaScript pour activer un event link. Un lien
- * est créé. Il sera retourné à la fonction JavaScript onCompleteCallback
- * pour mettre à jour la zone.
- *
- * @param value
- * @return un JSONObject contenant l'url de l'évènement mettant à jour la
- * zone.
- */
- public JSONObject onChangeFromListSelect(String value) {
- if (StringUtils.isNotEmpty(value)) {
- personList = serviceList.findPersonListById(value);
-
- // Copie des personnes de la liste de favoris dans la liste de votants
- for (PollAccountDTO account : personList.getPollAccounts()) {
- account.setId("");
- account.setPersonListId("");
- }
-
- votingLists.get(currentList).setPollAccountDTOs(
- personList.getPollAccounts());
- }
- return createParamsForCallback();
- }
-
- /**
- * Méthode appelée à la sélection d'un type de choix. Le mixin ck/OnEvent ne
- * permet pas de retourner le contenu d'une zone. Il faut donc passer par
- * une fonction JavaScript pour activer un event link. Un lien est créé. Il
- * sera retourné à la fonction JavaScript onCompleteCallback pour mettre à
- * jour la zone.
- *
- * @return un JSONObject contenant l'url de l'évènement mettant à jour la
- * zone.
- */
- public JSONObject onChangeFromChoiceType(String value) {
- poll.setChoiceType(ChoiceType.valueOf(value));
- return createParamsForCallback();
- }
-
- /**
- * Création d'un JSONObject contenant un identifiant de zone et une url pour
- * un évènement.
- *
- * @return un JSONObject contenant un zoneId et une url.
- */
- private JSONObject createParamsForCallback() {
- JSONObject json = new JSONObject();
- Link link = resources.createEventLink("updatePollCreationZone");
- json.put("link", link.toAbsoluteURI());
- json.put("zoneId", "pollCreationZone");
- return json;
- }
-
- /**
- * Méthode appelée par le callback JavaScript pour mettre à jour la zone.
- *
- * @return le contenu mis à jour de la zone.
- */
- public Object onUpdatePollCreationZone() {
- return pollCreationZone.getBody();
- }
-
- /**
- * Méthode appelée pour l'ajout d'une ligne supplémentaire dans le
- * formulaire des listes de votants.
- */
- void onSelectedFromAddPerson(int i) {
- votingLists.get(i).getPollAccountDTOs().add(new PollAccountDTO());
- noStepSubmitSelected = true;
- }
-
- /**
- * Méthode appelée pour l'ajout d'un groupe dans le formulaire des listes de
- * votants.
- */
- void onSelectedFromAddGroup() {
- votingList = new VotingListDTO();
- for (int i = 0; i < nbVotingListPersons; i++) {
- votingList.getPollAccountDTOs().add(new PollAccountDTO());
- }
- votingLists.add(votingList);
- currentList = getVotingListIndex();
- noStepSubmitSelected = true;
- }
-
- /**
- * Méthode appelée lors de la suppression d'un groupe dans le formulaire des
- * listes de votants.
- */
- void onSelectedFromDeleteGroup(int i) {
- //votingLists.remove(i);
- if (currentList == i) {
- currentList = votingLists.size() - 1;
- } else if (currentList > i) {
- currentList--;
- }
- deleteGroupId = i;
- noStepSubmitSelected = true;
- }
-
- /**
- * Méthode appelée à la selection d'un groupe dans le formulaire des listes
- * de votants.
- */
- void onSelectedFromEditGroup(int i) {
- currentList = i;
- noStepSubmitSelected = true;
- }
-
- /**
- * Méthode appelée pour l'ajout d'une ligne supplémentaire dans le
- * formulaire des choix.
- */
- void onSelectedFromAddChoice() {
- if (poll.getChoiceType() == ChoiceType.DATE) {
- dateTypeChoices.add(new DateChoiceUIO());
- } else if (poll.getChoiceType() == ChoiceType.IMAGE) {
- imgTypeChoices.add(new ImageChoiceUIO());
- } else {
- choices.add(new ChoiceDTO());
- }
- addChoiceSelected = true;
- }
-
- /** Retourne vrai si des listes de favoris existent */
- public boolean isPersonListsExists() {
- return personLists != null && !personLists.getList().isEmpty();
- }
-
- /**
- * Activation de la page
- */
- void onActivate(String id) {
-
- // Si un sondage est fourni (copie de sondage)
- if (id != null && !"".equals(id)) {
-
- // Réinitialisation des variables de session
- // Si l'ancien sondage n'existe pas ou est différent de celui fourni
- if (oldPoll == null || !id.equals(oldPoll.getPollId())) {
- oldPoll = servicePoll.findPollByPollId(id);
- if (oldPoll != null) {
- initWithExistingPoll(oldPoll);
- oldPoll = null;
- oldPollExists = true;
- }
- }
- }
- }
-
- /**
- * Initialisation de l'affichage
- */
- void setupRender() {
- address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
- new AddressBarItem(title, null) };
-
- if (!addChoiceSelected && !uploadExceptionCatched
- && !choicesCreationForm.getHasErrors()) {
- step = PollStep.POLL;
- if (!oldPollExists) {
- oldPoll = null;
- initPoll();
- }
- initPersonLists();
- }
-
- addChoiceSelected = false;
- uploadExceptionCatched = false;
- }
-
- /**
- * Initialisation du sondage.
- */
- private void initPoll() {
-
- // Initialisation du sondage
- poll = new PollDTO();
- if (userExists) {
- poll.setCreatorName(user.getLogin());
- poll.setCreatorEmail(user.getEmail());
- }
-
- // Initialisation des règles de notification
- notificationPreventRule = new PreventRuleDTO("vote", 0, true,
- PreventRuleManager.EMAIL_ACTION);
- reminderPreventRule = new PreventRuleDTO("rappel", 0, false,
- PreventRuleManager.EMAIL_ACTION);
-
- notificationCheckBox = false;
- reminderCheckBox = false;
- choiceNbCheckBox = false;
-
- // Initialisation des choix
- choices = new ArrayList<ChoiceDTO>();
- dateTypeChoices = new ArrayList<DateChoiceUIO>();
- imgTypeChoices = new ArrayList<ImageChoiceUIO>();
- for (int i = 0; i < nbChoices; i++) {
- choices.add(new ChoiceDTO());
- dateTypeChoices.add(new DateChoiceUIO());
- imgTypeChoices.add(new ImageChoiceUIO());
- }
-
- // Initialisation des listes de votants
- votingLists = new ArrayList<VotingListDTO>();
- }
-
- /**
- * Initialisation du sondage à partir d'un sondage existant.
- */
- private void initWithExistingPoll(PollDTO oldPoll) {
-
- // Initialisation du sondage
- poll = PollHelper.getPoll(oldPoll);
-
- // Initialisation du créateur du sondage
-// PollAccountDTO creator = servicePollAccount.findPollAccountById(oldPoll
-// .getCreatorId());
- //poll.setCreatorId(oldPoll.getCreatorId());
- poll.setCreatorName(oldPoll.getCreatorName());
- poll.setCreatorEmail(oldPoll.getCreatorEmail());
-
- // Initialisation des règles de notification
- notificationPreventRule = PollHelper
- .getNotificationPreventRule(oldPoll);
- notificationCheckBox = !"".equals(notificationPreventRule.getScope());
- reminderPreventRule = PollHelper.getReminderPreventRule(oldPoll);
- reminderCheckBox = !"".equals(reminderPreventRule.getScope());
-
- // Initialisation des choix
- choices = PollHelper.getTextChoices(oldPoll);
- dateTypeChoices = PollHelper.getDateChoices(oldPoll);
- imgTypeChoices = PollHelper.getImageChoices(oldPoll);
-
- // Initialisation des listes de votants
- votingLists = PollHelper.getVotingLists(oldPoll);
- }
-
- /**
- * Initialisation de la liste de favoris.
- */
- private void initPersonLists() {
- if (userExists) {
- List<PersonListDTO> _personLists = serviceList
- .findPersonListByUser(user.getId());
- personLists = new GenericSelectModel<PersonListDTO>(_personLists,
- PersonListDTO.class, "name", "id", _propertyAccess);
- }
- }
-}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -243,7 +243,7 @@
choices.add(ChoiceField.getChoiceText());
}
} else {
- for (ChoiceDTO current : getPoll().getChoiceDTOs()) {
+ for (ChoiceDTO current : getPoll().getChoices()) {
choices.add((ChoiceField)current);
}
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -262,7 +262,7 @@
poll.setPublicResults(true);
}
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ for (ChoiceDTO choice : poll.getChoices()) {
choice.setValidate(true);
}
servicePoll.updatePoll(poll);
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -349,7 +349,7 @@
String choiceId = "";
// Récupération du choix correspondant au résultat
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ for (ChoiceDTO choice : poll.getChoices()) {
if (resultName.equals(choice.getName())) {
choiceId = choice.getId();
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -46,9 +46,11 @@
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.util.AbstractMessages;
import org.apache.tapestry5.upload.services.UploadedFile;
import org.chenillekit.tapestry.core.components.DateTimeField;
import org.chorem.pollen.business.PollenBusinessException;
+import org.chorem.pollen.business.PollenBusinessException.PollenExceptionType;
import org.chorem.pollen.business.PollenProperty;
import org.chorem.pollen.business.business.PreventRuleManager;
import org.chorem.pollen.business.dto.ChoiceDTO;
@@ -70,12 +72,14 @@
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.ui.base.ContextLink;
+import org.chorem.pollen.ui.components.Border;
import org.chorem.pollen.ui.components.FeedBack;
import org.chorem.pollen.ui.components.ImageContextLink;
import org.chorem.pollen.ui.components.Pager;
+import org.chorem.pollen.ui.data.AddressBar;
import org.chorem.pollen.ui.data.EvenOdd;
-import org.chorem.pollen.ui.data.AddressBarItem;
import org.chorem.pollen.ui.data.PollAction;
+import org.chorem.pollen.ui.data.PollUri;
import org.chorem.pollen.ui.data.uio.DateChoiceUIO;
import org.chorem.pollen.ui.data.uio.ImageChoiceUIO;
import org.chorem.pollen.ui.utils.FeedUtil;
@@ -101,10 +105,6 @@
@Property
private String title;
- @SuppressWarnings("unused")
- @Property
- private AddressBarItem[] address;
-
/** Paramètres de la page */
private String param;
@@ -138,11 +138,6 @@
@Component(parameters = { "timePicker=true", "timePickerAdjacent=true" })
private DateTimeField dateDTF;
- /** Format des dates */
- @Persist
- @Property
- private DateFormat dateFormat;
-
/** Locale courante */
@Inject
private Locale currentLocale;
@@ -154,13 +149,6 @@
private Messages messages;
/**
- * Sondage pour lequel l'utilisateur vote
- */
- @Property
- @Persist
- private PollDTO poll;
-
- /**
* Vote courant de l'utilisateur
*/
@Property
@@ -191,9 +179,6 @@
@InjectComponent
private Zone pollZone;
- @InjectComponent
- private Zone commentZone;
-
/**
* Objet servant à changer la couleur à chaque ligne de la liste des
* sondages
@@ -237,17 +222,6 @@
@Persist
private ImageChoiceUIO newImageChoice;
- /** Commentaire courant pour l'affichage des commentaires */
- @SuppressWarnings("unused")
- @Property
- @Persist
- private CommentDTO comment;
-
- /** Nouveau commentaire posté */
- @Property
- @Persist
- private CommentDTO newComment;
-
/** Injection des services */
@Inject
private ServicePoll servicePoll;
@@ -292,36 +266,36 @@
@InjectComponent
private FeedBack voteFeedback;
- public String getVoteSizeMessage() {
+ public String getVoteSizeMessage() throws PollenBusinessException {
if (log.isDebugEnabled()) {
log.debug("poll voteDTOs list size : " + getVotes().size());
- log.debug("poll nbVotes : " + poll.getNbVotes());
+ log.debug("poll nbVotes : " + getPoll().getNbVotes());
}
- return messages.format("vote-size", poll.getNbVotes());
+ return messages.format("vote-size", getPoll().getNbVotes());
}
/** Méthode appelée après la soumission du vote. */
@Log
- Object onSuccessFromVoteForm() {
+ Object onSuccessFromVoteForm() throws PollenBusinessException {
if (initPollAccount()) {
List<ChoiceDTO> choiceDTOs = new ArrayList<ChoiceDTO>();
- if (poll.getVoteCounting() == VoteCountingType.NORMAL) {
+ if (getPoll().getVoteCounting() == VoteCountingType.NORMAL) {
int nbChoices = 0;
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ for (ChoiceDTO choice : getPoll().getChoices()) {
if (choice.getValue() == 1) {
nbChoices++;
}
choiceDTOs.add(choice);
}
- if (nbChoices > poll.getMaxChoiceNb()) {
+ if (nbChoices > getPoll().getMaxChoiceNb()) {
voteForm.recordError(messages.format(("tooManyChoices"),
- poll.getMaxChoiceNb()));
+ getPoll().getMaxChoiceNb()));
return pollZone.getBody();
}
- } else if (poll.getVoteCounting() == VoteCountingType.PERCENTAGE) {
+ } else if (getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE) {
int total = 0;
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ for (ChoiceDTO choice : getPoll().getChoices()) {
total = total + choice.getValue();
choiceDTOs.add(choice);
}
@@ -330,21 +304,21 @@
return pollZone.getBody();
}
- } else if (poll.getVoteCounting() == VoteCountingType.CONDORCET) {
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ } else if (getPoll().getVoteCounting() == VoteCountingType.CONDORCET) {
+ for (ChoiceDTO choice : getPoll().getChoices()) {
if (choice.getValue() == 0) {
choice.setValue(100);
}
choiceDTOs.add(choice);
}
- } else if (poll.getVoteCounting() == VoteCountingType.NUMBER) {
+ } else if (getPoll().getVoteCounting() == VoteCountingType.NUMBER) {
String votingId = pollAccount.getVotingId();
if (anonymousVote) {
votingId = "anonymous" + UUID.randomUUID().toString().replaceAll("-", "");
}
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ for (ChoiceDTO choice : getPoll().getChoices()) {
if (!choice.isHidden()) {
choiceDTOs.add(choice);
@@ -365,7 +339,7 @@
}
}
- VoteDTO vote = new VoteDTO(null, poll.getId(), null);
+ VoteDTO vote = new VoteDTO(null, getPoll().getId(), null);
vote.setChoiceDTOs(choiceDTOs);
vote.setWeight(pollAccount.getWeight());
vote.setAnonymous(anonymousVote);
@@ -387,7 +361,8 @@
}
// Mise à jour du sondage et des résultats
- poll = servicePoll.findPollByPollId(poll.getPollId());
+ //poll = servicePoll.findPollByPollId(getPoll().getPollId());
+ poll = null;
countPoll();
addFeedEntry(PollAction.ADDVOTE, pollAccount.getVotingId(),
@@ -403,7 +378,7 @@
return pollZone.getBody();
}
- private void deleteVote(String voteId) {
+ private void deleteVote(String voteId) throws PollenBusinessException {
for (VoteDTO vote : getVotes()) {
if (vote.getId().equals(voteId)) {
@@ -423,11 +398,12 @@
}
/** Méthode appelée lors de la suppression d'un vote. */
- Object onActionFromDeleteVote(String voteId) {
+ Object onActionFromDeleteVote(String voteId) throws PollenBusinessException {
deleteVote(voteId);
// Mise à jour du sondage et des résultats
- poll = servicePoll.findPollByPollId(poll.getPollId());
+// poll = servicePoll.findPollByPollId(poll.getPollId());
+ poll = null;
countPoll();
return pollZone.getBody();
@@ -440,7 +416,7 @@
}
/** Initialisation du pollAccount et contrôle du nom. */
- private boolean initPollAccount() {
+ private boolean initPollAccount() throws PollenBusinessException {
//// Contrôle et définition du votingId
alreadyVoted = false;
@@ -474,14 +450,14 @@
// The calcul of alreadyVoted will be needed for no double votingId
// Carefull, not correct for an anonymous vote
- alreadyVoted = serviceVote.hasAlreadyVoted(votingId, poll);
+ alreadyVoted = serviceVote.hasAlreadyVoted(votingId, getPoll());
// Check for restricted poll
if (!alreadyVoted && !isFreePoll()) {
- if (getAccountUId() != null) {
+ if (uri.getAccountUId() != null) {
// The accountUId must be valid for the poll
PollAccountDTO restrictedAccount =
- servicePoll.getRestrictedAccount(getAccountUId(), poll);
+ servicePoll.getRestrictedAccount(uri.getAccountUId(), getPoll());
if (restrictedAccount != null) {
// PollAccount is replaced by the good account from db
@@ -504,7 +480,7 @@
}
// Génération d'un identifiant de vote (si le sondage est libre et anonyme)
- if (poll.isAnonymous()) {
+ if (getPoll().isAnonymous()) {
anonymousVote = true;
if (isFreePoll()) {
pollAccount.setVotingId("anonymous"
@@ -540,19 +516,12 @@
* @param votingId le votant a rechercher
* @return vrai si la modification du vote est autorisée
*/
- public boolean isModifAllowed(String votingId) {
+ public boolean isModifAllowed(String votingId) throws PollenBusinessException {
boolean modifAllowed = false;
int i = 0;
// parcours des votes pour trouver celui correspondant au votingId
// et contrôle du droit de modification
-
- if (log.isDebugEnabled()) {
- log.debug("Nb votes : " + getVotes().size());
- log.debug("Nb votes in poll : " + poll.getNbVotes());
- }
-
- // FIXME !!!!!! SEEMS TO BE INDEFINITE
while (i < getVotes().size() && !modifAllowed) {
// account : compte associé au vote courant
@@ -588,9 +557,9 @@
/** Ajout d'une entrée dans le flux de syndication */
private void addFeedEntry(PollAction pollAction, String titleStr,
- String contentStr) {
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
- File feedFile = getFeedContext().getFile(poll.getPollId());
+ String contentStr) throws PollenBusinessException {
+ String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollId();
+ File feedFile = getFeedContext().getFile(getPoll().getPollId());
String title = null;
String content = null;
@@ -614,29 +583,29 @@
if (!feedFile.exists()) {
FeedUtil.createFeed(feedFile, "atom_1.0", messages.format(
- "pollFeed_title", poll.getTitle()), siteURL, messages
- .format("pollFeed_desc", poll.getDescription()));
+ "pollFeed_title", getPoll().getTitle()), siteURL, messages
+ .format("pollFeed_desc", getPoll().getDescription()));
}
FeedUtil.feedFeed(feedFile, title, voteURL, content);
}
/** Envoi du mail de notification */
- private void sendMailNotification() {
- String voteURL = siteURL + "poll/VoteFor/" + poll.getPollId();
- String modifURL = siteURL + "poll/Modification/" + poll.getPollId()
- + ":" + MD5.encode(poll.getCreatorId());
+ private void sendMailNotification() throws PollenBusinessException {
+ String voteURL = siteURL + "poll/VoteFor/" + getPoll().getPollId();
+ String modifURL = siteURL + "poll/Modification/" + getPoll().getPollId()
+ + ":" + MD5.encode(getPoll().getCreatorId());
Map<String, String> data = new HashMap<String, String>();
data.put("host", PollenProperty.EMAIL_HOST.getValue());
data.put("port", PollenProperty.EMAIL_PORT.getValue());
data.put("from", PollenProperty.EMAIL_FROM.getValue());
// Mail au créateur
- data.put("to", poll.getCreatorEmail());
- data.put("title", messages.format("voteEmail_subject", poll.getTitle()));
- data.put("msg", messages.format("voteEmail_msg", poll.getTitle(), poll
- .getVoteDTOs().size(), voteURL, modifURL));
+ data.put("to", getPoll().getCreatorEmail());
+ data.put("title", messages.format("voteEmail_subject", getPoll().getTitle()));
+ data.put("msg", messages.format("voteEmail_msg", getPoll().getTitle(), getPoll()
+ .getNbVotes(), voteURL, modifURL));
- for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) {
+ for (PreventRuleDTO rule : getPoll().getPreventRuleDTOs()) {
PreventRuleManager manager = new PreventRuleManager(rule);
manager.execute("vote", getVotes().size(), data);
}
@@ -671,9 +640,9 @@
* @param choice le choix concerné
* @return true si le choix est dans le vote
*/
- public Boolean isChoiceInVote(ChoiceDTO choice) {
+ public Boolean isChoiceInVote(ChoiceDTO choice) throws PollenBusinessException {
if (choice != null) {
- switch (poll.getVoteCounting()) {
+ switch (getPoll().getVoteCounting()) {
case NORMAL:
return choice.getValue() > 0;
case PERCENTAGE:
@@ -732,8 +701,8 @@
* @return vrai si le fichier existe
*/
@Log
- public boolean isFeedFileExisting() {
- File feedFile = getFeedContext().getFile(poll.getPollId());
+ public boolean isFeedFileExisting() throws PollenBusinessException {
+ File feedFile = getFeedContext().getFile(getPoll().getPollId());
if (log.isDebugEnabled()) {
log.debug("feed context path : " + getFeedContext().getContextPath());
log.debug("feed absolute path : " + feedFile.getAbsolutePath());
@@ -760,7 +729,7 @@
*
* @return les résultats
*/
- public String getResultsAsString() {
+ public String getResultsAsString() throws PollenBusinessException {
StringBuffer res = new StringBuffer("");
Iterator<ResultDTO> it = results.iterator();
while (it.hasNext()) {
@@ -785,8 +754,8 @@
*
* @return true si le vote est anonyme
*/
- public boolean isVoteAnonymous() {
- return poll.isAnonymous() || anonymousVote;
+ public boolean isVoteAnonymous() throws PollenBusinessException {
+ return getPoll().isAnonymous() || anonymousVote;
}
/**
@@ -795,42 +764,38 @@
*
* @return true si le vote est anonyme
*/
- public boolean isCurrentVoteAnonymous() {
- return poll.isAnonymous() || vote.isAnonymous();
+ public boolean isCurrentVoteAnonymous() throws PollenBusinessException {
+ return getPoll().isAnonymous() || vote.isAnonymous();
}
/** Retourne vrai si la checkbox anonymousVote doit être affichée. */
- public boolean isAnonymousVoteDisplayed() {
- return poll.isAnonymousVoteAllowed() && !poll.isAnonymous();
+ public boolean isAnonymousVoteDisplayed() throws PollenBusinessException {
+ return getPoll().isAnonymousVoteAllowed() && !getPoll().isAnonymous();
}
/** Retourne l'identifiant du votant du vote courant */
- // FIXME !!!!!! DON'T DO A QUERY FOR THAT
public String getCurrentVotingId() {
-// String id = vote.getPollAccountId();
-// String votingId = servicePollAccount.findPollAccountById(id)
-// .getVotingId();
return vote.getName();
}
/** Validation du champs de saisie du choix (texte). */
- void onValidateFromTextName(String value) throws ValidationException {
+ void onValidateFromTextName(String value) throws ValidationException, PollenBusinessException {
validateNewChoice(value);
}
/** Validation du champs de saisie du choix (date). */
- void onValidateFromDateDTF(Date value) throws ValidationException {
+ void onValidateFromDateDTF(Date value) throws ValidationException, PollenBusinessException {
validateNewChoice(String.valueOf(value.getTime()));
}
/** Validation du champs de saisie du choix (image). */
- void onValidateFromImgFile(UploadedFile value) throws ValidationException {
+ void onValidateFromImgFile(UploadedFile value) throws ValidationException, PollenBusinessException {
validateNewChoice(value.getFileName().replace(' ', '_'));
}
/** Validation du champs de saisie du choix. */
- private void validateNewChoice(String value) throws ValidationException {
- for (ChoiceDTO choice : poll.getChoiceDTOs()) {
+ private void validateNewChoice(String value) throws ValidationException, PollenBusinessException {
+ for (ChoiceDTO choice : getPoll().getChoices()) {
if (value.equals(choice.getName())) {
throw new ValidationException(messages.format("choiceExists",
value));
@@ -839,24 +804,24 @@
}
/** Méthode appelée lors de l'ajout d'un choix. */
- Object onSuccessFromChoiceForm() {
+ Object onSuccessFromChoiceForm() throws PollenBusinessException {
String choiceName = null;
String choiceDesc = null;
if (isTextType()) {
if (newChoice.getName() != null) {
newChoice.setValidate(true);
- newChoice.setPollId(poll.getId());
- poll.getChoiceDTOs().add(newChoice);
+ newChoice.setPollId(getPoll().getId());
+ getPoll().getChoices().add(newChoice);
choiceName = newChoice.getName();
choiceDesc = newChoice.getDescription();
}
} else if (isDateType()) {
if (newDateChoice.getDate() != null) {
newDateChoice.setValidate(true);
- newDateChoice.setPollId(poll.getId());
+ newDateChoice.setPollId(getPoll().getId());
newDateChoice.setName(String.valueOf(newDateChoice.getDate()
.getTime()));
- poll.getChoiceDTOs().add(newDateChoice);
+ getPoll().getChoices().add(newDateChoice);
Date date = new Date(Long.parseLong(newDateChoice.getName()));
choiceName = dateFormat.format(date);
choiceDesc = newDateChoice.getDescription();
@@ -864,10 +829,10 @@
} else if (isImageType()) {
if (newImageChoice.getImg() != null) {
newImageChoice.setValidate(true);
- newImageChoice.setPollId(poll.getId());
+ newImageChoice.setPollId(getPoll().getId());
newImageChoice.setName(newImageChoice.getImg().getFileName()
.replace(' ', '_'));
- poll.getChoiceDTOs().add(newImageChoice);
+ getPoll().getChoices().add(newImageChoice);
//File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
File imgFile = getImgContext().getImageDir(); // dir set in getImgContext()
ImageUtil.saveImage(newImageChoice, imgFile);
@@ -876,82 +841,63 @@
}
}
- servicePoll.updatePoll(poll);
- poll = servicePoll.findPollByPollId(poll.getPollId());
+ servicePoll.updatePoll(getPoll());
+ poll = null;
+ //poll = servicePoll.findPollByPollId(getPoll().getPollId());
addFeedEntry(PollAction.ADDCHOICE, choiceName, choiceDesc);
- newChoice = new ChoiceDTO();
- newDateChoice = new DateChoiceUIO();
- newImageChoice = new ImageChoiceUIO();
+// newChoice = new ChoiceDTO();
+// newDateChoice = new DateChoiceUIO();
+// newImageChoice = new ImageChoiceUIO();
return this;
}
/** Méthode appelée lors de la suppression d'un choix. */
- Object onActionFromDeleteChoice(String choiceId) {
- Iterator<ChoiceDTO> itChoice = poll.getChoiceDTOs().iterator();
+ Object onActionFromDeleteChoice(String choiceId) throws PollenBusinessException {
+ Iterator<ChoiceDTO> itChoice = getPoll().getChoices().iterator();
while (itChoice.hasNext()) {
ChoiceDTO choice = itChoice.next();
if (choiceId.equals(choice.getId())) {
itChoice.remove();
}
}
- servicePoll.updatePoll(poll);
- poll = servicePoll.findPollByPollId(poll.getPollId());
+ servicePoll.updatePoll(getPoll());
+ poll = null;
+// poll = servicePoll.findPollByPollId(poll.getPollId());
return pollZone.getBody();
}
- /** Méthode appelée lors de l'ajout d'un commentaire. */
- Object onSuccessFromCommentForm() {
- //newComment.setPollId(poll.getId());
- newComment.setPostDate(new Date());
- servicePoll.createComment(poll, newComment);
- //serviceComment.createComment(newComment);
- //poll = servicePoll.findPollByPollId(poll.getPollId());
- addFeedEntry(PollAction.ADDCOMMENT, newComment.getAuthor(),
- newComment.getText());
- newComment = new CommentDTO();
- return commentZone.getBody();
- }
+// public boolean isPollNull() {
+// return poll == null;
+// }
- /** Méthode appelée lors de la suppression d'un commentaire. */
- Object onActionFromDeleteComment(String commentId) {
- //serviceComment.deleteComment(commentId);
- //poll = servicePoll.findPollByPollId(poll.getPollId());
- servicePoll.deleteComment(poll, commentId);
- return commentZone.getBody();
- }
-
- public boolean isPollNull() {
- return poll == null;
- }
-
- public boolean isPollChoiceStarted() {
+ public boolean isPollChoiceStarted() throws PollenBusinessException {
Date now = new Date();
- boolean started = poll.getBeginChoiceDate() == null || poll.getBeginChoiceDate().before(now);
- boolean ended = poll.getEndChoiceDate() != null && poll.getEndChoiceDate().before(now);
+ boolean started = getPoll().getBeginChoiceDate() == null || getPoll().getBeginChoiceDate().before(now);
+ boolean ended = getPoll().getEndChoiceDate() != null && getPoll().getEndChoiceDate().before(now);
return started && !ended;
}
- public boolean isPollStarted() {
+ public boolean isPollStarted() throws PollenBusinessException {
Date now = new Date();
- return poll.getBeginDate() == null || poll.getBeginDate().before(now);
+ return getPoll().getBeginDate() == null || getPoll().getBeginDate().before(now);
}
- public boolean isPollFinished() {
+ public boolean isPollFinished() throws PollenBusinessException {
Date now = new Date();
- return poll.getEndDate() != null && poll.getEndDate().before(now);
+ return getPoll().getEndDate() != null && getPoll().getEndDate().before(now);
}
- public boolean isPollChoiceOrVoteStarted() {
+ public boolean isPollChoiceOrVoteStarted() throws PollenBusinessException {
return isPollChoiceStarted() || isPollStarted();
}
- public boolean isPollChoiceRunning() {
- return poll.isChoiceAddAllowed() && isPollChoiceStarted();
+ public boolean isPollChoiceRunning() throws PollenBusinessException {
+ return getPoll().isChoiceAddAllowed() && isPollChoiceStarted();
//&& !isPollStarted();
}
- public boolean isPollRunning() {
- return isPollStarted() && !isPollFinished() && !poll.isClosed();
+ public boolean isPollRunning() throws PollenBusinessException {
+ return isPollStarted() && !isPollFinished() && !getPoll().isClosed();
}
public boolean isDescNull() {
@@ -960,74 +906,61 @@
}
/** Retourne vrai si le champs pollAccount doit apparaître. */
- public boolean isAccountFieldDisplayed() {
- return !poll.isAnonymous() || isRestrictedPoll() || isGroupPoll();
+ public boolean isAccountFieldDisplayed() throws PollenBusinessException {
+ return !getPoll().isAnonymous() || isRestrictedPoll() || isGroupPoll();
}
- public boolean isFreePoll() {
- return poll.getPollType() == PollType.FREE;
+ public boolean isFreePoll() throws PollenBusinessException {
+ return getPoll().getPollType() == PollType.FREE;
}
- public boolean isRestrictedPoll() {
- return poll.getPollType() == PollType.RESTRICTED;
+ public boolean isRestrictedPoll() throws PollenBusinessException {
+ return getPoll().getPollType() == PollType.RESTRICTED;
}
- public boolean isGroupPoll() {
- return poll.getPollType() == PollType.GROUP;
+ public boolean isGroupPoll() throws PollenBusinessException {
+ return getPoll().getPollType() == PollType.GROUP;
}
- public boolean isTextType() {
- return poll.getChoiceType() == ChoiceType.TEXT;
+ public boolean isTextType() throws PollenBusinessException {
+ return getPoll().getChoiceType() == ChoiceType.TEXT;
}
- public boolean isDateType() {
- return poll.getChoiceType() == ChoiceType.DATE;
+ public boolean isDateType() throws PollenBusinessException {
+ return getPoll().getChoiceType() == ChoiceType.DATE;
}
- public boolean isImageType() {
- return poll.getChoiceType() == ChoiceType.IMAGE;
+ public boolean isImageType() throws PollenBusinessException {
+ return getPoll().getChoiceType() == ChoiceType.IMAGE;
}
- public boolean isNormalVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.NORMAL;
+ public boolean isNormalVoteCounting() throws PollenBusinessException {
+ return getPoll().getVoteCounting() == VoteCountingType.NORMAL;
}
- public boolean isPercentageVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.PERCENTAGE;
+ public boolean isPercentageVoteCounting() throws PollenBusinessException {
+ return getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE;
}
- public boolean isCondorcetVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.CONDORCET;
+ public boolean isCondorcetVoteCounting() throws PollenBusinessException {
+ return getPoll().getVoteCounting() == VoteCountingType.CONDORCET;
}
- public boolean isNumberVoteCounting() {
- return poll.getVoteCounting() == VoteCountingType.NUMBER;
+ public boolean isNumberVoteCounting() throws PollenBusinessException {
+ return getPoll().getVoteCounting() == VoteCountingType.NUMBER;
}
/** retourne vrai si l'utilisateur est le créateur du sondage */
- public boolean isCreatorUser() {
- PollAccountDTO creator = servicePollAccount.findPollAccountById(poll
- .getCreatorId());
- if (userExists && user.getId().equals(creator.getUserId())) {
+ public boolean isCreatorUser() throws PollenBusinessException {
+ if (userExists && user.getId().equals(getPoll().getUserId())) {
return true;
}
return false;
}
- /**
- * Récupération du créateur du sondage.
- *
- * @return le nom du créateur du sondage.
- */
- public String getCreatorName() {
- PollAccountDTO pollAccount = servicePollAccount
- .findPollAccountById(poll.getCreatorId());
- return pollAccount.getVotingId();
- }
-
/** Retourne le message d'aide correspondant au type de sondage. */
- public String getHelpMessage() {
- switch (poll.getVoteCounting()) {
+ public String getHelpMessage() throws PollenBusinessException {
+ switch (getPoll().getVoteCounting()) {
case NORMAL:
return messages.get("normalVote-help");
case PERCENTAGE:
@@ -1041,89 +974,152 @@
}
}
- /** Retourne la date correspondant au choix courant */
+ /**
+ * Retourne la date correspondant au choix courant
+ *
+ * @return date
+ */
public Date getChoiceNameAsDate() {
return new Date(Long.valueOf(choiceOfPoll.getName()));
}
- /** Action réalisée lorsqu'on clique sur l'image */
- /*Object onDisplayImage(String choiceId) {
- imageDisplay.setPoll(poll);
- imageDisplay.setChoiceId(choiceId);
- imageDisplay.setPageStyle("Vote");
- return imageDisplay;
- }*/
-
- /** Affichage de "" plutôt que 0 pour le Condorcet */
- /*String onToClientFromCondorcetInput() {
- if (choiceOfVote.getValue() == 0) {
- return "";
- }
- return null;
- }*/
-
- /** Récupération d'un entier plutôt que "" pour le Condorcet */
- /*Object onParseClientFromCondorcetInput(String input) {
- if ("".equals(input)) return 0; //ne fonctionne pas
- return null;
- }*/
-
/** Dépouillement du sondage. Mise à jour des résultats. */
- private void countPoll() {
+ private void countPoll() throws PollenBusinessException {
ResultListDTO resultListDTO = null;
-
- if (isGroupPoll()) {
- resultListDTO = serviceResults.getGroupResults(poll.getPollId());
- } else {
- resultListDTO = serviceResults.getNormalResults(poll.getPollId());
- }
+ if (getPoll().getContinuousResults()) {
- results = resultListDTO.getResultDTOs();
+ if (isGroupPoll()) {
+ resultListDTO = serviceResults.getGroupResults(getPoll().getPollId());
+ } else {
+ resultListDTO = serviceResults.getNormalResults(getPoll().getPollId());
+ }
- if (logger.isDebugEnabled()) {
- for (ResultDTO res : results) {
- logger.debug(res.getName() + ": " + res.getValue()
- + ", (voteCounting=" + res.getVoteCounting()
- + ", byGroup=" + res.isByGroup() + ")");
+ results = resultListDTO.getResultDTOs();
+
+ if (logger.isDebugEnabled()) {
+ for (ResultDTO res : results) {
+ logger.debug(res.getName() + ": " + res.getValue()
+ + ", (voteCounting=" + res.getVoteCounting()
+ + ", byGroup=" + res.isByGroup() + ")");
+ }
}
}
}
+ @Property
+ private PollUri uri;
+
/**
+ * Sondage pour lequel l'utilisateur vote
+ */
+ @Persist
+ private PollDTO poll;
+
+ @Property
+ private boolean pollNull;
+
+ @InjectComponent
+ private Border border;
+
+ /** Format des dates */
+ private DateFormat dateFormat;
+
+ /**
* Méthode appelée au moment de l'activation de la page
*
* @param id l'identifiant du sondage et du votant
*/
- void onActivate(EventContext ec) {
- param = ec.get(String.class, 0);
+ @Log
+ void onActivate(EventContext ec) throws PollenBusinessException {
+ uri = ec.get(PollUri.class, 0);
if (ec.getCount() > 1) {
page = ec.get(Integer.class, 1);
}
+ }
- // Initialisation du sondage
- if (param != null && !"".equals(param)) {
- String pollId = param.split(":", 2)[0];
- poll = servicePoll.findPollByPollId(pollId);
+ /**
+ * Méthode appelée au moment de la désactivation de la page
+ *
+ * @return l'identifiant du sondage et du votant
+ */
+ Object[] onPassivate() {
+ return new Object[]{uri, page};
+ }
+ /**
+ * Initialisation de l'affichage
+ */
+ @Log
+ void setupRender() {
+ try {
+ poll = null;
+ getPoll();
+
+ if (getPoll().isClosed()) {
+ feedback.addInfo(messages.get("pollClosed"));
+ } else if (!isPollStarted()) {
+ feedback.addInfo(messages.get("pollNotStarted"));
+ } else if (isPollFinished()) {
+ feedback.addInfo(messages.get("pollFinished"));
+ }
+ if (isPollChoiceRunning()) {
+ feedback.addInfo(messages.get("pollChoiceRunning"));
+ }
+
+ countPoll();
+ } catch (PollenBusinessException eee) {
+ feedback.addError(messages.get(eee.getMessage()));
+ pollNull = true;
+ }
+ }
+
+ /**
+ * Address bar of the page. Display in Border layout component.
+ *
+ * @return the address bar of the page.
+ */
+ public AddressBar getAddress() {
+// address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
+// new AddressBarItem(title, null) };
+ return new AddressBar().appendCurrent(title);
+ }
+
+ /**
+ * DateFormat used in the page.
+ *
+ * @return the DateFormat needed.
+ */
+ public DateFormat getDateFormat() {
+ if (dateFormat == null) {
+ dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
+ DateFormat.SHORT, currentLocale);
+ }
+ return dateFormat;
+ }
+
+ public PollDTO getPoll() throws PollenBusinessException {
+ if (poll == null) {
+ poll = servicePoll.findPollByPollId(uri.getPollUId());
+
if (poll != null) {
// Identification du votant
- if (getAccountUId() != null) {
+ if (uri.getAccountUId() != null) {
pollAccount = servicePollAccount
- .findPollAccountByAccountId(getAccountUId());
+ .findPollAccountByAccountId(uri.getAccountUId());
pollAccountId = pollAccount.getId();
}
-
+
if (pollAccount == null) {
pollAccount = new PollAccountDTO();
if (userExists) {
if (user.getFirstName() != null && user.getLastName() != null) {
pollAccount.setVotingId(
user.getFirstName() + " " + user.getLastName());
-
+
} else if (user.getFirstName() != null) {
pollAccount.setVotingId(user.getFirstName());
-
+
} else if (user.getLastName() != null) {
pollAccount.setVotingId(user.getLastName());
}
@@ -1134,59 +1130,14 @@
newChoice = new ChoiceDTO();
newDateChoice = new DateChoiceUIO();
newImageChoice = new ImageChoiceUIO();
- newComment = new CommentDTO();
-
- //newComment.setPollId(poll.getId());
+ } else {
+ throw new PollenBusinessException(
+ PollenExceptionType.POLL_NOT_EXIST);
}
}
-
- // Affichage des erreurs
- if (poll == null) {
- feedback.addError(messages.get("pollNotFound"));
- } else {
- if (poll.isClosed()) {
- feedback.addInfo(messages.get("pollClosed"));
- } else if (!isPollStarted()) {
- feedback.addInfo(messages.get("pollNotStarted"));
- } else if (isPollFinished()) {
- feedback.addInfo(messages.get("pollFinished"));
- }
- if (isPollChoiceRunning()) {
- feedback.addInfo(messages.get("pollChoiceRunning"));
- }
- }
+ return poll;
}
- private String accountUId;
-
- public String getAccountUId() {
- if (accountUId == null && param.split(":", 2).length == 2) {
- accountUId = param.split(":", 2)[1];
- }
- return accountUId;
- }
-
- /**
- * Méthode appelée au moment de la désactivation de la page
- *
- * @return l'identifiant du sondage et du votant
- */
- Object[] onPassivate() {
- return new Object[]{param, page};
- }
-
- /**
- * Initialisation de l'affichage
- */
- void setupRender() {
- address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"),
- new AddressBarItem(title, null) };
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
- DateFormat.SHORT, currentLocale);
-
- countPoll();
- }
-
/************** PAGER AND VOTES MANAGMENT *********************************/
@InjectComponent
@@ -1196,6 +1147,9 @@
private Integer page;
+ @Persist
+ private Integer nbVotesPerPage;
+
public int getPage() {
if (page == null) {
page = pager.getFirstPage();
@@ -1214,11 +1168,22 @@
* @return the number of votes to display per page
*/
public int getNbVotesPerPage() {
+ if (nbVotesPerPage == null) {
+ nbVotesPerPage = getPagerRange();
+ }
+ return nbVotesPerPage;
+ }
+
+ public void setNbVotesPerPage(int nbVotesPerPage) {
+ this.nbVotesPerPage = nbVotesPerPage;
+ }
+
+ public int getPagerRange() {
return Integer.parseInt(PollenProperty.NB_VOTES_PER_PAGE.getValue());
}
- public String getNoPagerText() {
- return messages.format("vote-noPagerText", poll.getNbVotes());
+ public String getNoPagerText() throws PollenBusinessException {
+ return messages.format("vote-noPagerText", getPoll().getNbVotes());
}
/**
@@ -1227,15 +1192,80 @@
* loaded depends on current page using pager component.
*
* @return the list of votes to display
+ * @throws PollenBusinessException
*/
- public List<VoteDTO> getVotes() {
+ public List<VoteDTO> getVotes() throws PollenBusinessException {
if (votes == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getVotesByPoll]");
- }
- votes = serviceVote.getVotesByPoll(poll,
+ votes = serviceVote.getVotesByPoll(getPoll(),
pager.getStartIndex(), pager.getEndIndex());
}
return votes;
}
+
+ /************** COMMENTS **************************************************/
+
+ @InjectComponent
+ private Zone commentZone;
+
+ private List<CommentDTO> comments;
+
+ /** Commentaire courant pour l'affichage des commentaires */
+ @SuppressWarnings("unused")
+ @Property
+ @Persist
+ private CommentDTO comment;
+
+ /** Nouveau commentaire posté */
+ private CommentDTO newComment;
+
+ public List<CommentDTO> getComments() throws PollenBusinessException {
+ if (comments == null) {
+ comments = servicePoll.getComments(poll);
+ }
+ return comments;
+ }
+
+ /**
+ * Accessor for newComment property. Instantiate a new comment if needed.
+ *
+ * @return the current newComment.
+ */
+ public CommentDTO getNewComment() {
+ if (newComment == null) {
+ newComment = new CommentDTO();
+ }
+ return newComment;
+ }
+
+ /**
+ * ACTION EVENT :: delete a comment.
+ *
+ * @param commentId id of the comment to delete
+ * @return the commentZone
+ * @throws PollenBusinessException
+ */
+ Object onActionFromDeleteComment(String commentId) throws PollenBusinessException {
+ servicePoll.deleteComment(getPoll(), commentId);
+ return commentZone.getBody();
+ }
+
+ /**
+ * SUCCESS EVENT :: submit form for adding a new comment.
+ *
+ * @return the commentZone
+ * @throws PollenBusinessException
+ */
+ @Log
+ Object onSuccessFromCommentForm() throws PollenBusinessException {
+ if (log.isDebugEnabled()) {
+ log.debug("newComment author : " + getNewComment().getAuthor());
+ log.debug("newComment text : " + getNewComment().getText());
+ }
+ getNewComment().setPostDate(new Date());
+ servicePoll.createComment(getPoll(), getNewComment());
+ addFeedEntry(PollAction.ADDCOMMENT,
+ getNewComment().getAuthor(),
+ getNewComment().getText());
+ return commentZone.getBody();
+ }
}
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -16,13 +16,18 @@
package org.chorem.pollen.ui.services;
+import java.math.BigDecimal;
+import org.chorem.pollen.business.services.SendMail;
import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.ioc.Configuration;
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;
import org.apache.tapestry5.ioc.annotations.InjectService;
+import org.apache.tapestry5.ioc.services.Coercion;
+import org.apache.tapestry5.ioc.services.CoercionTuple;
import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.apache.tapestry5.ioc.services.SymbolProvider;
@@ -36,7 +41,7 @@
import org.chorem.pollen.business.services.ServiceResults;
import org.chorem.pollen.business.services.ServiceUser;
import org.chorem.pollen.business.services.ServiceVote;
-import org.chorem.pollen.ui.utils.SendMail;
+import org.chorem.pollen.ui.data.PollUri;
import org.slf4j.Logger;
/**
@@ -146,6 +151,27 @@
configuration.add("PollenStartup", new PollenManager());
}
+ public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration) {
+ Coercion<String, PollUri> coercion1 = new Coercion<String, PollUri>() {
+
+ @Override
+ public PollUri coerce(String input) {
+ return new PollUri(input);
+ }
+ };
+
+ Coercion<PollUri, String> coercion2 = new Coercion<PollUri, String>() {
+
+ @Override
+ public String coerce(PollUri input) {
+ return input.getUri();
+ }
+ };
+
+ configuration.add(new CoercionTuple<String, PollUri>(String.class, PollUri.class, coercion1));
+ configuration.add(new CoercionTuple<PollUri, String>(PollUri.class, String.class, coercion2));
+ }
+
/**
* This is the BackgroundWorker service definition. It build the service
* giving a Messages object for localization in the service.
@@ -177,12 +203,11 @@
* @param conf
* @return
*/
-// @EagerLoad
-// public SendMail buildSendMail(Configuration conf) {
-// SendMail res = new SendMail(conf);
-// res.start();
-// return res;
-// }
+ @EagerLoad
+ public SendMail buildSendMail() {
+ SendMail res = new SendMail();
+ return res;
+ }
/**
* Make configuration from a Properties file available as symbols.
Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -20,7 +20,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
import org.chorem.pollen.business.PollenContext;
-import org.chorem.pollen.ui.utils.SendMail;
/**
* Service de gestion de l'arrêt du serveur. Ce service exécute une action à la
@@ -33,16 +32,12 @@
private static final Log log = LogFactory.getLog(PollenManager.class);
- protected SendMail sendMail;
-
@Override
public void run() {
if (log.isInfoEnabled()) {
log.info("Start Pollen");
}
PollenContext.start();
- sendMail = new SendMail();
- sendMail.start();
}
@Override
@@ -51,7 +46,6 @@
log.info("Stop Pollen");
}
PollenContext.stop();
- sendMail.stopExec();
}
}
Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/SendMail.java
===================================================================
--- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/SendMail.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/SendMail.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,248 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.ui.utils;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import org.chorem.pollen.business.utils.MailUtil;
-import org.nuiton.util.FileUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.CSVWriter;
-import org.apache.commons.io.IOUtils;
-import org.chorem.pollen.business.PollenProperty;
-
-/**
- * Mass mail management class.
- *
- * This class store email to send in a csv file, and send it (one per second) in
- * a second time.
- * This class can restart to send mail at application restart.
- *
- * For a mass mail sending to start, following files must be present:
- * <ul>
- * <li>xxx.emails : CSV file ("email", "subject", "body")</li>
- * <li>xxx.index : next index to manage ( inited at 0)</li>
- * </ul>
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class SendMail extends Thread {
-
- /** logger. */
- private static final Logger log = LoggerFactory.getLogger(SendMail.class);
-
- public static final String EXTENSION_MAIL = ".mail";
- public static final String EXTENSION_INDEX = ".index";
-
- /** Mail storage directory. */
- protected File mailStorageDirectory;
-
- protected volatile boolean stop;
-
- public SendMail() {
-
- // get email directory in configuration
- // create it if not exists
- String filename = PollenProperty.EMAIL_DIR.getValue();
- mailStorageDirectory = new File(filename);
- if (!mailStorageDirectory.exists()) {
- if (mailStorageDirectory.mkdirs()) {
- if (log.isDebugEnabled()) {
- log.debug("Email storage directory created in : " + mailStorageDirectory.getAbsolutePath());
- }
- }
- }
- }
-
- public synchronized void stopExec() {
- stop = true;
- }
-
- /*
- * @see java.lang.Runnable#run()
- */
- @Override
- public void run() {
-
- // try to find existing files
- while (!stop) {
- try {
- sendAllMails();
-
- // bloque thread until next notify
- sleep();
- }
- catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during SendMail main loop", ex);
- }
- }
- }
- }
-
- protected synchronized void sleep() throws InterruptedException {
- wait();
- }
-
- public synchronized void wakeUp() {
- notifyAll();
- }
-
- /**
- * Look for all xx.index file, and restart mail sending on
- * non ending mass mail sending.
- *
- * After execution, delete mail and index file.
- * @throws IOException
- */
- protected void sendAllMails() throws IOException {
-
- // don't do for, allways take the first found
- // a new one can be created when managing one other
- List<File> indexFiles = null;
- do {
-
- // filter is java valid : .*\\.index
- indexFiles = FileUtil.find(mailStorageDirectory, ".*\\" + EXTENSION_INDEX, false);
-
- if (!indexFiles.isEmpty()) {
- File indexFile = indexFiles.get(0);
- // convert index content to int
- String indexContent = FileUtils.readFileToString(indexFile, "UTF-8");
- int index = Integer.parseInt(indexContent);
-
- // get mail content file
- File mailFile = new File(indexFile.getAbsolutePath().replaceAll(EXTENSION_INDEX + "$", EXTENSION_MAIL));
-
- if (log.isDebugEnabled()) {
- log.debug("Managing mail file : " + mailFile + " (from index " + indexContent + ")");
- }
-
- Reader indexFileReader = new BufferedReader(new FileReader(mailFile));
- CSVReader cvsReader = new CSVReader(indexFileReader);
-
- int currentIndex = 0;
- String[] currentLine = cvsReader.readNext();
- while (currentLine != null) {
- String receiver = currentLine[0];
- String subject = currentLine[1];
- String body = currentLine[2];
-
- // index contains next index to treat so == is ok
- if (currentIndex >= index) {
- String host = PollenProperty.EMAIL_HOST.getValue();
- int port = Integer.parseInt(
- PollenProperty.EMAIL_PORT.getValue());
- String from = PollenProperty.EMAIL_FROM.getValue();
- MailUtil.sendMail(host, port, from,
- receiver, subject, body);
-
- // index contains next index to treat
- FileUtils.writeStringToFile(indexFile, String.valueOf(currentIndex + 1));
-
- // wait 2 secondes between each mail to not
- // load smtp server
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't wait between mail", ex);
- }
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("Mail to " + receiver + " already sent in a previous execution, skip.");
- }
- }
-
- currentIndex++;
- currentLine = cvsReader.readNext();
- }
-
- // delete woth index and mail file
- mailFile.delete();
- indexFile.delete();
- }
- else {
- if (log.isInfoEnabled()) {
- log.info("No more index mail index file found, go to sleep a while :)");
- }
- }
- } while (!indexFiles.isEmpty());
- }
-
- /**
- * Prepare mail list.
- *
- * TODO : improve configuration reading
- *
- * @param id
- * @param mailData
- * @throws IOException
- */
- public void prepareMails(String id, List<Map<String, String>> mailData) throws IOException {
-
- Writer fileWriter = null;
- CSVWriter cvsWriter = null;
- try {
-
- // write CSV datas
- File emailFile = new File(mailStorageDirectory, id + EXTENSION_MAIL);
- fileWriter = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(emailFile)));
- cvsWriter = new CSVWriter(fileWriter);
-
- for (Map<String, String> singleMailData : mailData) {
- String[] nextLine = new String[] {
- singleMailData.get("receiver"),
- singleMailData.get("subject"),
- singleMailData.get("body")
- };
- cvsWriter.writeNext(nextLine);
- }
-
- // write index (default to 0)
- File indexFile = new File(mailStorageDirectory, id + EXTENSION_INDEX);
- FileUtil.writeString(indexFile, "0");
- }
- finally {
- if (cvsWriter != null) {
- cvsWriter.close();
- }
- IOUtils.closeQuietly(fileWriter);
- }
-
- }
-}
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_en.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_en.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,3 +1,5 @@
-page=Page %d
+page=Page %d/%d
go-to=Go to page %d
-rows-title=Rows %d - %d over %d
\ No newline at end of file
+rows-title=Rows %d - %d over %d
+showPerPage=Show on each page:
+change-nbrows=Change to %d rows per page
\ No newline at end of file
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_fr.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/Pager_fr.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,3 +1,5 @@
-page=Page %d
+page=Page %d/%d
go-to=Aller \u00E0 la page %d
rows-title=Lignes %d - %d sur %d
+showPerPage=Afficher par page :
+change-nbrows=Afficher %d lignes par page
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_en.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -19,8 +19,8 @@
pollAccountName-required-message=You must provide your name.
anonymousVote-label=Anonymous vote
submitVote=Vote
-vote-success=Your vote has been correctly saved.
-vote-noPagerText=%d existing votes.
+vote-success=Your vote has been correctly saved
+vote-noPagerText=%d existing votes
#choices
addChoice=Adding a choice
@@ -49,7 +49,7 @@
submitComment=Add a comment
#messages
-pollNotFound=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
+#pollNotFound=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field.
anonymousForbidden=Anonymous vote is forbidden for this poll. Enter a name.
restrictedListsForbidden=The poll is restricted and you are not allowed to vote. Check if you have correctly used the link sent to you by email.
alreadyVoted=Someone has already used the name %s to vote.
Modified: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties
===================================================================
--- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/poll/VoteForPoll_fr.properties 2010-03-19 15:05:04 UTC (rev 2951)
@@ -20,7 +20,7 @@
anonymousVote-label=Vote anonyme
submitVote=Voter
vote-success=Votre vote a bien \u00E9t\u00E9 enregistr\u00E9
-vote-noPagerText=%d votes existants.
+vote-noPagerText=%d votes existants
#choices
addChoice=Ajout d'un choix
@@ -49,7 +49,7 @@
submitComment=Ajouter un commentaire
#messages
-pollNotFound=Il n'y a pas de sondage \u00E0 cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le compl\u00E8tement dans le champ d'adresse de votre navigateur.
+#pollNotFound=Il n'y a pas de sondage \u00E0 cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le compl\u00E8tement dans le champ d'adresse de votre navigateur.
anonymousForbidden=Le vote anonyme est interdit pour ce sondage. Saisissez un nom.
restrictedListsForbidden=Le sondage est restreint et vous n'\u00EAtes pas autoris\u00E9 \u00E0 voter. V\u00E9rifiez que vous avez bien utiliser le lien qui vous a \u00E9t\u00E9 envoy\u00E9.
alreadyVoted=Une personne a d\u00E9j\u00E0 vot\u00E9 sous le nom %s.
Added: trunk/pollen-ui/src/main/webapp/img/1leftarrow.png
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui/src/main/webapp/img/1leftarrow.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/pollen-ui/src/main/webapp/img/1rightarrow.png
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui/src/main/webapp/img/1rightarrow.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/pollen-ui/src/main/webapp/img/2leftarrow.png
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui/src/main/webapp/img/2leftarrow.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/pollen-ui/src/main/webapp/img/2rightarrow.png
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui/src/main/webapp/img/2rightarrow.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,5 +1,5 @@
-<t:border t:address="address" t:pageLogo="literal:Vote" t:feedFilename="${poll.pollId}"
+<t:border t:address="address.items" t:pageLogo="literal:Vote" t:feedFilename="prop:uri.pollUId"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<t:feedback t:id="feedback"/>
@@ -8,7 +8,6 @@
<!-- Informations sur le sondage -->
-
<div id="pollTop">
${poll.description}
<fieldset>
@@ -26,7 +25,7 @@
</t:FileLink>
</t:if>
</div>
- <label>${message:creator-label}</label> ${creatorName}
+ <label>${message:creator-label}</label> ${poll.creatorName}
<br/>
<label>${message:beginDate-label}</label>
<t:output value="poll.beginDate" format="dateFormat"/>
@@ -51,7 +50,7 @@
<t:feedback t:id="voteFeedback"/>
<p:else>
<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"
- t:currentPage="page" t:noPagerText="prop:noPagerText"/>
+ t:currentPage="page" t:noPagerText="prop:noPagerText" t:range="pagerRange"/>
</p:else>
</t:if>
<t:form t:id="voteForm" t:zone="pollZone">
@@ -65,7 +64,7 @@
</p:else>
</t:if>
<t:if test="textType">
- <t:loop t:source="poll.choiceDTOs" t:value="choiceOfPoll" volatile="true">
+ <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
<t:if test="!isChoiceHidden()">
<th>
<t:unless test="isDescNull()">
@@ -88,26 +87,26 @@
</t:loop>
</t:if>
<t:if test="dateType">
- <t:loop t:source="poll.choiceDTOs" t:value="choiceOfPoll" volatile="true">
- <t:if test="!isChoiceHidden()">
- <t:unless test="isDescNull()">
- <th class="desc">
- <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind">
- <t:output value="choiceNameAsDate" format="dateFormat"/>
- </span>
- </th>
- <p:else>
- <th>
- <t:output value="choiceNameAsDate" format="dateFormat"/>
- </th>
- </p:else>
- </t:unless>
- </t:if>
+ <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
+ <t:unless test="choiceHidden">
+ <t:unless test="isDescNull()">
+ <th class="desc">
+ <span t:type="ck/Tooltip" t:value="choiceOfPoll.description" t:effect="blind">
+ <t:output value="choiceNameAsDate" format="dateFormat"/>
+ </span>
+ </th>
+ <p:else>
+ <th>
+ <t:output value="choiceNameAsDate" format="dateFormat"/>
+ </th>
+ </p:else>
+ </t:unless>
+ </t:unless>
</t:loop>
</t:if>
<t:if test="imageType">
- <t:loop t:source="poll.choiceDTOs" t:value="choiceOfPoll" volatile="true">
+ <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
<t:if test="!isChoiceHidden()">
<t:unless test="isDescNull()">
<th class="desc">
@@ -137,7 +136,7 @@
<th></th>
</p:else>
</t:if>
- <t:loop t:source="poll.choiceDTOs" t:value="choiceOfVote" volatile="true">
+ <t:loop t:source="poll.choices" t:value="choiceOfVote" volatile="true">
<t:if test="!choiceOfVote.hidden">
<th>
<t:if test="isNormalVoteCounting()">
@@ -184,7 +183,7 @@
</t:if>
</t:unless>
</td>
- <t:loop t:source="poll.choiceDTOs" t:value="choiceOfPoll" volatile="true">
+ <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
<t:unless t:test="choiceHidden">
${setCurrentVoteChoice()}
<t:if t:test="poll.anonymous">
@@ -234,7 +233,7 @@
<td>
<t:PageLink t:page="poll/results" t:context="${poll.pollId}">${message:results}</t:PageLink>
</td>
- <t:loop t:source="poll.choiceDTOs" t:value="choiceOfPoll" volatile="true">
+ <t:loop t:source="poll.choices" t:value="choiceOfPoll" volatile="true">
<t:if test="!isChoiceHidden()">
<td class="result">${currentChoiceResult}</td>
</t:if>
@@ -304,7 +303,7 @@
<h3>${message:comments}</h3>
<t:zone t:id="commentZone" show="show" update="show">
<div id="commentsDiv">
- <div t:type="loop" t:source="poll.comments" t:value="comment" class="${evenodd.next}">
+ <div t:type="loop" t:source="comments" t:value="comment" class="${evenodd.next}">
<t:if test="creatorUser">
<span class="cmd">
<t:actionlink t:id="deleteComment" context="comment.id" t:zone="commentZone">
Deleted: trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/SendMailTest.java
===================================================================
--- trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/SendMailTest.java 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/SendMailTest.java 2010-03-19 15:05:04 UTC (rev 2951)
@@ -1,102 +0,0 @@
-/* *##% Pollen
- * Copyright (C) 2010 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
-
-package org.chorem.pollen.ui.utils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.chorem.pollen.business.PollenContext;
-import org.chorem.pollen.business.PollenProperty;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * Class for send mail storage class.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-@Ignore
-public class SendMailTest {
-
- protected static SendMail sendMail;
-
- @BeforeClass
- public static void init() throws InterruptedException {
-
- ApplicationConfig config = new ApplicationConfig();
- config.setOption(PollenProperty.EMAIL_DIR.getKey(), "target" + File.separator + "massmail");
- config.setOption(PollenProperty.EMAIL_HOST.getKey(), "smtp");
- config.setOption(PollenProperty.EMAIL_PORT.getKey(), "25");
- config.setOption(PollenProperty.EMAIL_FROM.getKey(), "pollenreminder(a)codelutin.com");
-
- PollenContext.loadConfiguration(config);
-
- sendMail = new SendMail();
- sendMail.start();
- Thread.sleep(3000);
- }
-
- /**
- * Test to add mail and send mail.
- *
- * WARNING : This test really send mail, don't set it automatic.
- *
- * @throws IOException
- * @throws InterruptedException
- */
- @Test
- public void testAddMail() throws IOException, InterruptedException {
- List<Map<String, String>> mailList = new ArrayList<Map<String,String>>();
-
- Map<String, String> mailMap = new HashMap<String, String>();
- mailMap.put("receiver", "chatellier+test(a)codelutin.com");
- mailMap.put("subject", "Test 18:00");
- mailMap.put("body", "Test body");
-
- Map<String, String> mailMap2 = new HashMap<String, String>();
- mailMap2.put("receiver", "chorlet+test(a)codelutin.com");
- mailMap2.put("subject", "CR, CR CR !!! 18:00");
- mailMap2.put("body", "Des cr, encore des \"CRs\" !!!");
-
- mailList.add(mailMap);
- mailList.add(mailMap2);
-
- sendMail.prepareMails("test", mailList);
-
- String emailDir = PollenProperty.EMAIL_DIR.getValue();
-
- Assert.assertTrue(new File(emailDir, "test.mail").exists());
- Assert.assertTrue(new File(emailDir, "test.index").exists());
- sendMail.wakeUp();
-
- // TODO , en 5 secondes, il aura le temps d'envoyer 2 mails ?
- Thread.sleep(5000);
- Assert.assertFalse(new File(emailDir, "test.mail").exists());
- Assert.assertFalse(new File(emailDir, "test.index").exists());
- }
-}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-19 10:17:45 UTC (rev 2950)
+++ trunk/pom.xml 2010-03-19 15:05:04 UTC (rev 2951)
@@ -41,6 +41,11 @@
<artifactId>commons-email</artifactId>
<version>1.2</version>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
<!-- <dependency>
<groupId>org.chorem</groupId>
<artifactId>chorem-commons</artifactId>
1
0
r2950 - in branches/pollen-1.2.5-1.2.x/pollen-ui/src: main/java/org/chorem/pollen/ui/pages/user main/java/org/chorem/pollen/ui/utils main/resources/org/chorem/pollen/ui/pages/user test/java/org/chorem/pollen/ui/utils
by echatellier@users.chorem.org 19 Mar '10
by echatellier@users.chorem.org 19 Mar '10
19 Mar '10
Author: echatellier
Date: 2010-03-19 11:17:45 +0100 (Fri, 19 Mar 2010)
New Revision: 2950
Log:
#147 : CSV import fail on content type check
Added:
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVParseException.java
Modified:
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_en.properties
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties
branches/pollen-1.2.5-1.2.x/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-03-16 10:22:18 UTC (rev 2949)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-03-19 10:17:45 UTC (rev 2950)
@@ -46,7 +46,9 @@
import org.chorem.pollen.ui.data.EvenOdd;
import org.chorem.pollen.ui.data.Lien;
import org.chorem.pollen.ui.utils.CSVAccountUtil;
+import org.chorem.pollen.ui.utils.CSVParseException;
import org.chorem.pollen.ui.utils.LDAPAccountUtil;
+import org.slf4j.Logger;
/**
* Classe de la page d'affichage des listes de votants favorites de
@@ -59,6 +61,9 @@
@IncludeStylesheet("context:css/lists.css")
public class UserLists {
+ @Inject
+ private Logger log;
+
/**
* Objet de session représentant l'utilisateur identifié.
*/
@@ -196,19 +201,36 @@
// Import CVS des comptes
if (accountsFile != null) {
- if (!accountsFile.getContentType().equals("text/csv")) {
+ /*
+ Ce test n'est pas sur, c'est à l'appreciation du client, par
+ exemple, chromium envoi 'application/octet-stream'
+
+ if (!"text/csv".equals(accountsFile.getContentType())) {
createListForm.recordError(messages.format("invalidCsv",
accountsFile.getFileName()));
+ if (log.isWarnEnabled()) {
+ log.warn("Uploaded csv file content type : " + accountsFile.getContentType());
+ }
return this;
+ }*/
+ try {
+ List<PollAccountDTO> accounts = CSVAccountUtil
+ .importList(accountsFile);
+ if (accounts.size() == 0) {
+ createListForm.recordError(messages.format("noAccountCsv",
+ accountsFile.getFileName()));
+ return this;
+ }
+ newList.getPollAccountDTOs().addAll(accounts);
}
- List<PollAccountDTO> accounts = CSVAccountUtil
- .importList(accountsFile);
- if (accounts.size() == 0) {
- createListForm.recordError(messages.format("noAccountCsv",
+ catch (CSVParseException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't import uploaded file", ex);
+ }
+ createListForm.recordError(messages.format("invalidCsv",
accountsFile.getFileName()));
return this;
}
- newList.getPollAccountDTOs().addAll(accounts);
}
// Import LDAP des comptes
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java 2010-03-16 10:22:18 UTC (rev 2949)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java 2010-03-19 10:17:45 UTC (rev 2950)
@@ -18,9 +18,11 @@
import java.io.InputStreamReader;
import java.io.Reader;
+import java.text.ParseException;
import java.util.Iterator;
import java.util.List;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry5.upload.services.UploadedFile;
@@ -47,33 +49,39 @@
*
* @param reader which contains the input stream
* @return the new PollAccountDTO list from results imported
+ *
+ * @throws CSVParseException if file can't be read (not csv file)
*/
- public static List<PollAccountDTO> importList(Reader reader) {
+ public static List<PollAccountDTO> importList(Reader reader) throws CSVParseException {
List<PollAccountDTO> accounts = null;
- // Définition de la stratégie de mapping
- ColumnPositionMappingStrategy<PollAccountDTO> strat =
- new ColumnPositionMappingStrategy<PollAccountDTO>();
- String[] columns = new String[] { "votingId", "email", "weight" };
- strat.setType(PollAccountDTO.class);
- strat.setColumnMapping(columns);
-
- // Parsing du fichier CSV
- CsvToBean<PollAccountDTO> csv = new CsvToBean<PollAccountDTO>();
- accounts = csv.parse(strat, reader);
-
- // Suppression des comptes null
- Iterator<PollAccountDTO> it = accounts.iterator();
- while (it.hasNext()) {
- if ("".equals(it.next().getVotingId())) {
- it.remove();
+ try {
+ // Définition de la stratégie de mapping
+ ColumnPositionMappingStrategy<PollAccountDTO> strat =
+ new ColumnPositionMappingStrategy<PollAccountDTO>();
+ String[] columns = new String[] { "votingId", "email", "weight" };
+ strat.setType(PollAccountDTO.class);
+ strat.setColumnMapping(columns);
+
+ // Parsing du fichier CSV
+ CsvToBean<PollAccountDTO> csv = new CsvToBean<PollAccountDTO>();
+ accounts = csv.parse(strat, reader);
+
+ // Suppression des comptes null
+ Iterator<PollAccountDTO> it = accounts.iterator();
+ while (it.hasNext()) {
+ if ("".equals(it.next().getVotingId())) {
+ it.remove();
+ }
}
+
+ if (log.isInfoEnabled()) {
+ log.info(accounts.size() + " comptes importés.");
+ }
+ } catch (Exception ex) {
+ throw new CSVParseException("Error during csv import", ex);
}
- if (log.isInfoEnabled()) {
- log.info(accounts.size() + " comptes importés.");
- }
-
return accounts;
}
@@ -83,14 +91,25 @@
* @param file le fichier CSV
* @return a PollAccountDTO list
* @see #importList(java.io.Reader)
+ *
+ * @throws CSVParseException if file can't be read (not csv file)
*/
- public static List<PollAccountDTO> importList(UploadedFile file) {
+ public static List<PollAccountDTO> importList(UploadedFile file) throws CSVParseException {
if (log.isInfoEnabled()) {
log.info("Import du fichier " + file.getFileName() + " ("
+ file.getContentType() + ")...");
}
- InputStreamReader reader = new InputStreamReader(file.getStream());
- return importList(reader);
+ // make sure that reader is closed after parse
+ List<PollAccountDTO> result = null;
+ InputStreamReader reader = null;
+ try {
+ reader = new InputStreamReader(file.getStream());
+ result = importList(reader);
+ }
+ finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return result;
}
}
Added: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVParseException.java
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVParseException.java (rev 0)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVParseException.java 2010-03-19 10:17:45 UTC (rev 2950)
@@ -0,0 +1,43 @@
+/* *##% Pollen
+ * Copyright (C) 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/
+
+package org.chorem.pollen.ui.utils;
+
+/**
+ * CVS excpetion thrown during bad file parsing.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class CSVParseException extends Exception {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1717187553275691080L;
+
+ /**
+ * Constructor with message and cause.
+ *
+ * @param message message
+ * @param cause cause
+ */
+ public CSVParseException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Property changes on: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVParseException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_en.properties
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_en.properties 2010-03-16 10:22:18 UTC (rev 2949)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_en.properties 2010-03-19 10:17:45 UTC (rev 2950)
@@ -1,7 +1,7 @@
title=Your voting lists
accountExists=%s already exists in this list.
listExists=%s list already exists.
-invalidCsv=%s is not a CSV file.
+invalidCsv=%s is not a valid CSV file !
noAccountCsv=%s file contains no valid entry.
noAccountLdap=%s URL can not obtain valid entries.
noUser=You must be logged to access to your polls.\n Please fill the form below.
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties 2010-03-16 10:22:18 UTC (rev 2949)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/resources/org/chorem/pollen/ui/pages/user/UserLists_fr.properties 2010-03-19 10:17:45 UTC (rev 2950)
@@ -1,7 +1,7 @@
title=Vos listes de votants
accountExists=L'identifiant de vote %s existe d\u00E9j\u00E0 dans cette liste.
listExists=La liste %s existe d\u00E9j\u00E0.
-invalidCsv=Le fichier %s n'est pas un fichier CSV.
+invalidCsv=Le fichier %s n'est pas un fichier CSV valide !
noAccountCsv=Le fichier %s ne contient aucune entr\u00E9e valide.
noAccountLdap=L'URL %s ne permet pas d'obtenir d'entr\u00E9es valides.
noUser=Vous devez \u00EAtre identifi\u00E9 pour pouvoir acc\u00E9der \u00E0 vos listes de votants.\n Veuillez remplir le formulaire ci-dessous.
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java 2010-03-16 10:22:18 UTC (rev 2949)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java 2010-03-19 10:17:45 UTC (rev 2950)
@@ -39,9 +39,10 @@
/**
* Test of importList method, of class CSVAccountUtil.
+ * @throws CSVParseException
*/
@Test
- public void testImportList_Reader() {
+ public void testImportList_Reader() throws CSVParseException {
System.out.println("importList");
InputStream input = getClass().getResourceAsStream("/import.csv");
1
0
r2949 - in branches/pollen-1.2.5-1.2.x/pollen-ui/src/main: java/org/chorem/pollen/ui/pages/poll webapp/poll
by echatellier@users.chorem.org 16 Mar '10
by echatellier@users.chorem.org 16 Mar '10
16 Mar '10
Author: echatellier
Date: 2010-03-16 11:22:18 +0100 (Tue, 16 Mar 2010)
New Revision: 2949
Log:
Fix poll description format.
Fix line break in chenillekit tooltips.
Modified:
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-16 08:59:17 UTC (rev 2948)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-16 10:22:18 UTC (rev 2949)
@@ -27,6 +27,8 @@
import java.util.Map;
import java.util.UUID;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.ValidationException;
@@ -1244,4 +1246,24 @@
}
return votes;
}
+
+ /**
+ * This method is used in tapestry template to escape line break string.
+ *
+ * Used for chenillekit tooltip for example.
+ *
+ * @param nonEscapedString non escaped string
+ * @return html escaped string
+ */
+ public String escapeLineBreak(String nonEscapedString) {
+
+ if (nonEscapedString == null) {
+ return null;
+ }
+
+ String localStr = nonEscapedString.replaceAll("\n", "<br />");
+ localStr = localStr.replaceAll("\r", "");
+
+ return localStr;
+ }
}
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-16 08:59:17 UTC (rev 2948)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-16 10:22:18 UTC (rev 2949)
@@ -10,7 +10,7 @@
<!-- Informations sur le sondage -->
<div id="pollTop">
- ${poll.description}
+ <div style="white-space:pre-wrap; text-align: start;">${poll.description}</div>
<fieldset>
<legend>${message:about}</legend>
<div style="float: right">
@@ -69,7 +69,7 @@
<t:if test="!isChoiceHidden()">
<th>
<t:unless test="isDescNull()">
- <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind">
+ <span t:type="ck/Tooltip" title="${message:description}" value="${escapeLineBreak(choiceOfPoll.description)}" effect="blind">
<span class="desc">${choiceOfPoll.name}</span>
</span>
<p:else>
@@ -92,7 +92,7 @@
<t:if test="!isChoiceHidden()">
<t:unless test="isDescNull()">
<th class="desc">
- <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind">
+ <span t:type="ck/Tooltip" title="${message:description}" value="${escapeLineBreak(choiceOfPoll.description)}" effect="blind">
<t:output value="choiceNameAsDate" format="dateFormat"/>
</span>
</th>
@@ -111,7 +111,7 @@
<t:if test="!isChoiceHidden()">
<t:unless test="isDescNull()">
<th class="desc">
- <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind">
+ <span t:type="ck/Tooltip" title="${message:description}" value="${escapeLineBreak(choiceOfPoll.description)}" effect="blind">
<t:image t:src="choiceOfPoll.name" alt="choiceOfPoll.description" t:dir="poll.pollId"/>
</span>
</th>
1
0
r2948 - in branches/pollen-1.2.5-1.2.x: . pollen-business pollen-ui pollen-votecounting
by echatellier@users.chorem.org 16 Mar '10
by echatellier@users.chorem.org 16 Mar '10
16 Mar '10
Author: echatellier
Date: 2010-03-16 09:59:17 +0100 (Tue, 16 Mar 2010)
New Revision: 2948
Log:
Prepare next snapshot version
Modified:
branches/pollen-1.2.5-1.2.x/pollen-business/pom.xml
branches/pollen-1.2.5-1.2.x/pollen-ui/pom.xml
branches/pollen-1.2.5-1.2.x/pollen-votecounting/pom.xml
branches/pollen-1.2.5-1.2.x/pom.xml
Modified: branches/pollen-1.2.5-1.2.x/pollen-business/pom.xml
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-business/pom.xml 2010-03-16 08:53:19 UTC (rev 2947)
+++ branches/pollen-1.2.5-1.2.x/pollen-business/pom.xml 2010-03-16 08:59:17 UTC (rev 2948)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.2.5</version>
+ <version>1.2.6-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/pom.xml
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-ui/pom.xml 2010-03-16 08:53:19 UTC (rev 2947)
+++ branches/pollen-1.2.5-1.2.x/pollen-ui/pom.xml 2010-03-16 08:59:17 UTC (rev 2948)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.2.5</version>
+ <version>1.2.6-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: branches/pollen-1.2.5-1.2.x/pollen-votecounting/pom.xml
===================================================================
--- branches/pollen-1.2.5-1.2.x/pollen-votecounting/pom.xml 2010-03-16 08:53:19 UTC (rev 2947)
+++ branches/pollen-1.2.5-1.2.x/pollen-votecounting/pom.xml 2010-03-16 08:59:17 UTC (rev 2948)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.2.5</version>
+ <version>1.2.6-SNAPSHOT</version>
</parent>
<groupId>org.chorem.pollen</groupId>
Modified: branches/pollen-1.2.5-1.2.x/pom.xml
===================================================================
--- branches/pollen-1.2.5-1.2.x/pom.xml 2010-03-16 08:53:19 UTC (rev 2947)
+++ branches/pollen-1.2.5-1.2.x/pom.xml 2010-03-16 08:59:17 UTC (rev 2948)
@@ -15,7 +15,7 @@
<groupId>org.chorem</groupId>
<artifactId>pollen</artifactId>
- <version>1.2.5</version>
+ <version>1.2.6-SNAPSHOT</version>
<modules>
<module>pollen-ui</module>
@@ -345,9 +345,9 @@
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:http://svn.chorem.org/svn/pollen/tags/pollen-1.2.5</connection>
- <developerConnection>scm:svn:http://svn.chorem.org/svn/pollen/tags/pollen-1.2.5</developerConnection>
- <url>http://www.chorem.org/repositories/browse/pollen/tags/pollen-1.2.5</url>
+ <connection>scm:svn:http://svn.chorem.org/svn/pollen/branches/pollen-1.2.5-1.2.x</connection>
+ <developerConnection>scm:svn:http://svn.chorem.org/svn/pollen/branches/pollen-1.2.5-1.2.x</developerConnection>
+ <url>http://www.chorem.org/repositories/browse/pollen/branches/pollen-1.2.5-1.2.x</url>
</scm>
<repositories>
1
0
Author: echatellier
Date: 2010-03-16 09:53:19 +0100 (Tue, 16 Mar 2010)
New Revision: 2947
Log:
Create maintenance branche from 1.2.5
Added:
branches/pollen-1.2.5-1.2.x/
Property changes on: branches/pollen-1.2.5-1.2.x
___________________________________________________________________
Added: svn:ignore
+ target
nbactions.xml
.settings
.classpath
.project
*.ipr
*.iws
*.iml
Added: svn:mergeinfo
+
1
0
Author: tchemit
Date: 2010-03-15 23:25:29 +0100 (Mon, 15 Mar 2010)
New Revision: 2946
Log:
final bundle are now generated and should not be stored in vcs
Modified:
trunk/pollen-ui/src/main/webapp/WEB-INF/
Property changes on: trunk/pollen-ui/src/main/webapp/WEB-INF
___________________________________________________________________
Added: svn:ignore
+ app_fr.properties
app_en.properties
1
0