r2958 - in trunk: pollen-business/src/main/java/org/chorem/pollen pollen-business/src/main/java/org/chorem/pollen/business pollen-business/src/main/java/org/chorem/pollen/entity pollen-business/src/main/java/org/chorem/pollen/mail pollen-business/src/main/java/org/chorem/pollen/service pollen-business/src/main/resources/i18n pollen-business/src/main/xmi pollen-ui pollen-ui/src/main/java/org/chorem/pollen/ui/base pollen-ui/src/main/java/org/chorem/pollen/ui/components pollen-ui/src/main/java
Author: fdesbois Date: 2010-03-26 15:06:00 +0100 (Fri, 26 Mar 2010) New Revision: 2958 Log: Refactor ui module to use new model v2 (only for build) Added: trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/mail/ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorker.java trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/mail/MailUtil.java trunk/pollen-business/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java Removed: 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-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/data/uio/DateChoiceUIO.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/ImageChoiceUIO.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/PollModification.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorker.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/utils/ImageUtil.java trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/PropertiesLoaderTest.java Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/PollenProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties trunk/pollen-business/src/main/xmi/pollen.zargo trunk/pollen-ui/pom.xml 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/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/FileLink.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.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/admin/PollsAdmin.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/CloseValidation.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/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/PollForm.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/Account.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/pages/user/UserLists.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.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/PropertiesFileSymbolProvider.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java 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 Added: trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,59 @@ +/* *##% 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; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Classe utilitaire permettant d'encoder des chaîne en MD5. + * + * @version $Id$ + */ +public class MD5 { + + /** + * Encode la chaine passé en paramètre avec l’algorithme MD5 + * + * @param key : la chaine à encoder + * @return la valeur (string) hexadécimale sur 32 bits + */ + public static String encode(String key) { + + byte[] uniqueKey = key.getBytes(); + byte[] hash = null; + + try { + // on récupère un objet qui permettra de crypter la chaine + hash = MessageDigest.getInstance("MD5").digest(uniqueKey); + } catch (NoSuchAlgorithmException e) { + throw new Error("no MD5 support in this VM"); + } + + StringBuffer hashString = new StringBuffer(); + for (int i = 0; i < hash.length; ++i) { + String hex = Integer.toHexString(hash[i]); + if (hex.length() == 1) { + hashString.append("0"); + hashString.append(hex.charAt(hex.length() - 1)); + } else { + hashString.append(hex.substring(hex.length() - 2)); + } + } + return hashString.toString(); + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/MD5.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenContextImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -6,7 +6,6 @@ import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.business.PollenException; //import org.chorem.pollen.PollenDAOHelper; //import org.chorem.pollen.business.services.SendMail; //import org.chorem.pollen.business.services.ServiceUserImpl; @@ -121,6 +120,10 @@ } I18n.setInitializer(new DefaultI18nInitializer("pollen-business")); I18n.init(); + + // Set context in PollenProperty enum to use easily method + // getValue() on PollenProperty + PollenProperty.setContext(this); // ServiceUserImpl serviceUser = new ServiceUserImpl(this); // serviceUser.createDefaultAdmin( Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/PollenProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/PollenProperty.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/PollenProperty.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -42,6 +42,8 @@ String key; + static PollenContext context; + PollenProperty(String key) { this.key = key; } @@ -50,11 +52,15 @@ return key; } -// public String getValue() { -// return PollenContexImpl.getProperty(this); -// } + static void setContext(PollenContext cx) { + context = cx; + } -// public boolean hasValue() { -// return !getValue().equals(""); -// } + public String getValue() { + return context.getProperty(this); + } + + public boolean hasValue() { + return !getValue().equals(""); + } } Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenContext.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,90 +0,0 @@ - -package org.chorem.pollen.business; - -import org.chorem.pollen.PollenProperty; -import java.util.Date; -//import org.chorem.pollen.business.services.SendMail; -import org.nuiton.util.ApplicationConfig; - -/** - * PollenContext - * - * Created: 20 mars 2010 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public interface PollenContext { - - /** - * Load the application configuration : - * <pre> - * - Add entities implementation classes for Topia-persistence - * - Add model version for Topia-migration-service - * </pre> - * - * @param conf ApplicationConfig - */ - void loadConfiguration(ApplicationConfig conf); - - /** - * 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> - * - */ - void start(); - - /** - * Stop the application. Close the Topia rootContext. - */ - void stop(); - - /** - * Get the SendMail thread to manage emails. - * - * @return the SendMail running thread - */ -// SendMail getSendMail(); - - /** - * Get a property from the configuration. - * - * @param property PollenProperty - * @return value of this property - */ - String getProperty(PollenProperty property); - - /** - * Test if the property is defined in this context - * - * @param property PollenProperty - * @return value of this property - */ - boolean hasProperty(PollenProperty property); - - /** - * Get the configuration of the application. Instantiate the default one - * if needed. - * - * @return the ApplicationConfig - */ - ApplicationConfig getConfiguration(); - - /** - * Return the current date from context - * - * @return a date - */ - Date getCurrentDate(); - -} Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenException.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,34 +0,0 @@ - -package org.chorem.pollen.business; - -/** - * PollenException - * - * Created: 23 févr. 2010 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class PollenException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - 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; - } - -} Added: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,46 @@ + +package org.chorem.pollen.entity; + +import org.chorem.pollen.common.ChoiceType; +import org.chorem.pollen.votecounting.business.NumberMethod; + +/** + * ChoiceImpl + * + * Created: 26 mars 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class ChoiceImpl extends ChoiceAbstract { + + private static final long serialVersionUID = 1L; + + @Override + public ChoiceType getChoiceType() { + return ChoiceType.valueOf(getType()); + } + + @Override + public void setChoiceType(ChoiceType choiceType) { + setType(choiceType.ordinal()); + } + + @Override + public boolean getHidden() { + return getName().startsWith(NumberMethod.HIDDEN_PREFIX); + } + + @Override + public void setHidden(boolean hidden) { + boolean previous = getHidden(); + if (hidden && !previous) { + setName(NumberMethod.HIDDEN_PREFIX + name); + } else if (!hidden && previous) { + name.substring(NumberMethod.HIDDEN_PREFIX.length()); + } + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/ChoiceImpl.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/entity/PollImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,6 +1,10 @@ package org.chorem.pollen.entity; +import org.chorem.pollen.common.ChoiceType; +import org.chorem.pollen.common.PollType; +import org.chorem.pollen.common.VoteCountingType; + /** * PollImpl * @@ -36,4 +40,34 @@ throw new UnsupportedOperationException("Not supported yet."); } + @Override + public ChoiceType getChoiceType() { + return ChoiceType.valueOf(getTypeChoice()); + } + + @Override + public void setChoiceType(ChoiceType choiceType) { + setTypeChoice(choiceType.ordinal()); + } + + @Override + public PollType getPollType() { + return PollType.valueOf(getType()); + } + + @Override + public void setPollType(PollType pollType) { + setType(pollType.ordinal()); + } + + @Override + public VoteCountingType getVoteCountingType() { + return VoteCountingType.valueOf(getVoteCounting()); + } + + @Override + public void setVoteCountingType(VoteCountingType voteCountingType) { + setVoteCounting(voteCountingType.ordinal()); + } + } Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorker.java (from rev 2956, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorker.java) =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorker.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorker.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,28 @@ +/* *##% 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.mail; + +/** + * Service lancé en parallèle de l'application. Ce service permet d'effectuer + * des actions en arrière-plan. + * + * @author rannou + * @version $Id$ + */ +public interface BackgroundWorker { + +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorker.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Rev Id Added: svn:mergeinfo + Copied: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java (from rev 2956, trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java) =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,170 @@ +/* *##% 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.mail; + +import java.util.Date; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenProperty; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.service.ServicePoll; + +/** + * Implémentation du service BackgroundWorker. + * + * @author rannou + * @version $Id$ + */ +public class BackgroundWorkerImpl implements BackgroundWorker { + + /** Timer gérant les threads. */ + private Timer timer; + + /** log. */ + private static final Log log = LogFactory + .getLog(BackgroundWorkerImpl.class); + + /** Messages internationalisés **/ +// private final Messages messages; + + /** Injection du service de gestion de sondages. */ + private ServicePoll servicePoll; + + private PollenContext context; + + /** + * Constructeur exécuté au lancement de l'application. + * @param servicePoll + * @param context + */ + public BackgroundWorkerImpl( + ServicePoll servicePoll, PollenContext context) { + this.context = context; +// this.messages = messages; + this.servicePoll = servicePoll; + + timer = new Timer(); + executeTasks(); + } + + /** + * Lancement des tâches en arrière-plan. + */ + public void executeTasks() { + if (!context.hasProperty(PollenProperty.SERVER_URL)) { + log.warn("No property siteUrl. Reminder emails would not contain it"); + } + + // Exécution de la tâche toutes les 10 min + timer.schedule(new MailingTask(), 600000, 600000); + } + + /** + * Tâche gérant l'envoi de mails de rappels. + */ + private class MailingTask extends TimerTask { + + @Override + public void run() { + if (log.isDebugEnabled()) { + log.debug("MailingTask running..."); + } + + // Récupération des sondages en cours + List<Poll> polls = servicePoll.getRunningPolls(); + //servicePoll.findRunningPolls(true); + + for (Poll poll : polls) { + Date now = new Date(); + + // Parcours des preventRules de chaque sondage + // envoi d'un email si endDate-nowDate <= preventRuleSensibility + if (poll.getEndDate() != null) { + + // timeValue = endDate-nowDate + Long timeValue = poll.getEndDate().getTime() + - now.getTime(); + + if (log.isDebugEnabled()) { + log.debug("Now: " + now.getTime() + " End: " + + poll.getEndDate().getTime() + " timeValue: " + + timeValue + "(" + timeValue / 3600000 + "h)"); + } + + // envoi des mails avec une sensibilité de l'ordre de l'heure + sendMailNotification(poll, timeValue / 3600000); + } + } + } + } + + /** + * Envoi du mail de notification. + * + * @param poll sondage concerné + */ + private void sendMailNotification(Poll poll, Long timeValue) { + // FIXME : create ServiceMail + +// String voteURL = context.getProperty(PollenProperty.SERVER_URL) + +// "/poll/VoteFor/" + poll.getPollUId(); +// Map<String, String> data = new HashMap<String, String>(); +// 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 (PreventRule rule : poll.getPreventRule()) { +// if (rule.getActive()) { +// Boolean hasRun = false; +// PreventRuleManager manager = new PreventRuleManager(rule); +// for (VotingListDTO list : poll.getVotingListDTOs()) { +// for (PollAccountDTO account : list.getPollAccountDTOs()) { +// if (account.getEmail() != null) { +// String accountVoteURL = voteURL + ":" +// + account.getAccountUId(); +// +// data.put("to", account.getEmail()); +// data.put("title", messages.format( +// "reminderEmail_subject", poll.getTitle())); +// data.put("msg", messages.format( +// "reminderEmail_msg", poll.getTitle(), +// account.getVotingId(), accountVoteURL)); +// +// // Exécution de la règle avec une valeur +1 +// // Sensibilité de 2h : 2h05 KO, 1h55 OK +// hasRun = manager.execute("rappel", timeValue +// .intValue() + 1, data); +// } +// } +// } +// +// // désactivation de la règle de rappel pour éviter qu'elle soit réexécutée +// if (hasRun) { +// rule.setActive(false); +// ServicePreventRule spr = new ServicePreventRuleImpl((PollenContextImplementor)context); +// spr.updatePreventRule(rule); +// } +// } +// } + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/BackgroundWorkerImpl.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Rev Id Added: svn:mergeinfo + Added: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/MailUtil.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/mail/MailUtil.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/MailUtil.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,73 @@ +/* *##% 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.utils; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.SimpleEmail; + +/** + * Classe permettant d'envoyer des mails. Basée sur {@link SimpleEmail} (commons-email). + * + * @author rannou + * @version $Id$ + */ +public class MailUtil { + + /** log. */ + private static final Log log = LogFactory.getLog(MailUtil.class); + + /** + * Envoi d'un email. + * + * @param host Nom du serveur + * @param port Port SMTP + * @param from Adresse email de l'expéditeur + * @param to Adresse email du destinataire + * @param subject Sujet + * @param msg Message + */ + public static void sendMail(String host, int port, String from, String to, + String subject, String msg) { + SimpleEmail email = new SimpleEmail(); + try { + email.setHostName(host); + email.setSmtpPort(port); + email.setFrom(from); + email.addTo(to); + email.setSubject(subject); + email.setMsg(msg); + email.setCharset("UTF-8"); + email.send(); + } catch (EmailException e) { + log.error("Erreur à l'envoi d'email", e); + } + + if (log.isInfoEnabled()) { + log.info("Mail sent to : " + to); + + if (log.isDebugEnabled()) { + log.debug("Détail de l'email : " + "\ndate: " + email.getSentDate() + + "\nhostname: " + email.getHostName() + "\nport: " + + email.getSmtpPort() + "\nfrom: " + + email.getFromAddress().toString() + "\nto: " + to + + "\nsubject: " + email.getSubject()); + } + } + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/MailUtil.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,195 @@ +/* *##% 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.mail; + +import java.lang.reflect.Method; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.business.utils.MailUtil; +import org.chorem.pollen.entity.PreventRule; + +/** + * Classe de gestion des règles de notification. Cette classe exécute des + * méthodes en fonction de la règle définie. + * + * @author rannou + * @version $Id$ + */ +public class PreventRuleManager { + + /** log. */ + private static final Log log = LogFactory.getLog(PreventRuleManager.class); + + /** Représente l'action qui ne fait rien. */ + public static final String NULL_ACTION = "nullAction"; + /** Représente l'action qui écrit sur la sortie standard. */ + public static final String PRINT_ACTION = "printAction"; + /** Représente l'action qui envoi un email de notification. */ + public static final String EMAIL_ACTION = "emailAction"; + + private PreventRule preventRule = null; + + /** + * Constructeur. + * + * @param preventRule règle à utiliser + */ + public PreventRuleManager(PreventRule preventRule) { + this.preventRule = preventRule; + } + + /** + * Exécution de la méthode définie par la règle. La méthode s'exécute sans + * prise en compte de la sensibilité de la règle. + */ + public boolean execute() { + return execute(null, null, null); + } + + /** + * Exécution de la méthode définie par la règle. La méthode s'exécute si la + * valeur correspond à la sensibilité de la règle. + * + * @param value valeur conditionnant l'exécution de la règle. + */ + public boolean execute(Integer value) { + return execute(null, value, null); + } + + /** + * Exécution de la méthode définie par la règle. La méthode s'exécute si la + * portée est égale à la portée de la règle. + * + * @param scope portée de la règle. + */ + public boolean execute(String scope) { + return execute(scope, null, null); + } + + /** + * Exécution de la méthode définie par la règle. La méthode s'exécute si la + * valeur correspond à la sensibilité de la règle et si la portée est égale + * à la portée de la règle. + * + * @param scope portée de la règle. + * @param value valeur conditionnant l'exécution de la règle. + */ + public boolean execute(String scope, Integer value) { + return execute(scope, value, null); + } + + /** + * Exécution de la méthode définie par la règle. La méthode s'exécute si la + * valeur correspond à la sensibilité de la règle et si la portée est égale + * à la portée de la règle. + * + * @param scope portée de la règle. + * @param value valeur conditionnant l'exécution de la règle. + * @param data données utiles pour l'exécution de la règle. + * @return true si la méthode à été exécutée, false sinon. + */ + public boolean execute(String scope, Integer value, Object data) { + + // Si la règle n'est pas active, on ne fait rien + if (!preventRule.getActive()) { + log.debug("Règle non active"); + return false; + } + + // Si la règle est à exécution unique, on la désactive + if (preventRule.getOneTime()) { + log.debug("Règle à exécution unique : désactivation"); + preventRule.setActive(false); + } + + // Si la règle est répétitive (exécution tous les n), on met à jour la valeur + if (value != null && preventRule.getRepeated() + && preventRule.getSensibility() != 0) { + value = value % preventRule.getSensibility() + + preventRule.getSensibility(); + } + + try { + if ((value == null || value == preventRule.getSensibility()) + && (scope == null || scope.equals(preventRule.getScope()))) { + if (log.isDebugEnabled()) { + log.debug("méthod " + preventRule.getMethod() + "(scope : " + + preventRule.getScope() + ", sensibility : " + + preventRule.getSensibility() + ")"); + } + + Method method = this.getClass().getMethod( + preventRule.getMethod(), Object.class); + method.invoke(this, data); + } else { + return false; + } + } catch (Exception e) { + log.error("Erreur lors de l'appel de la méthode " + + preventRule.getMethod(), e); + return false; + } + return true; + } + + /** + * Action qui ne fait rien. + * + * TODO set this method to protected + */ + public static void nullAction(Object data) { + // ne fait rien + } + + /** + * Action qui écrit sur la sortie standard. + * + * TODO set this method to protected + */ + public static void printAction(Object data) { + String message = ""; + if (data instanceof String) { + message = (String) data; + } + System.out.println("printAction : " + message); + } + + /** + * Action qui envoi un email de notification. + * + * @param data mail data + * + * TODO set this method to protected + */ + public static void emailAction(Object data) { + Map<String, String> fields = null; + if (data instanceof Map<?, ?>) { + fields = (Map<String, String>) data; + MailUtil.sendMail(fields.get("host"), Integer.parseInt(fields + .get("port")), fields.get("from"), fields.get("to"), fields + .get("title"), fields.get("msg")); + } + else { + if (log.isWarnEnabled()) { + log.warn("emailAction data parameter is not instance of Map"); + } + } + + } +} Property changes on: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/PreventRuleManager.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java (rev 0) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/mail/SendMail.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -0,0 +1,259 @@ +/* *##% 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.mail; + +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.PollenContextImplementor; +import org.chorem.pollen.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); + + protected PollenContextImplementor context; + + 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(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 = context.getProperty(PollenProperty.EMAIL_DIR); + 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() { + if (log.isInfoEnabled()) { + log.info("P:[ SendMail ] start"); + } + + // 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 = + context.getProperty(PollenProperty.EMAIL_HOST); + int port = Integer.parseInt( + context.getProperty(PollenProperty.EMAIL_PORT)); + String from = + context.getProperty(PollenProperty.EMAIL_FROM); + 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/mail/SendMail.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServicePollImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -29,10 +29,6 @@ */ public class ServicePollImpl extends ServicePollAbstract { - public ServicePollImpl(PollenContextImplementor context) { - super(context); - } - @Override protected Poll executeGetNewPoll() { return new PollImpl(); @@ -131,4 +127,18 @@ throw new UnsupportedOperationException("Not supported yet."); } + @Override + protected Poll executeGetPollForResults(TopiaContext transaction, + List<Object> errorArgs, String pollUId) + throws PollenBusinessException, TopiaException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + protected Poll executeGetPollForVote(TopiaContext transaction, + List<Object> errorArgs, String pollUId) + throws PollenBusinessException, TopiaException { + throw new UnsupportedOperationException("Not supported yet."); + } + } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/service/ServiceUserImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -22,10 +22,6 @@ */ public class ServiceUserImpl extends ServiceUserAbstract { - public ServiceUserImpl(PollenContextImplementor context) { - super(context); - } - @Override protected UserAccount executeConnect(TopiaContext transaction, List<Object> errorArgs, String login, String password) 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-03-26 14:06:00 UTC (rev 2958) @@ -19,7 +19,9 @@ pollen.error.servicePoll.getComments= pollen.error.servicePoll.getNewPoll= pollen.error.servicePoll.getPoll= +pollen.error.servicePoll.getPollForResults= pollen.error.servicePoll.getPollForUpdate= +pollen.error.servicePoll.getPollForVote= pollen.error.servicePoll.getPollsByUser= pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUId \= %1$s and poll with uid \= %2$s pollen.error.servicePoll.getRunningPolls= 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-03-26 14:06:00 UTC (rev 2958) @@ -18,7 +18,9 @@ pollen.error.servicePoll.getComments= pollen.error.servicePoll.getNewPoll= pollen.error.servicePoll.getPoll= +pollen.error.servicePoll.getPollForResults= pollen.error.servicePoll.getPollForUpdate= +pollen.error.servicePoll.getPollForVote= pollen.error.servicePoll.getPollsByUser= pollen.error.servicePoll.getRestrictedAccount=Unable to retrieve restricted account with accountUId \= %1$s and poll with uid \= %2$s pollen.error.servicePoll.getRunningPolls= Modified: trunk/pollen-business/src/main/xmi/pollen.zargo =================================================================== --- trunk/pollen-business/src/main/xmi/pollen.zargo 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-business/src/main/xmi/pollen.zargo 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,145 +1,134 @@ -PK��w<pollen.argo�TKn�0��� �AQt!kcwѢA��]��,=�~�'�=z��"eRv�E6�ś��aEd+��Bѯ�y}�e���k�-���;!{¡��$HY�ٙ���C���x�T��r�=KA5�X-�<Q^0�l�R�5�� -�z�9F��ߏ߲U�*��@u���iT} LAU.A/4 -Z���,\�1#QJ48��9�4!�W��p��)m$A���q`�\�x�c� 3��x�R 5.w$A�T���x>��� Ax4ɕ؞�aD&S�"� -�|���#T�HuW���B��C -{�(�q�AlZi+�j��x;�ד�vE[�g � -�@�z��,[=�p��c�K"��v2E�J�� Gl@Y�-��'�+�E�l���.�$�����_?o~��_��4�ޚ2T�Q��s{�d�k���i)a�~��bV���y�9��Q8��uC��+�������i���:�-�sg8+��B�g��){�6 -��}46n��k^L�����|����\�m͇�(L]��k-x�7�Ђ�W��D�� �렴�'w�ÊIf�f���PK����4:PK��w<pollen_Modèle.pgml�]�n�F�ߧ���"�3�k�p�dQ�i��E��IZ� -�r��>оǾ�)���CrFQEٮ$R�|���7��������1X,�x~q�ε�I0�b?��.�>�=��&?^~��o/�~���W�������z39K����F��������������]���(���l�ޟ/7 �.���KV��|�x��u�.�/���gj�өmO�1�" -O-l�x�t�"��qoo��S[Ӵ�Z��B3Ͼ�d��{\������7 -ξ��/?�-������L�^�����}�?2𓉮�O&� �?���M�>���& -.n�h<[&�"��/��0�t�=��������B���37I��* �/���n�^����=���0���+Ͻ8�g���$�ߠˎ� -ʗ�_�\|��_�[����ᣛ�g?T��_[^��gQP�y.���/QH�O�\�Ql��>�~rG/ �����]B_r��%feuۮK���.k2�a�V��Di�7�r]X�#�H^��?K��N��� ����%U�s -�Q�:%@�p����%u��EׯXr݊s���I��Iu�]a������c�uh"�L���s�鷠�9�gūa�F�wq�ٶ��8���^��NA-��_�eކ���0���n��ۗ�Fɳ�}5L�|;����?���5,�n�<a���`L��zc��;Tےz�!�A��!��|Gѕ�ūyR��p%���p��?n�����H��_ߘ9�3��^�9�{�Pf���9����åU�<f.�5�u����z��bSnSR�����A�6�b�5 ��������c�ļq0�{�p���"�P���A���r�n[�*'����mk�,�s�{No��%��*���o:�D6]*�MW��������6��ɦ q4��NS�=�h?�I.�?����w���ge -�L�q64��\�)��(��4�چ,� ܻa$��т4�U�1���������B��+�{� -��5�дQ�S�]�>�S�o�8 -�y+�V�&���u -�c�/)�h��i��n����� ��<���WK �vZ�vX��=|��p��HWϲ��+��S����O��q��B�c���0^P#a"MO��ړ &�6�q���� -!&L��%m��2�D���FUm:x�)1*�4LT��w�a"�d���)C?�Di�����D�a"Ą��Ƅ�QoL�&��a"�:L��9l�����2s]��&b��H������^k4�0QY�8�<ք��4z�S Y�5�:��)&}\����}�tE?��w�SM)�=}��~�/g�G�2�g8[���Fȿ"��G�X�g� 40�CG���E�jl_*Y�W������:V#L��[�'�/�*s7�c��i��n��w��/��ڱh;�^�hoо -���)"w,�� ��G�S�#Wm6xǢ -8j���m���w,���1�"�:�t��$4��߱h�fC��x�ϵh�'!&�� �]<��g�x�; -�mz^$���p��b� -'�J8�Tc�������DQ�����IXY4�Q �����{L�\0��Y���_R�~Ē0K"lő��7c:��$�P���CR8�� -��#I���)��Ն�2�fe~�ԶY�W��+7*�"H�m� /*d۬�}];Q��H���������&pK�s�#N*�S?����?�I�U�e<��F"��T�Y�k���o+���%�"���f9NWl�[a+��E@������K����,6m^��II���˥�hkc�a��I�16l�*��_c���Q�T�c�c����X*I>V�����!m^x��X�=��O1�fa6�dk�U��I�D�1̅�9�1������ǻ�9:��H~�7�,�� �h���� xL(#.��Ռ��k�3B�A�}��f�m�lCf������k#�� -E;�J�`;�`�`����d`{Q�|a�=�4���6[#�ހ�����_EQ�Iv6��Nx�c�����=�6�}����� -0����|�4M������������[�\E����Lӂ��C�0����+��;��|�4@��x��p��\����O���6!E?Ab���N �|&��Q�����6u'��CE�<�H7�8-�+���atzH�i9�uk�4�dO�Hx�.y� Z�'O[(mDmᴛJ�t�'O�)���\��g �.�|m�߫�iRI��PY��"_,?dج.�� -t�<M�%O� -Ԛ<���{�<M��i�\���W�~$O.y�B�Y�ha!�5&Og�7$O�J�4cH���zC2�����>M�hʟ&j�3�f��Ƽ�j�Լu��C��iּY&PR ��c�i C˟�H��FM��M�[��4� r���f������8n��:�v3����W�ݨ4d�[���8¥����sKkt7���K�4"���q8c`0 -s�3��57��.I�C[�*�<�lww��ŋ����K���;�W!j��\�^���߾/�(6�>&zm�Zx��x��/�z����[�*��}��_b�� -�w���%�݈����9TH�Tl��g�yx��p}i�o���D?�-]z�ڄ��Y�3�7{OU<�9�\�i,ԉ�{d;)m.����-no�Aj�*��u�Y��7�( �)�/`J�"���Nz�{�h���W�y�T-رd�+�G�"�P���mV���S���2@DR̡�9�_z�������_ѧ�q�k�j�kM�y7����JV.�syq�m�x�Z*�5��O&F����O�������h7����L����g��WJ=�UpӨ��]ƌ�l���Z~Z0�Go��3¨OCpswq�<�i�CF��/vU - E�Gh��g���h�Ш�1��!��4�#F�f�D�zh��"x��[U�@�M턑�����1pM��� -\W��/�8ӄj�\��E[��7+R`�Qm�܌�z�pp�P<�"c���lN��o6n��&L(�l6��獡�6�6[* -��V��1�i��,8mu�����r���-)~�� -$��-)N0���?�(�x�Di�,X��7��&4֬d�/�9�?(i����,��f�R8$8���v�$|$�6����HhT������^l�l�k�j�b��}���ps��$ �:]A�۳�$�b{*I�����z"���V�Ϧ����g����WE0Eu~�Ϗ0��#p������{�1lf$?bO�r���F��I�� d�`�4 ��q �UgD��Ɉ�� -`*�f2ā�W�a�=h���s,8[PD�r�<���+�q(��w�[��)}Ͷ�}�+#��0~�8m'��#��AѸ���=F㬡�8I�_��8MȪb,���i�r�U�8kh4N� -V��a]��8��+�qV�y��j�:��y_�z!"W����I�u���z�n����$��.�E�Jh���z -_n���p���y�[]�F}�%�����V���S�XU�R�~$��|��rP��'Z�o��jW{�T�H�;SoF��кn�ٔ�j+nՓuY�**�eU`ۺJ���F=�m3�^ٶc��C�e�H��F]琺�<T�^ט�j+nԓ �l6[S��o6�MK$L(��l�l�c-��n��Ґ�l�[sYm�M� -<��&�`.k -�X*�ͷ�aq��B�q��h��j6ߨ�����zlR��{�&�v�S�WEwIh�TکG�L0���6|�C.������F/�3����B�y�+�,8É_� -�H��]<�f�p"P�t���t�@�P&F�2�y8(�e:_i,S��egb�r�Pfi��ђ�^��i�Ii�))�rW���� mz� -���)V�q��4��`h�N�p:�=)��t�_5�������+eyiR����\i}'sk=�u�&3 -��hH���8�+�\VN����.TN���ӥr�1��c�ŧD�����"~�T���5G�+��G.'.�):�T�~�N��!�~jD��9K���I@G�f��ϡ��9�3�Y�ӺJvږ���j�"�}�������"����ӡ���(�E��ı��7X����.�+*Ccpo�c�]@�]R��,��o94E�T�bpo�c�J�.i���}e���Y��x8�4O.أ��F�{�XSnZҵyK�SH�0��.#r,��ö� !� ��'�8uO��Ue*"��T��Ř�vI��o�4�%6����+SQV���T�����u]j�%SOb���V�R�~�f�@�:�� -[P��X�*]�J�/��2f��%QoF�^��1NS)�J+Sצ�q6� -�ƴuU)��f��h4mx?ӶW�\��A��U�����V��Tx�C���b�Hܨ�� -1��N��;����͗��� --�r.zb��</^͓�����xc�0���"�ݳ�����o��a��Y|����D8[�i�=ː�{�{��[%�+��mЇ��|t�UZH�ǫfN^[-%E�\L��p�]-e�vYj�͂�+�V��r��9#�Co�}����6z��$��Hf�i�ʼ~�&�_��6#F*�2뺝RJѺib����ܱ��Vg2�z�.�m[N������j���t���oG!?�Y-p�T�z�G!?�Y�f@���Q����:���#v.�z;2tG�o�r%��B��3�FLcc�T��7n���q̬q������7�Y��$6�92e]�-�=����͆�f�AM���X���J5B���-����1�n6��7[�f�?����Y��ղ��͗���a�I3��֪�sk3��n����] -�[o�[�{��n����Z����aѡ�� �T%Ea%��\��P��U��aXUw,�8\ӓ��T��=�� ��5�Y\h�3U�@y�����JB� -��w=�TU����z�����61!fM;*���\Dz��Ê���@�cX��P��q�Ō� Ob-�{����(Vd��� -�Q�2�+g�=��mճ�q����_���?3j�|9q�&:G_��G���PK����PK��w<pollen_Services.pgml�\ko�6��_�C��#J�é��M��@_X��P�D�\eѐh'��GJ�^�%���V -;E=�9������]�F1��jO���=������S^L�ƿ��t����7�ҧ\~�����c�x=�#9��؍В$wÑ?p"�h'���G�b� ��D+��"8X��Շ��ǯ�>���a�o�}`��@���f]���g�5rf3��o��z��^�f�HI~Bg'�K����є�����٩䫛Ώsz�w!���q�_��Dac��?F���C�_Q��8�9A�Ǵ/��n �"x3Q��%���xӑ�64��;����Y}��?����h��G�A]Pϵ�3��c8��n�����5m�:_�����&��������a�A�8������IOn��7�#�I�»i�C�� �S4��j�jc�Zm�ۤ(��!u�p����].s�߲[V�F�n��y�%T��n�f�u�RΑ���D<(���_�_���6��f��6������[R5T�0�F#T�`le���Ea//>3�!}����8r'�$���8�Fv���-��*&h�\'!�����鳀<g����|�@?�Sv; ���ځ~?�q�"E��O�����ϟT�F��%{o�i�B����;�&�qT岈��,�)����҉Ȃ>=I%�������%*�\��s�e��%����"��ibՊ���o<��t�Xr��ٌ&��lj� �y���!�u�d�f���tu -[cn�빡� #��'���sGx��=���C�������?�3�Ä`�2�G��Fv -�%���n��P�;P^n�f@�A�UD��1��ސ/X�t��Zz�oJ��otq=>v֏�ݒ�n����=�݃���m)�&���;����.Ď��==n -�H -����fu�'� �*��_1��t�0�����W!i��.��H0�QG������"�lG�ѡ��лq��Ag���c#!��G��$ -�֓ ]�j�hLX��σ �e0��d��ń톲 -�*"�0Z`8�!A�n���ؒ��H��ڐ:��$��U�!�b�ke��G�P��nȊ_�]�0:^�/J -���7vȔtq�Y���)b�0��9^��߸��c�D�]��[ڂBrC�t؊����(�.�+S� -�CA��AR��j��4ϓW��������3���� - -�����Kl��F�c�e��(�Ŋl�z�*��'���E��FE�~3-�x7VՍ�.�;��T�fG:���k�?K�8�O��&�F����pB����@`E':IO>R�8�Ou��Pߛ�T�>ը]PI�>�[ɴ>`�Z�$���Y>�SI(?K�8�O=�dB��ThR��_M�Sa��F���� -��K�z��}8g��zyUz��;.C:���#Q�oC�,�8��Quc���sOή����O�4S4>��R�L��vo�p!��6]Ӻ�}BCZ:ۖCN�h������0�[�J�XTԵD1?2�!�b&1� -c$��M�uK��]�NP/����~=��8aG�-HjW�OhH�¶��h� -�G�}.�5�P��J�I@��Ԁ`�آ��a2�t�ƨa����껮5*��k���xpR�Eb#�A�(��rξ���S��L��PK�N�ŷ�@PK��w<pollen_Diagrammedeclasses.pgml�Zko�H��_�VU*��c0� PuIZEj���T�V�ʘ���a��G��w��/HC[Ԅ����9w�̽a��n�K7���.G2ꨲ�����7����(�,��8�0��tq&��tyu�^��Mg�g2�f8t x4e^�f]A'q͈�1{� �͉�o����+�;+ҹ~�n��ax���M���4�+ -R5�Ќ�������5,�úb��:P�Ծ| E����#yB��q�`���*�[�OM�~���,�����G�I��jꑄt�s`��G���G���$�����$�v���3[<7L:�������a��EU�)�5u5��ɜ�ڷp ->i(��%�s��S6�o�g���ﺶĝ���|M�y0rcs�n�6�n/=��d܍d=e�>sKf|>���2�ěsx5�HL%���J�R����*i�.�u�q�L9~:$[��:d.�(ߊ)K�c|�M���d��]Gx� �e�+���7��2�KP -�� ȅ���*7;\�o��i,�'BX�N��F� ��2k���N�qB�� I/_��d�dPb�z��p�'�H�d,3O�?���!�*�2����8�z�L��ͤy���'�"�������XL��I��2��� -bt7+���މ�0mº�Z�kP�ø���}�����Q�f�=D�>�[ք.��<?R6KO�mo�M��~��uۥ�ʭ�Vi{��m%����Kы��g3h8��B�O��(X({�O[��8�3\��i��"0�'�x@��7������nGk���MN5j"�,��[���S}j�@�\��s�Dw�@z~<h��%o(��E���n� -F�� -�$B�n�s�g������q���0�0����3�g�&2n~�_���)i<\rF��F&��L�$3���,s;�)�>���0Z�0j�V��=A*`Qwܗu��F�V��Z@�U�zO��cpb>�\#�_|i·kӏ������m[V���*�ѡ9���44[�����,HDM���{GRk��I:�^�fQ�6۳�Qd��(x�Q���Y���l1rvT��q���YT)��������j�GuU��=�X�5�gԯ; ?�g��<� -�٢�dL4�ȓ�Ϟ/�Zem�Z��Rm$tY��i��t?�V�*�ڲ�8�I�����w+�X(��P����CZ뵨R��D�V���5��S�^�aխU�������R�ǟ>^ -�!��5�/a���k���ӝ� -З���2oY��A�o���c=l�Y)��� -�dE�0 -�2�����[8�>��5Ѻk�0�9�{�G�m�����| -fx���WGM��[`y�V>������*�w���P���ai�,�*Z��b4s�1v<�v�C�1 -^� �?j���ݺU�V{y���WoS�l�H:���?>�PK9ܜ='PK��w<pollen.todo�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��q�(��;�D�*���+G���*(�8z)%)J -@% ���,.2���E���9e�)�E�%��� Y,B3PK4�[-m�PK��w<pollen_profile.profile�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��qq��e��q��ÙPK7Rp:BPK��w< -pollen.xmi�]뗣6��������Jv�\���N�g]~��9IO��:;���]L0xWw���W�[<$��<3��-�Օ�O������e�H/�lϕ�"�)�N���Y���_|zZ�O��槿��N��������q�7�~�������pCla�&���F�`����P���:D�}��o4U�/�$UV价�H~���o%����-tC"p��/����C�v�o<L����= -�@����o�&������C�7鑿����u2P�� ����%�g�iB��-��e�^Q%y�&���2�V��#�,��_�f?H��oM^�<��0Ј�-D�,�H ���-����˷�@���m�������������8��3s?���'�{E��Wd�~�� -s8o���)X�'o�'�,��ӟGytw`�?�7�q�{'���4��mF��?��@���3_�������`f��T��dG�t f� � -�~�&�͞^!y:ţ��k덢*��aBȄ�yxw|��?ȷ�F�D,��Pu ����s�C¯�L��&��];�'���#���wJ�Βr��q��LZ4��G�>��:4?��߀�ؤ�TQ�@��(�p�ʆ5A�w�S�\CH�"k���L�04����v�������Ҭ��*ɮ�]�džsae#>���C٘X�bD�<N-��I�����2�~e��ٳMD6@۰���no8��Ȓ�l�_���ɜ:2!����;��c��Yy]@�SC��*�+h$OLsHE��x��|�^����5��ϣ|��m�C��`�i�hᏴ�%�1����t:�3���~��:�?��.z�����5Ϧ�g�n x}x����s�8���D<�*��`�wB{��E�'uKM�٥���#�j����5't���_J��4���>#% ?�N��vɿ���#�4�:oM�����Yd�?vH�&q���Mh"�)A��O����$%H�'s2���L�nZ���߂���;,���:����������hOƊjY:I�S��Zf��=!:o(�:l( � -�;,����c -`�*�9�`E� -��pH���Y�\f2�Z5f4��i����{�7���� �L��%��g�k�<b��h��υf�m��x�Z5�~I���^� -���~�[�?8��n��H���7LJ��v�vX���@� �e^���r���J?vʙ$���!���L�e���>_�E; - -y�-Ƃ�B.�ɞ�Eu�p=� -�b�;P��@q�HA��o'���*!g-)�Tj�|<�w��ʙiz{7�FK��F�#�j��[�;d��#��ya���;�v��m3��J�td:\��� -����6��8'+;��7*�G�@$!�=~F�h[$��vnXyڦA�J�X A��!��A��C���yf0��8:�۫���kF��d�l_����tX~��0�q.�gn -����)�Q���h�+�BT�at�}��-FE���}��]�sz��+���:�6q,���*�/��$�@��2���=�����Y���O�z��P1��OU$xf:ܴ��@;�:~�O� -�g�C�����n�̙3�1"��Ȝ�<s�u�-kj����N&mm��&N����>#:~v�'�N�u��E��n5����!�|��N�ca�#�@L�J>zt'��Bkqm�A�^���2�}���@a2f:�:��#���)�%�t�9��p�0�k���h9��Y�D#ѬM -��"y�����Cǔ��q�C��ƕ��N��^�xh���ӋB�O2�P�tٍ�W�O���U���WCa��?8���nJV�OT�t��� -��i1+���^�k^<\Z���£s�=�������sͽ�C� -���qyn����֑�����^j�v�GLI�#@��[���9�=ܚ̋M�����]+ղ��d�ʱqm��|R�*U�:i�������ĉV���l*�,3���4q*�����<�èjn���|��������͢9��5�4G��EM��N��(���W��nW�ffj�G���ǰ2z�L�X�B#f��� -D���5 -��$����� -�)<8Э�p8�ft�Z�1Qռ�d�����p�3_W����D�V�A�C��A�uX���Ad� 0�ej�>wV��=�A@����.|�o9�������i\� ��j��~<� 0 -�-C�`J�+(:1)#�-�=a$�s�ͻS�� -4Hw����ܫ�:0�+D���K"��0�t�0������hS�C�6��şhE$��!K��M��;��%�D�A\�~)[5�a��=����@#��C�H�µ6;չه? pc��M�L�� ��������f!Pf"E1�L�+�̚�TX�-B�ۮ���6k���(�e:4� -k�A�X���6˾��(J�e:\0ޕ�_bK�q�X�����L��O\���P_ї@�A*��b:^p�)�,���SuEL�+,�T�ج0s�����e��.��j��L��(��:�"� ��j��ĆQ�*��M��ش�5��S̅�ǻ�~�Bx����6s����W�L�с,n���3ޕ����# ������6��Vtհ�P��W��@,�`�X�@���6���D�W�H���b���62��E-����)�pp5&sۏPx�უ�l��EFξ -�_v>���>��5���|'���"ܨ>�e� -�'��h�f -�ǚ1^�3ۅ���k]�_y5�c۬��D�(��p����XWF�� -���c8�9�6�/�s|Y��nP�#�N���L�+ˠ�\���;�q0kP�+�)9ՙ�����q��j�vs�6�"�:ӡ�P��9�R�.N�hR�/�5�x�=�5GQr�k^ӭ9y���M�ޚ�(�W!���ɩo2Ľ9in��j�t�3|�0[ -2��,�[UP�aI�&'�����j��=[������8h$.VlG�r�Y$��larr�j���{H,�k��� �@����M�4�W@,�iV�5�5�Q�N���j�G��Md�0���վy������M�M�TU�ut:C��#M��o��ܓ~a��k�61�{%���'�W[����YME}=ՉqHE->���������n��N�8ß�p�9����2��4�IXO��D6�ʅ�h`>{���C��D�N�HD�t�:P�9ϴO�r���َ�����8���\�.�T�k�2~�H��������Yd��oA�v7���ߡEz�l|�9>����,��\�ʲ����!����nDN���Z�N�D�(r�eҨ�W�^7�9"��B��N��r*Iӿ~�:��a+�˪��"y��a1Vu!V$ZW -,�nu�@���o�8�#�Zx_���2]��1%W&��"��D���"?�Aw�e��q�&W%9kYYUc*�s�<��Ҙ�N�M��QQ�%�=�C]���zZ<��0��E�ъs�U+[#�9�[E��ujdt���Z�c��r�D��V#��VN`[�:A���U��T�ؕ�bt0� �EjWŮ%(|���N �LL�!�l���ՖV{[���vձE���su��^( ��,*���l@� -Yfۼ�\����SJTF����H�G܊6VR 9�W�^C���nu�9�Δ���N: �,�9$^!\y��jw� -��hLK;=Rβδ��ʼn��V�R%�|��;%U#F�D�fW��k\�=�X ���O�L#8A<n,<�uk�:�Y�z��[��t�y������@Y�0��\��%|��8�N��9����p�~r��w��c��VPkZ�����@� -�$̭9#�E��larr+��j����j��Fò�Yl�f²:Q��HS��ˀy�r���{RE�c��.(�H�m%��بN�H�8�D� &��qI�:B��Yh?Q�>�M���Z���(:1̸֚��g���C������ ���J>�(��sh氩�"���hm�^��� -�V(P����X�ҟ{(�ەѵ���j�,��G5G"���Я��E����#�v��,���@ym�'�?@z�v�є�+���^��O=���2���,�g2m��+=d�HL�G��9a��,��v�xK�8�f��T]㵪LF� u"���jI����rP -�Y�1,��"���YYi"�e� -����D�_�L��ɢ;`@~-���LI����*�e����s����U=���*.��H͇BE����N��sE4��H�����l{��/0��}f�@�����bȔ�ޜ0�� -d�I�M�TS9_[���G��ɹE�����$�Gyc���ic0�V�������G���gχ���s�b�e����&v�~� ����f7_����K�x�Ԉ�Ce~ -�/b� ��|<�X}�<$�S��8���Ac���Vcr�dy7�X[9���$���-&�6�G�WwV�Zr��F#�p�+��*�z�<�A��F���t�]�[y�[b~���^�5K9��P�R�[u�&^yB^�q�z�ZFkA6+)˺`��c$^��B�gF��=�#i(�����h�݉,5u����$Bf��mR�/3��r����5jx!/r��?ƣ�ޝnr�O�a�tA������z��sⱓd����~f�ᾞ~��V��Bh���� -Ԣ��Vdx:5��z͆���h -)+d���N6����:� -�>��!mR�˹YS�?�C�ם -���S˓�{TLn����% s��w^C����4F�z_'��j����K����������9����\�;W��\g�؝�[�0?��ձvU����r�Е��0I��������J�+��pX�����X8ϽK[`�U`!Q�=�CG5M�'n�G���larrN,�,T�HxH�^a9�ʝ@�-LNi|A a��P�����VئV�{3���-xs� Xx -X�*<�c��ً����|� -�@Ü�-L1!=9�AV��Ú�B�}6xG�E���N.� ������ȐH|do�ea+s����V7!�k -����=�+�zL�aN�����;&N'GX�-�Ji�Q�M�ޛ�0�iC��]y~��}�Tx�x��(��[��Y]�"C�Q�Q���ۜ,�#c t�V$n��]΅�vhJ# -ًA��R��aﺶ�a�?��0�Ii���?R�^�_a���$��Z�W'~RpJ7��s&p�$��!^d���}$9}s��>F��'����6hG��M�~:�5b�hzf�3���(�@p��\~ieN�W�� )u#B���cM��J+�)ਿPZ�6�mZ� 黚�o��%�s�<�F�a�&��S��.Ԅ�Մ��j�,�'������#(e���\���2'��W�9�q -}�E����9����ޚ�Ԧv���y�"��95�Fi�����L���8�Ua�8}��*�Ŝ�R<�o������kFDE�P�� ;�t��(�b!�������(b ��<�<F�)Q&�f��57$x��\�{���.D��y+'����D�,,����0����0M�(���- �:��HR�fD<�oa6\�*I{��s>��caiJ���c��" -_�<[�Ϸc@��[ -̔ -_F�¼���;��P�J�#mxHJ�%|���j$C��f@T��H�@��3�g��[CC�t�����P��չ��������4��e���K�f�6��$���"EU��^<�h5Qa" N�r�Qg�4���gχ�>����qef��~�7.p.d�Y(6a�o������ X~1����39���DBb���8����h -+�bv�s�������H5��!b���� �B<Zۛ}���q�dN`�`�������m/���k��&E���ٶ�am�@~A�+��P���<�L϶�&~�K�9�;~� L���f�%��mH�v3������kϗ��� -�qin;�d��#�����u|���71�A|l0M�Á�x�#�*K*�3���m�NIܙ۫����_w6�2��xq�,����"���ƕ��ON��DX - -:�=v�}s�|��1�L���|㝖ш�(^��.-![�J -t#�/�ڥSsܣ:���ڴ5����ͣ�����R�Ts��u���J��T�HO�z�g�q$J��V��}�mQ8�W�^K.��g ����ӱ�?��}�fL�_i�^��^2�+m����$�q����I��K2O����W�����hmK��t�b-��f���%[�� -2�}��-����m�Q�d�Õ����c��#fb]/�-��@��em�F�n���5;57�������P���p�hi$�auaׅ�E�R�I7�I�ό�^�.<� i�t+��\�U����;�Z����ȉ*���8J�U*q���-�<9�-��#��ï�[��ܓ�ub��)���0�����窻�����a˙�]���B�O�F�KDpd�#�2�0a9���r�cra͘PZ�aw�z�ͽE �F�8�7!��w-�Kw��j��̺�K6�3����3�UѪU�[6�N�� !��cK�h[ -��h-�vc�Ȍ�G¼�J�� -�+�1O��[�}Do�����B�(jߵ�Q�}3m��/Jo4��[���q��/L�47�2= -+F�W�Hm�����j�' ���Es�Ʊ�$I�s�����B"r�vJ˵2;�Br������$T�$J��q�^5���ՐH���Ҋ���]��!�b=$�a W��s,���5�ҋ��L��=�?uk #�B��P�`N��o%ϋ�4�z��]C'$f���V�`���\�gx���K��x_�Yʐ�5z~�Hu�Ǚ���D@7�/t՟3�.�!.��g ���C��#+�$���;�v�P��;Ԯ('%S}�������+}zg���B��m�9r�Iv(}���,�b�g ��zR9:���p����X�����X?��U�����T�[>ӹ*�;^��_�w�gi� -���H�~�}Q�k��E�*�~DO�^xi -��"9��K�Z��uD0���#�b^ۜ��� ˊ -�V�p��/\���ۡ�����Y�5-��~��,�Ӎe��4C��؛�i�`�-k������e�l�s�۽�xN� ������bF�g�o����}�p��!:`�3R��;i����Nȕ;l�%���:_dU����d�m{v�>.UV����l;V'��9Ij�� ъ�x2�G��T ��R��F�I@��� -z�ft�/�щ�<� -3u.6��آ�L3�a��8[j����-�r�+e���6�C`MGk݈89VT��ubv�b~�������d���*�),���)��i��|�L;9��>��[Ed��Ē#��g:�Z�I"[^.�\l�4��[2��݄ޕ/�vx�7��'CSC5�B��(_��Xv*����d����.h���H��!��N�k�K�B�^b�w*�[�:��J���di/�[�g�� -�R��}Mh)�Tt�3^�E�N/j�<�o�����?6�sPS1���1G���f��;����t�-x�\�]��� �b�-�=e�R�}K�+' -���t�X��`ߤ����ޑ�^�}+�����7��p��S1�+���n�SAvY��}\Xm��Zm+.���j�˪o==d���-d��EN�����rO�.����v�)C.���s�](<n����B�AyY(=u�-T�����>|���>Ӆ�\b -]'��S��桖���?� -j���)�4.tg����}h<��Z9�qʾ)�#����<4.�Z�۔W�������w�xp�.�r�)��ӹ�z��F,#.4�Q_�.#.�o�W�˄�x�b��x�b �N�z�cʅ�oZ��}\<�}5z�\ﴧ�.��;���xH3]��;o�`��'��p��ʳt9e.�YO3��\���)��c�#V�c_��9��y_��s.v�yOx,\����^�'��eA�y{��%���X>K��N�c"�c�c��ּ&z���:jL��8 �V�jª������$^�<Z8q����jB����m��l -i�8�D[խ{֭䞲���|9��xg]#g\hi�$Ղ��&-hi�$͂��F��ii�'��jJ0��Okb5l"�CK'9��d�M��ii�$�MKv9)�4��-s�:� ��ۄ��61�d��.�_keyv*8qP�5�@C'~;z�����\��ECYx�:;EA�΅��}��Ftz*8�Z�o�i.�� -N<RԄ��;zFCW �4�7�GFCWyd4�7��CCEǧ�_��C˚`d"����d��-�@�"�u�,��x�e!�N-�����,$��`y�� -��:���g%���L�X��s�V�d�N����]W�d��c�T�'����X��?-�V_����e��cyמ7���z����2�,4�y����zw<��̀`y��$�:��r��iєycYǫl��U�1��:.�����ק�e���i�G#mb��yX��II@�W��N��z��p�FQGk}=�5�tPO�k�ɒ���˻0�܌xR��S�:͵�D7���XSD��hOƊjY:Sj=��D@���U'������V&`�q~ �]�gAmٌ��r�sF�]�g�W�2Ь� -�� (�䙻�@i(dGAG�Te��̈́�)�&�^��Z/�`"���]u����OE�&EAs��������Bb�cҜ�?�Nz�۰<����@o��������6Ah{.�i -��_>x^����v��L���>0��fh��ׯRC�����~ ��;��G{�'3�C<�)�9��u��iN4X/��5�w�UjZ��]�\mx���H�Wz�HF�W�$�B��t~z����ѯn����Ϸ��?PK���#��PK��w<����4:pollen.argoPK��w<����mpollen_Modèle.pgmlPK��w<�N�ŷ�@�pollen_Services.pgmlPK��w<9ܜ='�pollen_Diagrammedeclasses.pgmlPK��w<4�[-m�i#pollen.todoPK��w<7Rp:B$pollen_profile.profilePK��w<���#�� -�$pollen.xmiPK�aH \ No newline at end of file +PK�hz<pollen.argo�TKn�0���@�AQt!kcwѢA��]�4� E�9�z�^��H��g�Mh1�=�<�3,��D6�T(�u�1�lDm8�j�:�b��^ȁr��" R8Ev�}��P��'�Ȫ,N�gP��1V�2O�.�� +�ơS!� <����A���[�"���T/{��U��)(�%�FAg�1�B��K0f�J��z>��&佢� >�F4J�aG���x�G9����2�|�G�(�R��D4J�q\l�ǑW$�&�R8ۛ4��d��~Cp꣖Z\���6��V���P/ﱁ=6(�v�AmZi+�j��؝��<[{��+�3y��Z=xn�Vϧ0!���vI�)�N&h�v���Q4��2�t �c���*�~���z �:������ͯ���S����ۙ�|������z��0��s۴���?삂��>�e�g��sǾ�n�8{�x8r-'R3;q�\Ȏ���pF�X�ܫP�Z � �o�ƭ�z͋i��P�m�����N�O��f~c��;y�oXע���L��/�η/��B]��̎��@u�PK(�:K/.PK�hz<pollen_Modèle.pgml�]���8�����8,�@�G$E}dҽ�t���#�I��v��m5l�����=�Ŏ�mI$Ke�j�$��,�毊���U����a1y +W�(^^���l.��,Z�/�>}|�M�v����x�����?��<�� +�����w?N����Y2;cW�o���t=&�ū�E���v�3���*x�X'AM�{��6�d� +/6�ŧ�Y����5�:w��s�;G��Y�����8�+��;���ݝ��ܳ,�U<�X��7��X��ُ�����Ͼ�b�_�W��q���hn��=���OI�Q�rb��� "���<��o�:�]��w�b~�N�U'_�ߢ���]�����������$YE��$Og��~�]����;���h�`�^O�E��<�|%a�v�ϰx������E0�'�*}���*z +�p��[����*�&�r���D�}�t�����v��s4K��$�1�a4�O�)��OI#+�~\�xB�d��n,�]�h*�Vo~�ta�w��� +��(|�9��B�;$�r��v���W`�eJ�r5PAVH +����A��rو3�`�I�/�8$��H���q`=j��8&���w��%��:/�y~6J�E4�<Km[~�6^̔������rP����:��i��07�M���WY$��?�l�|�˜�b^�?koX�ٸ{!�}`L��rc��;Lےr�!�A��!�+��/��i�Y&���+hm�s�p���U���}g�����;e�,�ܩ��3s#=3��>�y���5�8 +��@=�͘b3nSP�����0U�xuԘ�L�Uv���)LbU�8r�=�h��{:�0�`�A�K�r�aS�:#�ꔳ=w�,�?�9g�R�՛s�s��Igd�qy4�t�=�I���i�J6]H!�fׇp�»$��g�W�_��YęT�L-����#�g��>�v +�HUh��@s�Ç Z�#Mk�&�J�Έ4G�s:v�,ް�Q-�N +ԐK��F�9���!Z2�o�x�Z����Q�ˠ~���-c�m�O-�^ +Ԯ��k�X�x��!ެ��_���hō��"Z'0��Z\xe�iʱo_V9�x�ı_���Em"Ld�|�m��`B��<��0Qn�;&BR�Ȳ�İ����h��Dm:y�I*d4LTx�w;L��0�UX���)C7�DYTơ�b�D)�a"$��DcB2�(7&}}Z�+�02&�f�dg�p��\[.k��$3�0�3s�83w���/LT�$�2�5!��=�k��V��T%n��UL0�����lA�b��)����^>�Ѭ� �X>�Ѻ��QO��������:��Q5�fx�C�Ѻ����������>5Z'k��r~ȁS������J��� +��d�]� �,w��C��ן�ftA;m_�kdy#���h�N~Ҏ�" r'S(Rn(�1@�AS�����6ਁ�wD�I��;ki6D����Q�M0o��r�NF�t�� +q%V�kQOBR<�@��xR���$�Өm�����q�Nz��S�$,��p�t�c�ԑt��,�C]ԥ�G���h��@F�I�w<���`.�ދ��B7bIX�%���I���7�q�}��PBI�!ɝ�冤�$�d� +!a�!�Զ���m�qkˏ���l�\�� +7�0�ݨ�o!$A�8J����-�NT��u|����&~\M��oq�`����j�Hg��E@�E8W1��d�"��N���r����]��a��f����}M���R���.E�<\��� �Z��օ�I���v6|dk���e-�n5����oq_�O�� +�2;@AxՂ��Ȇ,��&�:���_�b�Wc�ʏ�h�1_0�����ڣ�e��d��[tS0��������L���B�=x�|u"0>Cܢ���$�d�8�����:�}�sTa�d�ߟ�Q%'�)^x@�AG�P��6U=��+sTqq4tT���8��l?UԠ����)�.́�T?fZ|$�P��(Yh��`%�O��H�R�fT�j��U�r;�o�y�ܮ�u`%�OA�9S�G� ���"���P�P��Y���Aԃ��hFR��/[#��-C;���`W;���`�z�a�E�gڞ~���V Ð;�S���ͮ��s3ث}<Qu�O�U��^���^R:�f��AC��굥�@|�;��qs�>��p�Y$�0�^f:�h�˭z������^��t|@���S�#o��DիMׂV�c���b\D������)�c�6E;�F��P�^m�DUjؿ7��GykET�k7�aaS��}@��)�I��{�\�y�<�E�x/"䵼���LQ@p�C� ����ܼtjO��������X�%���K(�-�)#���� +T���0�w|OQ���E3&*� +��SF�=e."�0��ck��qOY�xŞ2"�)�I�.7$}�Sv?�4��me�춲Լy6ݙ���U�����u���L6o"=�����H�6� R��Q���_���U�lrܖM�h7��P����� ȻM7��ӭg�qeӍK��to�L�#Jj�� +*�t�*?��J��J!"Jn�~qz�N�閛�zt�� ���U�.��r9�`��ǫ��)��e�]ў�+u��^��(�1��X.�[�c<L��x����U�~��MbcL�o�m�c�~�g�W��U|#��~"�zş9LHLl�a�3$S�3�^Z���߳����r�P����>����L�S�S��ş��ʜh�#�I|#�U�gʯ��[��0 ��u�Yt�7�$zd�,J��x�)I�Du�o�;�(���n9�^.�D�`�%۸��ҝA��Sos�q�iGq&կ������;K�~i�l�z���ٯ��\\����"SE��+S��o��ZV���\�/t+H^����7�)�Ka��!�E7�s��ωu��,t�j�O��lJA�+4�Tl� +�͌����N~���������Mj,�)�NE\�pQw<�I��f��*)A7b�T�i�� �zx�N�1���]ѤBDS0y���|�=��a>�lĞتM3�d6�q��a��h�n�� +�P%�)6�rI!����Lڷh&�2�ˢ��ܙH�E;�I��29p��4��AN39�)���ӬX���iֳ(&<,N3��&Ub��&�L҃���\O�GͪT aJ0{@��Xsb�s�d��h�h.C�{F���n� +nX�qKJ +���A���9�hl��J���!U����`�DOa��*��E?�jP���e�1zh�[����C̀x���zU�A��㝚��?��7����Vl����=�S�-?�n�̞M=X~ �:���N}���*��*���y?�*#bNOR���r�,���O��A���Ŝ Osd5���'��t��ӟd�CS���~�9�~D�_���t=��v��q\8�E��˵2r�o�ơT������W��"<�Qȋ������H㬃h\v�քw{E���r��ƹ}�q +1WO�,-��q�{L��o�ƹ}�q�[a`��8l7���<�8��y��u����]��e�6�ޱQ3��w�Omu|�H�/'��<���v��2���ΥN%�zBr��E�r�z�5�B�=�m7�������c,��(�'�zJ�����blEU�n��zJ���K��Z��r}c�k�xE��'$�Jf$/o[nF��溭�W����pMmE�ζ���[�mm%�yJ��l�(R��@�Vl��v��,WA +�4J���<����)��Um�:Ǝ��qx�_O����N�$�a1�Q�=9�ǯ�4~WD`�������W4����]�=����輥������3���r��.���h�.��UU��zL��= +ʒRnȠ?gm6�o��h�FCZ%�RC��} +�6�o��Ï+���O�ؠ���x�� Ѝ�iz��o_�k���P;Г�ҒM���KL�'���lMi� �Z��#��d�ABKv�~�UF>��$�/T��rZ� +��G���� +�NZ���~v��ϴ�Ӊ�tf�ߟ̖A�Jn���Ǩ�Ln9�����Z�����˵�U +��-Q���8�U��������od?Lk�#�'��H�*��2�⽡u����L��e���ӝӄ���Fw���*7¼�t�D��r��:�C�R�0��b%uuK�'V��c����*T/3N����!T�ٞ3��K��/Nl�)�诘�C�r_�?�|-�(�>r9}�c��h��0d6�p��i:��&��t��l�����9�}>�)f1M+,�MF�� +M�w��0���i#�·�ӍjH���}��A>�f�]�;K[1�v�e�?Em��h�;�[7�0�e���|}��sD�,w�:����h�����,��l�>O�w��5�X��w�4" +�������j��MoN�9����Q������_N|t�G*_�� "�``�_q�nν������7�o��"�k���8��t���R�A�ka٧�A7���@�8\i��w�>�}�����=�D3�����H���'��1�_+5m.ݙ6����9h�is��$�i�Ǚ��6ɥ���.9A�8ʺ������&��kBm�+��O����|ܔ�`*�N7r���z:�7ˤdov��`D7<K�E{�l��S��jNѡjު�����R�GQs�'�Sg���g�B����q�S������xs+uH��K�������u{{) +�ͼy�� +�=�J�}���Л|��^v�NO*��v睄��:M�~�$�_o[����6S��B���qJ�_N��_�뤟�`���'���ж� +��+�2��l�P^�-G!5�(����jZp�w�QHG�m��Ⱛ���t�QHG�m��8���X���(L!�rR�Q(�Ovv���_��f�T� +�YWaj܈Cw��Ԓ�x��ڒ�*�Bٸ1x�۳.�i�\�6�$�Gɒ���&e��⊹�?E����� +��d����~���)e�!�?N��,^��c� +���J'�wOQ�=���,���,�v�5]�h�EM�&�hc�"7��.�)�Oq¦�q��\���mW�m���S�^���&-:_O�b�!�ȭ�q�+=p�*u�6��Я.�V9NW��wm��^�|L�֖��Q��l��-&�k��r`m An��I�;m��tՓηڦ.XĄ8p(�;.6���M�G<knD��ƫWT��U����q���Ā�s����nύ� +�g�Q8��n��q�7��܈֗4�����M�7��:ߠ�oT�-�s��ķҹ� +��9:����\|��B����=�-�9� 6װ��?2w�X��td��%���~]m��y�'s&�7N�^�9}�5��ɜ�{2gD��xT̒��6��*�]�Wњ3���U�f(�`\����.+iW?q��u���aq���PK�GCY�8PK�hz<pollen_Services.pgml�\�o�8���NSOJR�#]�i��Ӥ�6���4�(8�78i{�?�l |ٸ�I��B�d�1��y^��k?����җ60�QLd0Pd N�����_.��,����y�q��ۧi���]}�� ɴ0p�+���N�V8�-���y�4��^d/1�1r��q�v�:��5\x?��8~����o�}������7U����8�̑=�[�}KQ�s���F1�)� �%��W0� ��ɔԏ�(\��K��S����椗w���v���'я>R{����W6^|E1���dn�1|��0��+��ۉ�2\�Ȧύ� +I���:�E�0��+}@�8�5�{N�,��j��2S�>���I���a4�o#�?`�iZ�5��m��4M.�W��f��J1�������a��AN��DV���}�p�\����m�"o�'2{[U3�ɪ�QJ��n�$�e��}gP���Rw��= ��vY���n�A3K��j���L�&U��3ڛ��5�k����Ecq��{���}�X����F�U#t� +k�w2Bic�$ї�_��y2 +��W�"l�ș��VT߄��TҾc�E�D����9r�t�� �3���/|��~�v&}� +������"ЇJ�à�i��A>>K&��PG?R}��� �<an�nF��3e�<��N��ǧ��+�2QD{Z���f�reGxI�����B�j��$�(Lݡb�&�%��.��?%��.�V�����p�;��b�%~�+�8K�dS�9�ی���NB��r�����<#7�A����zl�y�� �������Alx�8�Ѓ�xK���ߤs�>�q��D`��%0���+�����w�p��ୀ�x'�$���߄�}x]<'i�<>~�rw��q<^������<vS�����v�p�������U�{,��!I�N��/zZn +�H����jj��Ky��Nf��!��$�� ���ܚ L���3�QG������b��Fѡθкq��AV���0J�FB��;�@�#x��@��*oL��06^�>E9N���(�t7�n��P����0��ڴŖ4!E� +�Cvdh�7Q')��A@��A��ʪΎ��ڭ���$�����at�&_���R��#S��Z59'�f�L��%���+�>�v��.�#5(�=��b+����Q(L�+K�-���TN!]��:��_S�5^�5�g��l0>m�'���� +�e�|��'?QP=��1�@�E������oP�h*�~�\dl�Q�C�' +��������P�v�L�n�"w#H�ܨ��l���Os�Oһ���ݪ~�'����"��%x��D�n���C�ś1U�+:�Uz�7�H���F���4o��y�������!z��"�د�-�'�aO��\��R�F�V(� +7��?+4����M�Va��F�� +(�l���� +0�7�X)�VN�9mw� �<y��[�q|F�̱���@̮����.�T�7>����)�`���CK���8������%�!=Cޕ]L/�Ѻ#��b�x�C�9-�����!FgG�y'�G82R/e$WK� +�u��]�NP/��{�|=A��C�� JwΑА��] PNX�.��3,\ڛ0B)��L<&<q~����n�H�/x$b����cb��֨�Z��z��`�h�N9D<x(*��{8�9ԩ����Gӓ�PK5��I��CPK�hz<pollen_Context.pgml�Zmo�H��_��S�J�a�1�خzNZEj���T�N� Â���hY祺��v�g%!�df_`�yfg�y �`�ɨ��^8�%$__�SLYz3>�v�ir���L +}Xp�����$����]f�.�FB�F�߱�O�0I|\b�̞w"ns��q�t���Βt�?~�v������{�b� +���bh�����B����y�@1UU����/H��x$O��;.�A<�]���;��?���9<�y�����G��t5�HB��5���3��4�#�"|�\L�}�?|;ROh��-��'���A���a��EU�)�5�4��Ȝ�ڷp�}�P��G��(�;4�l$��� +�o8?u%I&O��&����0d���8�;.ܮd;�^��A�I���z��}�斸|6���k����tc-*�դ�Z)�((�$Ilj"e��d���V�r�z@�^lY��kn�]�\��:��M3N�!�����<ʠ/�_���r.`d���� +��ۤn��� �����QT¨*��%�G)�n��$����.G2�p@�LJ�g$����4p+B�wD��j���eĉG{!,8s=<~��!k&}�>�c�ݚI�Ln��O�Uf���=�t��ɣ��u���s���l�b�� +�HRa��R�f�=��>��jB����3����mo�M��~�u۩��E{+�=�۶����ĩ��E�ip�3�.9��]$@;e��i+��s�sz�9-�P#�,�"Y�5��+�1�l�����Z=�&ɩF�'�e��;w�=���Sj��]�+�9t�;i � +� Y����7��y��E�ۆB���AC�E�[۹�jg����X{�v���f�[�ܫ��fh/vv�1�`�����a���:2�G������~+5Ōf�0K��̎�CbJi���F(�V(����=|UJ��E1㾮K�0[0��P`��:C��%cpb>�Z#6���\זi��IKM�߶UŨ(hh��\�f��/۳�5E +��I�}��v'�{E��l��{�����[�����ˢ��e�^���E�=o̢Jc�g�� +W=`?:��ҙ�Y�֬Y=�~����5�#�YTh� $C��@�Uo�|X��(kkӢݶic�C�J�N���U}ZT�Ӗ����i�c�=�Fm� +�ھnm���W�*�ڊ7h5�O��o��+[��W.�u+V�f��{X�<�X��B�����+_2K= ��[@��F�AAq��:��%sP��-�5(��C��q�ց�O��:�*?��YGdb��S@h���y'���_������=�}/@�8�6oO�nϷ ����mԴ��w�i劣G$ 5��*���Cp(HM���*KYE+�]��>�@� ��V襜ݚ%G��<�����iz���?��PKd>�7�0'PK�hz<pollen.todo�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��q�(��;�D�*���+G���*(�8z)%)J +@% ���,.2���E���9e�)�E�%��� Y,B3PK4�[-m�PK�hz<pollen_profile.profile�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��qq��e��q��ÙPK7Rp:BPK�hz< +pollen.xmi�]m��6���_��me���LR�$:Y�i��sU���c�~�IHËD�Hjl����ȡ���@|%hw� +��Fw㗿~�m�'���J�|'A��l���/>=��;�o������a��z��ۺ��O���������m���v0�яwR�?C���v+ߑ~���%e�Z�^+i�|�TY���|'I�u�Gl近��m�:���[�_����3�aZ~<x�`hB����|59� +��_^ez��9n�F�ӡ���'ɇONm =�O�ly2����J��u�_��d����G�YB���E�~��$eߚ� zy�a�M;���p+%���h�ߧ'�/�+C��Wo�'=�0��!z��#Q���xfcm0�N�>(�:�����kE��������`*��k9����w���t�G���[��IN�q-g�X�x�Ok� + ��煙/~�`�����`f��T��dG��B̴a6h�L=7{x��0d����L�4Ե�ZQ��ش�dՅ<�;>]��T�S"�6AL�:�y��s�C�o�L��&�v\'�'���#���w�2���%���㜽�2i�(�Q���B���ɼ��`��SEE����Z�M{���Z7 +�ZCH�"k���L�04����n������ �Ѭ��*ɮ�]�dž�-��F|P��lNmY1#Q6F�m[:I����]��/�?z���F��1�?�[�bdIe��/��y�dN��YVX�Kȱ��c����,��a�:ZEx��e���Ⱥ�����O��"B�� <�y����w�CH^�����fD��&d����t�g�?�|�u���}��E�k�M;�X���@����-zL� +ϟsΑ�l��lW1�6t��\�xR�dѤ�]�O�H�UC6�9����Rg��H>[�R����~�����>���fP等s��m2s�Y��ҨI� �-��"%HUu(�� )A�>���7�`z������H�mX����-`���s�a`!` ���`@��alc�4_D�d:QT��IJ��L�"��S�sԺ�S� �OwX c�!���U,k�)�� ��������ohf@��?Y�m+��,^��a���A\��H���Ŗ�C�0��y���T_�s���C� +����սG������G��x����$�*$�z���tJ�vYzZ|��*t���v�e! �.�c�{�eWޙ�P�4G`����J�I�| ��ָ�Q̚�B]<b�9�N��C1�mϚO[��g'�j����ͅ��;��1QMMi&���6l�9!�05�-��}��s3�WhB�Z?�����F�F��<>KK�����#�T���W��������a����+'fA�Y���dp��'��(b�����E��*�NS��=/����s���{��;�oC�9���FA��:���ps|����^���B?}e^�xY��/+���S�$i������F0e:��F&�Wj�?��<R��cA\!F�N�:Z��{�@1�(r�o�!��f��>�E�8k������PR�����ݖ�Y�wpCn�Tz���XQ5�B���L��f����Oo�ۍ�`�h�Q��4�@�L����B/�x�)��Yٹ�&��2}DD���c�g�P���Ep���"+O�4(Yi$�%�=F�</<����#�x-8���)�^%l�\3%ceC��YN�I��� /z���int�1�S���.ӳ���=P���u�}�Po1.B=`��d�s�[���O�A�C��a��(�"��B�+���*��ړS�>>��a�Z�\�����*����4�L��V�B�� �烎���Ө�����/�o2��>r�̃p���/"g8��yY�#�6L0�0գ�t��m2�䃓�n�m�ψ����ɫ�w�nrqPF���S���k�x� +α���sȭ�?zt��Bkq��A�N���2�}���@a2f:�:��#���)�%�u9��p�0�k�ҭh9�����T#ѬMO�E�5C����) GǙ��W�1D;��x-ؓ�m�& �O/ +�?��@��e7�_�>!��W��W_ +�U[o<q����\�P�>qsB�CO���Dbe���^�{�<|��o,�#�G� �eu �a*�u�nu��Inr�(�XҲ��!���ɉ�Z��Xg��{M�I�<U�-��އO�>��Bn�hN�}M� �1�ZT��SC։�eT�~���vUhf�����L�H��t�2]c +����"�rV��F� ������ �Ej +��V,82��;�V�fNU5/��|�G����c��;��2�h� +<Hu�S?�Nk��Bw;�L4�Lm���J��g:( _��@����c�X�ڝ^P�ƅP2�Æ�2-D�M�|���Ġ�v0|�@��6�Na&r$� ݡoND��Wgu`�W ��'^ϞX����N7}�;�/�GI�8m�t��FQ�������N�kp����"o�G���pH����;{,��ت���� ��4m=Rm�$O!\k� ��[��}��@� 7����T ���8n�မ�me&R�t������H�5�"T����|m��+���[��@���tm�,\m��+���[��aC!�I�]�;�5�ޙ��,\m��T:�ĕ���}����ª/��n9$���]}�N�����p�E��W�FX��?����z$�!o; +#�N�#�t�$8�aT���S�8�l} +e9'��0��xw�g/�7��<n3���H_��p5���M��F�˘:�]9 �'&����0���QD����m@�&_1W���b� +#kۄFd:\ +dHc]PNja<����$�t(j᱁幡��B� +Wc"01���J����($C�up���`{(���������|Mj���I�gG+�7�B�_rٮ��n)�YC��fN�&9g���t��+�Fbbl�u��E�2�2zb�Mte.�0^��9��1q9��l x�B8Ǘ%;�F�_;� +�t�� +��PZ�)�O��n�Ϧ P�Sg:ܶ��Rc +ck@`W��A��@G���K���E)v��K4)�ݘsV�����ܘ�(��5��Ɯ<�Y�&no�Q��댐@^���7�Μ47j�B�0�A�_"�VL�!˄�VxXҲ���M�xXm>���B����Ǘ>0�����Rŗ9� +e�XҲ��ɵ�$V��!��Y�"Z�#�'s7q�l_���Y�\�@�m�2 �Sl��f�������a�>4|�x��H1%�R�!$.��.���P�b�9���m7%���{7!���87�1�M3�Oy�L(f�Էh�$��Dc��c��'�V�آ�����U�9E���ݖ�M!���MxMz����M���7�D�bIa���|N�`0��8bc���s�c��8Q�0>s���@cg�Xf"4���m�N�>�D�~j,=���&�tU���R�H��� T� +�z��,�,Y#so�/&���z�k2�1��1�rCU�uT�K��cM��|��9�!��0�גY���69ƙW{�Rk&�59m���s���Ts��v�VζY���FQ�9��*k�L��m�##�?]kk*[�J4�E�!|��ۅ�vSu�:}��@�C�ԁ:��Yx�s�c�&�v�?hF6���x����*pS�/]���E�ހ~�� +F��"�H}�����D�mһ�f������g!�� +V�m��r��u3��Mնuҍs�"���*����*��u� �RN%i���Q�=pC6leqYթ� �ԣ=� �%]��֕��[.�ŷ�'�3Nv�=����X��i�o����ɨNdO���:(2DV9��@�Y�\��eeU���3�饖�4tb̛�T��I��1H��I>l{�M��=qys�^��8G���\��\&(o�W������3����Љ�խF�#��̶w����� +Z�"��,�^�*F�[�vU�JQ�z\�tٍ2V���r��#��fJ�ܖ:��]ulф:v;8[���6�Ø�,*p�8�P,�Bֆ�6�&֡z +<�P��Qb,�1�5ᷢ��{N�4���אa�Ǡ[��#ε3e$���NB;��qɟW#��"��!�-�Ghј�v�Rβδ���DWa��L��WN%�NIՈ'w��fW��k\�=�x+���O�L#8AL7ú�Q���[�Zԭ +�x��0�;e4=Pւ7L�C,l|�����m���9��U�<���h���m�����O{�Pܦ���S�5g��rd_o˭"n�6�V�<��5z,���M�̱�NT*Ei�W}0��n/��'U�x0fo/q!�*F���%��بN��8�D� &��qI�:�\����D +�4y�Е���L��ij�d��o���a/�T,�&1��@�+��`�ϡ�æ���R,��A��C�_��2)$��'��(�s+/�( N5k�O5ɗ�&!�|�j6W����/����C'���s��Ug1�nn@� �'W �}����ˣ0�����܉r�����;p��'�Dkp�ҏ|��!��5e?��_�%!$� =�d�6�k;EW�V8�,�v���zj��w2�� +��[`�Ъң�Vy�i��?����9ѭ�%�5S5 +u�- +�A�ԉ�W�%��O��ʡS�t�n���a!�_�PxK��&bř�X[ +c��5��ʴZ�,�gȿ1��eSi��7x�J{�51���-��zF_�T\86λř����{��B�T'��K� �����^����#C�逤�!�iJ������b����uC��L�]{��r��<S;�L��sKgBg{C�L�;�ӕ�H��}Uȉߜ �a��������p7�{�-t���2|���Y>��a���5"+��d_�q��K�x�Ԉ�Ce~ +�/bne>��[�o���[�*�',���5h,���jL��,�fQ+�6��pVݩŃ��=�<��]��b* +4��p6�ɇ*_���F������Fӹ t�� +��Y�D{�J�,��"��KynmH�c������+��)(IAs�F!i=f�en���U3Ù���a�rO����mo4��D��̉���$Bf��cQ�/3���Y�#�k��B^�&�}�G��;�d����kL�a�� \'�`Z_=e��9198�b����_�f��5�2�"�ڟqVC�Z��Ҋ���Vדh6L]����c�V�&E��F8$�x 4��� +�tH.�fMe�Rg��;PY9���'7�Z��܈?z��K@�Y�<���堀Y��/�mͬzwg�ճbw�hw�uJ +���#&W��U�:י)v��-�O�mu�0��=�/*t�D;.R�2�}U}Օ�5Vr�%శ����X8'��JO���^c!Q�=�CG���'n����larr��,�,T�º�xH��5rn-b��%-[������=FBy^�e�-Za�Z!1/6=%sZ��-̽(R`�5`�0)=����E� 4lC�(8��9-[�bBzr�gY�k������ +�6r|vr�}��g�`�e�H@�@�#{�=P�2��(/�meq_e�1���@�!��{���b�l^?<� �tr��ܢ��7����{���:m`�ݸ+Ϗuv���� +�O���֧�v�PqT�bT��8�)X�m����"q�܌G>�e�#!{1#��_J�>\�q7l�'4�9) +��Gj�K�+�}6 ��o���Չ���ͫD� �3��yf��g�IN�\&c����je��sq`a�#o���&Z?��1L4=3��l�F ��÷� +��2'��~������k��豦Px���PZ����N�EM����E�$O�Q�L"ԄvCbJ�م����@qw�5~/A`p�2�xw���0PLKi�_Õ�TT)XP�a�+Ƨ�l��N��q����r \l��.e�[/�8�1�ۅY�e�q0��!������8V�i��K���JŊ���^F�<?��0[o�t����^Y�l�F����x�P^83�Oqa�a�F�U�r�K�Ox�Y��J�^3"*r�zzl���Y�C�����,�f,������j)��Zz5�V�\��O^����_~s�6lG�_��)��Œ���u��~&1~�I�����R��6������0�"����=q�9��汰4�B`a��P^�/e�����;1 ��fJ��/#��2�pY���~y�\U�#mxHn%?��=�^�d$Nj���F�a�ƙڳ��[CC�t����P�e�*/#��z}�G? +1x��i/풱Y�M�;�s��HQ���'�)ZMT�H��W'cyᅧ�*i(��Z��wC�����qef��~t6.�^Ȁ�� �DžA��j�=y�99�-�DBb���$����q1;ֹ������X.RM�<�9DLs~IN6�����ݎ�'����ڟ������./�.�-w;gۺS� +m�!�� +M�>B ����Vz����S�U�a�������䫁4�m �G��@rv��Y����}��|���;`�osq�M&�>b�9-=�QǗ;g�1��41�����>�����>��/��q��ĝ���!������)5ŋ��PX���K�� b��p`o\�aP��)�9�A��РC�c���7���P��D` +�f/���F|E�JNwi ٢WR��}���.���=��I�M[��YxNT�v\|]��j�ac�*�G<���>U;��C����n%J��v��C��Pl��$g-���%l�n�������!���aƔ��9�f��K���;Hp�p���~��%zz�)����<�����tzxt)Zے�!�X�~��l�����Lc�>��Y�`����(�S���J��9n�1?���3�������-��P��em�F�n�櫮5;57�������P���p�hi$�auaׅ�E�R�I7�I�ό�^�.����]��m���^]�۟o-����ȉ*�/�8J�U*q���-�<9�-�#���o�[���L�:��W�bi�<����v窻�����Qˑ�]��W��O�F�SDpd�#�2�0a9���r�cpa͘PZ�a�zz�[f�F�8콐� +�����{�e5ivf]����QX��ªhժ�-]�U��{ر%q�-�dc4��丱Vd��#a^\�y�r����3O��[�}Do�����B�(jߵ�Q��m��/Jo4��[���q��/L�47�2= ++n`(�ڷ?rk��}�q�D +�z�b|�m'AB�{L +:F +�c��SZ��ٹ�{-��n� ��(�RFD&J�jq�K�!�""��.�T ɍ֮S ���ϰ��`�1��y�E��WW�Q�x�O���H�E�9T!�)�[���*M��!v�� �٪5����ǣ-������<o��"��Wu�2�z��_!R�p:0�0����]��L��}�����H��Ш0e%��$^��-�]'���+ +�I��T�������� �J���qb`RQ�ˣc=FN=� ��2��U�,�?^2���C�߇{X���|��o����[\e谅�9x��|�90����ş�Uy~��/0,����'����&�^T`���G�T腗�`5��cVo\��r�/#� �w�����_/mNXVT赺�k$~�B��� =wx�-�e^Ӳ����1�Ύy����V�<�{�r�#m�a-ٞu8V���tN�pw؆���b�=������>p7yF_����Bz�ح�����t���'��=o�%���:_dU����d�m{v�>.UV�����l� +N�<s�Ԗ�A���d0��XU�@�)�F��.��A� ���� +_0��y�f�\l:i�E��f�&��Rs�Ԉ��}]j�j�nۊe@�y�أ�d�u������1_6@�l�S�K�v�s�,�$����C�N-��\����v�?���v����9�O;��q^`/�wM9������#`�nF�9QT����˘�Ԕ� +pW' #�G�VR�=HAv1T�At�\��n�&/�K���p}�n�Z6��}�%n`D��Ȗͩ-+ft5�12l�"�-/�u.6V��MnMJY�r���e���K���h:�0R#�!T� +��ոN�e�B�g�O'*бA��3��X3&D�G +�]u�\�^bz��Ј�Sy��j�9�V���&K{�b>k�h�0JŖS�5���Sѱ^�Lx�;��y����������o~���AMż�{�|^��� +�+���c>_p��yOW߂�eK��p.V�b�S�-UطT�r��P�q��QO����M�*�\�9�e�ٷRx`ߪ�z� g=㾲��� +z*�.����m�W�mŅ"[m=pY5⭧��lw�Ͽ����9���x����S��B�b�)�]~ʈ����} +��B��PxP^JO�~U�}������B���t�6�FCEׁi�s�y��.��h��Z��r�?��Y#�~�oGF��8e����GF�[~��m�+�qazh}��h<�MZ�۔O��\l�zOO,c.4�q_�.c.�o�W�˔���Ŵ���)�;�k������(�Zq�>.<����k�4�e1�Bxg}�a��y�M'��|���ˬ<J�S�q�r��4Rmq��q�=9Ğ������1��[?~���;�i��b��Q����K�s��,ʋ�qʾ%��8-��~�R'�1�1��\k\=\ij�jL��89��ՄUAK'6mI�&|y�4p↧��Մ>GK'�-��\qR!���[��[�=eE�r��xg]#9.�4pjAKv��4pfAIv#�ݴ4��j5%i�5�5q�CK'1��d�Mm�����6-�MĤ��@���=�8�&�~n:�Ę�m��~���٩��@M��\, +���� o.�� +�bho�b +d��*w��r����*���,�Tp����D�\2 +�x�� �4�zFCW�4�7GFCWqd4�7�CCE�Y�/��#�6L0����t:�ֶL Y��:�\��w�۲�\�������c��<�`yLJ$+u"��;�Jd!������&>�2�j�Z����p�Bsǒ��O2k�˱��ZF��8���O˨������=o,4���`y�eYh�3����zw<�대`y��$�;��rQӢ)�Ʋ�Wٸ���c0w\�9&=� +�6'@�4���6�I��<��Ф$��|S�@�64�_+�x��G�f���֛,�踼�͈'�85��\뭋LpcoF�6�&�y2�(�m�dL�5㍉�>2�!L�N?�� +%�V&`�q| �]�gAmٌ��r�sF�]�g�W�2Ь� +�� (�䙻�@i�Ȏ��,��D��9N� �����4�z1ܜ�U�Y�x�Ttn��(h�x�TZK�oA\H�z�s���ION���O�{0ћ�$'�����v,:��Z�m�/</|����N��L���>���V�<���^��8���!���N������� +�4�(��Yf(�5�`G� +��pDލV�i����v�s���sk#Y^�}#m_��<�m[�� +���⳧}�Yn����E��W���0�� +�|����PK�X��U&g3PK�hz<(�:K/.pollen.argoPK�hz<�GCY�8hpollen_Modèle.pgmlPK�hz<5��I��Cpollen_Services.pgmlPK�hz<d>�7�0'pollen_Context.pgmlPK�hz<4�[-m��$pollen.todoPK�hz<7Rp:B�%pollen_profile.profilePK�hz<�X��U&g3 +&pollen.xmiPK��L \ No newline at end of file Modified: trunk/pollen-ui/pom.xml =================================================================== --- trunk/pollen-ui/pom.xml 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/pom.xml 2010-03-26 14:06:00 UTC (rev 2958) @@ -10,7 +10,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/ContextLink.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -2,7 +2,6 @@ package org.chorem.pollen.ui.base; import java.io.File; -import org.chorem.pollen.business.PollenBusinessException; /** * ContextLink 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/base/Polls.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -34,12 +34,9 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.BeanModelSource; import org.apache.tapestry5.services.Response; -import org.chorem.pollen.business.dto.PollAccountDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServicePoll; -import org.chorem.pollen.business.services.ServicePollAccount; -import org.chorem.pollen.business.services.ServiceResults; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.data.EvenOdd; import org.chorem.pollen.ui.data.AddressBarItem; import org.chorem.pollen.ui.data.PollAction; @@ -62,7 +59,7 @@ @SuppressWarnings("unused") @SessionState @Property - private UserDTO user; + private UserAccount user; @SuppressWarnings("unused") @Property private boolean userExists; @@ -71,13 +68,13 @@ * Liste de sondages de l'utilisateur */ @SuppressWarnings("unused") - private List<PollDTO> polls; + private List<Poll> polls; /** * Sondage servant à l'itération des sondages de la liste */ @Property - private PollDTO poll; + private Poll poll; /** * Objet servant à changer la couleur à chaque ligne de la liste des @@ -122,21 +119,21 @@ /** Injection des services */ @Inject private ServicePoll servicePoll; - @Inject - private ServicePollAccount servicePollAccount; - @Inject - private ServiceResults serviceResults; +// @Inject +// private ServicePollAccount servicePollAccount; +// @Inject +// private ServiceResults serviceResults; /** * Récupération de l'identifiant de modification du sondage. * * @return l'identifiant. */ - public String getAdminId() { - PollAccountDTO creator = servicePollAccount.findPollAccountById(poll - .getCreatorId()); - return poll.getPollUId() + ":" + creator.getAccountUId(); - } +// public String getAdminId() { +// PollAccount creator = servicePollAccount.findPollAccountById(poll +// .getCreatorId()); +// return poll.getPollUId() + ":" + creator.getAccountUId(); +// } /** * Fermeture du sondage. @@ -170,7 +167,7 @@ } confirmPoll.setBackPage(backPage); confirmPoll.setAction(pollAction); - confirmPoll.setPoll(servicePoll.getPoll(pollId)); + confirmPoll.setPoll(poll); return confirmPoll; } @@ -180,21 +177,24 @@ * @return le flux correspondant au fichier */ public Object onActionFromExport(String id) { - final String filename = serviceResults.exportPoll(id); + // FIXME : create service for export - // Retour d'un StreamResponse contenant le fichier XML - return new StreamResponse() { - public String getContentType() { - return "text/xml"; - } - - public InputStream getStream() throws IOException { - return new FileInputStream(new File(filename)); - } - - public void prepareResponse(Response response) { - } - }; +// final String filename = serviceResults.exportPoll(id); +// +// // Retour d'un StreamResponse contenant le fichier XML +// return new StreamResponse() { +// public String getContentType() { +// return "text/xml"; +// } +// +// public InputStream getStream() throws IOException { +// return new FileInputStream(new File(filename)); +// } +// +// public void prepareResponse(Response response) { +// } +// }; + return null; } /** @@ -211,7 +211,7 @@ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), new AddressBarItem(title, null) }; - pollsModel = beanModelSource.createDisplayModel(PollDTO.class, + pollsModel = beanModelSource.createDisplayModel(Poll.class, componentResources.getMessages()); pollsModel.add("functions", null); pollsModel.include("title", "description", "beginChoiceDate", 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Border.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -24,7 +24,6 @@ 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; @@ -35,13 +34,14 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.PersistentLocale; import org.apache.tapestry5.services.Request; -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; -import org.chorem.pollen.business.utils.MD5; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenProperty; +import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.ui.base.ContextLink; import org.chorem.pollen.ui.data.AddressBarItem; +import org.chorem.pollen.MD5; +import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.service.ServiceUser; /** * Classe du Layout Component Border. @@ -129,7 +129,7 @@ */ @SessionState @Property - private UserDTO user; + private UserAccount user; /** * vrai si l'utilisateur s'est identifié, faux sinon @@ -170,7 +170,7 @@ /** Injection des services */ @Inject - private ServiceAuth serviceAuth; + private ServiceUser serviceUser; @InjectComponent private ContextLink feedContext; @@ -189,17 +189,23 @@ * * @return la zone à mettre à jour */ - Object onSuccessFromLoginForm() { - UserDTO userDTO = serviceAuth.getUser(login, MD5.encode(password)); - if (userDTO != null) { - user = userDTO; - feedback.addInfo(messages.get("loginOk")); - } else { + Object onSuccessFromLoginCompForm() { + // Récupération de l'utilisateur identifié + UserAccount current; + try { + current = serviceUser.connect(login, MD5.encode(password)); + if (current != null) { + user = current; + feedback.addInfo(messages.get("loginOk")); + } else { + feedback.addError(messages.get("loginFailed")); + } + } catch (PollenBusinessException ex) { + // TODO feedback.addError(messages.get("loginFailed")); } - return null; + return this; } - /** * Methode appelée lorsque l'utilisateur se déconnecte. L'objet user est * désinstancié (=null). 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FeedContextLink.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -3,9 +3,9 @@ import java.io.File; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.PollenContext; +import org.chorem.pollen.PollenContext; import org.chorem.pollen.ui.base.ContextLink; -import org.chorem.pollen.business.PollenProperty; +import org.chorem.pollen.PollenProperty; /** * FeedLink Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/FileLink.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -16,7 +16,6 @@ package org.chorem.pollen.ui.components; -import org.chorem.pollen.business.PollenBusinessException; import org.chorem.pollen.ui.base.ContextLink; import java.io.File; import java.io.FileInputStream; Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/Image.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,172 +0,0 @@ -/* *##% Pollen - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ - -package org.chorem.pollen.ui.components; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import javax.activation.MimetypesFileTypeMap; - -import org.apache.commons.lang.StringUtils; -import org.apache.tapestry5.ComponentResources; -import org.apache.tapestry5.Link; -import org.apache.tapestry5.StreamResponse; -import org.apache.tapestry5.annotations.Parameter; -import org.apache.tapestry5.ioc.annotations.Inject; -import org.apache.tapestry5.services.Response; -import org.chorem.pollen.business.PollenBusinessException; -import org.slf4j.Logger; - -/** - * Composant qui affiche une image. - * - * Ce composant permet d'afficher une image dynamique (exemple : image uploadée - * sur le serveur par un formulaire). - * - * <pre> - * Utilisation : - * <t:image src="/img/image.png" /> - * Pour afficher une image statique il est préférable d'utiliser : - * <img src="${asset:context:img}/image.png" /> - * </pre> - * - * @author rannou - * @version $Id$ - * @deprecated use links + event + serviceImage depends on page - */ -@Deprecated -public class Image extends ImageContextLink { - - /** Chemin de l'image */ - @Parameter(required = true) - private String src; - - /** Texte alternatif */ - @Parameter - private String alt; - - /** Largeur de l'image */ - @Parameter - private int width; - - /** Hauteur de l'image */ - @Parameter - private int height; - - @Inject - private Logger logger; - - @Inject - private ComponentResources resources; - - /** - * @return the src - */ - public String getSrc() { - return src; - } - - /** - * @return the alt - */ - public String getAlt() { - return alt; - } - - /** - * @return the width - */ - public int getWidth() { - return width; - } - - /** - * @return the height - */ - public int getHeight() { - return height; - } - - /** - * Create a link to call "thumbLink" event. - * - * @return event link - */ - public Link getThumbLink() { - return resources.createEventLink("imageLink", src, width, - height, true); - } - - /** - * Create a link to call "imageLink" event. - * - * @return event link - */ - public Link getImageLink() { - return resources.createEventLink("imageLink", src, width, - height, false); - } - - /** Affichage de l'image */ - public StreamResponse onImageLink(final String src, final int width, - final int height, boolean thumb) { - - // security : src containing .. are filtered, to not access to full system - if (StringUtils.isEmpty(src) || src.contains("..")) { - return null; - } - - File file = getFile(src, thumb); - FileInputStream stream = null; - try { - stream = new FileInputStream(file); - } catch (FileNotFoundException e) { - logger.error("Fichier inexistant : " + file.getAbsolutePath(), e); - } - - MimetypesFileTypeMap mimes = new MimetypesFileTypeMap(); - String type = mimes.getContentType(file); - - return new ImageStreamResponse(stream, type); - } - - /** Création du flux de l'image */ - class ImageStreamResponse implements StreamResponse { - protected String contentType; - protected InputStream stream; - - public ImageStreamResponse(InputStream stream, String contentType) { - this.stream = stream; - this.contentType = contentType; - } - - public String getContentType() { - return contentType; - } - - public InputStream getStream() throws IOException { - return stream; - } - - public void prepareResponse(Response response) { - - } - } -} \ No newline at end of file Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/ImageContextLink.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,91 +0,0 @@ -/* *##% Pollen - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. ##%*/ - -package org.chorem.pollen.ui.components; - -import java.io.File; -import org.apache.tapestry5.annotations.Parameter; -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; - -/** - * ImageContextLink - * - * Created: 4 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * 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_"; - - @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) - */ - @Parameter - private String dir; - - /** - * true for thumbnails images prefixed by {@link Configuration.IMG_DIR} - */ - @Parameter - private boolean thumb; - - @Override - public String getContextPath() { - return pollen.getProperty(PollenProperty.IMG_DIR); - } - - @Override - public File getFile(String filename) { - return getFile(filename, thumb); - } - - public File getFile(String filename, boolean thumb) { - if (thumb) { - filename = THUMB_PREFIX + filename; - } - return new File(getImageDir(), filename); - } - - /** - * Get the directory where are uploaded the images from the context. - * @return a File corresponding to the image directory - * @ - */ - public File getImageDir() { - File result = null; - if (dir != null && !dir.isEmpty()) { - result = new File(getContextPath(), dir); - } else { - result = new File(getContextPath()); - } - return result; - } - -} Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/LoginComponent.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -16,15 +16,18 @@ package org.chorem.pollen.ui.components; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.tapestry5.annotations.Component; import org.apache.tapestry5.annotations.IncludeStylesheet; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServiceAuth; -import org.chorem.pollen.business.utils.MD5; +import org.chorem.pollen.MD5; +import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServiceUser; /** * Formulaire d'identification. Formulaire que l'utilisateur doit remplir pour @@ -45,7 +48,7 @@ */ @SuppressWarnings("unused") @SessionState - private UserDTO user; + private UserAccount user; @SuppressWarnings("unused") @Property private boolean userExists; @@ -67,7 +70,7 @@ /** Injection des services */ @Inject - private ServiceAuth serviceAuth; + private ServiceUser serviceUser; /** * Methode appelée lorsque l'utilisateur s'identifie @@ -75,13 +78,17 @@ * @return la zone à mettre à jour */ Object onSuccessFromLoginCompForm() { - // Récupération de l'utilisateur identifié - UserDTO userDTO = serviceAuth.getUser(loginComp, MD5 - .encode(passwordComp)); - if (userDTO != null) { - user = userDTO; - } else { + UserAccount current; + try { + current = serviceUser.connect(loginComp, MD5.encode(passwordComp)); + if (current != null) { + user = current; + } else { + feedback.addError(messages.get("loginFailed")); + } + } catch (PollenBusinessException ex) { + // TODO feedback.addError(messages.get("loginFailed")); } return this; 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/ChoiceField.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -4,11 +4,10 @@ import java.util.Date; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.lang.StringUtils; -import org.apache.tapestry5.Block; import org.apache.tapestry5.upload.services.UploadedFile; -import org.chorem.pollen.business.dto.ChoiceDTO; -import org.chorem.pollen.business.dto.PollDTO; import org.chorem.pollen.common.ChoiceType; +import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.Poll; import org.chorem.pollen.ui.services.ServiceImage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,11 +35,11 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ChoiceField extends ChoiceDTO { +public class ChoiceField { private static final Logger log = LoggerFactory.getLogger(ChoiceField.class); - protected ChoiceType type; + protected Choice choice; protected Date date; @@ -56,7 +55,7 @@ } - public ChoiceField(PollDTO poll) { + public ChoiceField(Poll poll) { switch (poll.getChoiceType()) { case DATE: setDateType(); @@ -65,35 +64,36 @@ setTextType(); break; case IMAGE: - setImageType(poll.getPollUId()); + setImageType(poll.getUId()); } } - public ChoiceField(PollDTO poll, ChoiceDTO dto) { + public ChoiceField(Poll poll, Choice choice) { this(poll); + this.choice = choice; if (log.isDebugEnabled()) { log.debug("Instanciate ChoiceField : " + - "type = " + poll.getChoiceType() + - " _ name = " + dto.getName()); + "type = " + getChoiceType() + + " _ name = " + getName()); } - switch (poll.getChoiceType()) { + switch (getChoiceType()) { case DATE: - setDate(new Date(Long.parseLong(dto.getName()))); + setDate(new Date(Long.parseLong(choice.getName()))); break; case TEXT: - setText(dto.getName()); + setText(choice.getName()); break; case IMAGE: - setImageFileName(dto.getName()); + setImageFileName(choice.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()); +// setDescription(dto.getDescription()); +// setHidden(dto.getHidden()); +// setTopiaId(dto.getTopiaId()); +// setValidate(dto.getValidate()); +//// setPollUId(dto.getPollUId()); +// setName(dto.getName()); +// //setValue(dto.getValue()); +// //setVoteId(dto.getVoteId()); } /** @@ -141,7 +141,7 @@ * @see #saveName() */ public void setDateType() { - this.type = ChoiceType.DATE; + setChoiceType(ChoiceType.DATE); image = null; } @@ -153,7 +153,7 @@ * @see #saveName() */ public void setImageType(String pollUId) { - this.type = ChoiceType.IMAGE; + setChoiceType(ChoiceType.IMAGE); imageDir = pollUId; date = null; } @@ -162,15 +162,11 @@ * Change type of the choice to text type. */ public void setTextType() { - this.type = ChoiceType.TEXT; + setChoiceType(ChoiceType.TEXT); date = null; image = null; } - public ChoiceType getType() { - return type; - } - public void setDate(Date date) { this.date = date; } @@ -230,7 +226,7 @@ */ public void saveName(ServiceImage serviceImage) { String name = ""; - switch (type) { + switch (getChoiceType()) { case DATE: name = String.valueOf(getDate().getTime()); break; @@ -260,4 +256,30 @@ } setName(name); } + + public void setName(String name) { + choice.setName(name); + } + + public void setDescription(String description) { + choice.setDescription(description); + } + + public void setChoiceType(ChoiceType choiceType) { + choice.setChoiceType(choiceType); + } + + public String getName() { + return choice.getName(); + } + + public String getDescription() { + return choice.getDescription(); + } + + public ChoiceType getChoiceType() { + return choice.getChoiceType(); + } + + } 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollHelper.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -16,19 +16,6 @@ package org.chorem.pollen.ui.data; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.chorem.pollen.business.dto.ChoiceDTO; -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.VotingListDTO; -import org.chorem.pollen.common.ChoiceType; -import org.chorem.pollen.ui.data.uio.DateChoiceUIO; -import org.chorem.pollen.ui.data.uio.ImageChoiceUIO; - /** * Gestion de la copie d'un sondage existant pour en créer un nouveau. * @@ -43,150 +30,150 @@ * @param oldPoll le sondage existant * @return le nouveau sondage */ - public static PollDTO getPoll(PollDTO oldPoll) { - PollDTO newPoll = new PollDTO(); - newPoll.setTitle(oldPoll.getTitle()); - newPoll.setDescription(oldPoll.getDescription()); - newPoll.setBeginChoiceDate(oldPoll.getBeginChoiceDate()); - newPoll.setBeginDate(oldPoll.getBeginDate()); - newPoll.setEndDate(oldPoll.getEndDate()); - newPoll.setAnonymous(oldPoll.isAnonymous()); - newPoll.setAnonymousVoteAllowed(oldPoll.isAnonymousVoteAllowed()); - newPoll.setPublicResults(oldPoll.isPublicResults()); - newPoll.setContinuousResults(oldPoll.isContinuousResults()); - newPoll.setChoiceAddAllowed(oldPoll.isChoiceAddAllowed()); - newPoll.setMaxChoiceNb(oldPoll.getMaxChoiceNb()); - newPoll.setChoiceType(oldPoll.getChoiceType()); - newPoll.setPollType(oldPoll.getPollType()); - newPoll.setVoteCounting(oldPoll.getVoteCounting()); - return newPoll; - } - - /** - * Création de listes de votants à partir d'un sondage existant. - * - * @param oldPoll le sondage existant - * @return les listes de votants - */ - public static List<VotingListDTO> getVotingLists(PollDTO oldPoll) { - List<VotingListDTO> votingLists = new ArrayList<VotingListDTO>(); - for (VotingListDTO oldList : oldPoll.getVotingListDTOs()) { - VotingListDTO votingList = new VotingListDTO(); - votingList.setName(oldList.getName()); - votingList.setWeight(oldList.getWeight()); - votingList.setPollAccountDTOs(getPollAccounts(oldList)); - votingLists.add(votingList); - } - return votingLists; - } - - private static List<PollAccountDTO> getPollAccounts(VotingListDTO oldList) { - List<PollAccountDTO> pollAccounts = new ArrayList<PollAccountDTO>(); - for (PollAccountDTO oldAccount : oldList.getPollAccountDTOs()) { - PollAccountDTO pollAccount = new PollAccountDTO(); - pollAccount.setVotingId(oldAccount.getVotingId()); - pollAccount.setEmail(oldAccount.getEmail()); - pollAccount.setWeight(oldAccount.getWeight()); - pollAccounts.add(pollAccount); - } - return pollAccounts; - } - - /** - * Création de choix de type Texte à partir d'un sondage existant. - * - * @param oldPoll le sondage existant - * @return les choix - */ - public static List<ChoiceDTO> getTextChoices(PollDTO oldPoll) { - List<ChoiceDTO> choices = new ArrayList<ChoiceDTO>(); - if (oldPoll.getChoiceType() == ChoiceType.TEXT) { - for (ChoiceDTO oldChoice : oldPoll.getChoices()) { - ChoiceDTO choice = new ChoiceDTO(); - choice.setName(oldChoice.getName()); - choice.setDescription(oldChoice.getDescription()); - choices.add(choice); - } - } - return choices; - } - - /** - * Création de choix de type Date à partir d'un sondage existant. - * - * @param oldPoll le sondage existant - * @return les choix - */ - public static List<DateChoiceUIO> getDateChoices(PollDTO oldPoll) { - List<DateChoiceUIO> choices = new ArrayList<DateChoiceUIO>(); - if (oldPoll.getChoiceType() == ChoiceType.DATE) { - for (ChoiceDTO oldChoice : oldPoll.getChoices()) { - DateChoiceUIO choice = new DateChoiceUIO(); - choice.setName(oldChoice.getName()); - choice.setDescription(oldChoice.getDescription()); - Date date = new Date(Long.valueOf(choice.getName())); - choice.setDate(date); - choices.add(choice); - } - } - return choices; - } - - /** - * Création de choix de type Image à partir d'un sondage existant. - * - * @param oldPoll le sondage existant - * @return les choix - */ - public static List<ImageChoiceUIO> getImageChoices(PollDTO oldPoll) { - List<ImageChoiceUIO> choices = new ArrayList<ImageChoiceUIO>(); - if (oldPoll.getChoiceType() == ChoiceType.IMAGE) { - /*for (ChoiceDTO oldChoice : oldPoll.getChoiceDTOs()) { - ImageChoiceUIO choice = new ImageChoiceUIO(); - choice.setName(oldChoice.getName()); - choice.setDescription(oldChoice.getDescription()); - //TODO copie des images de l'ancien sondage et initialisation UploadedFile - choices.add(choice); - }*/ - } - return choices; - } - - /** - * Création de la règle de notification à partir d'un sondage existant. - * - * @param oldPoll le sondage existant - * @return la règle - */ - public static PreventRuleDTO getNotificationPreventRule(PollDTO oldPoll) { - PreventRuleDTO preventRule = new PreventRuleDTO(); - for (PreventRuleDTO oldRule : oldPoll.getPreventRuleDTOs()) { - if ("vote".equals(oldRule.getScope())) { - preventRule.setScope(oldRule.getScope()); - preventRule.setSensibility(oldRule.getSensibility()); - preventRule.setRepeated(oldRule.isRepeated()); - preventRule.setMethod(oldRule.getMethod()); - } - } - return preventRule; - } - - /** - * Création de la règle de rappel à partir d'un sondage existant. - * - * @param oldPoll le sondage existant - * @return la règle - */ - public static PreventRuleDTO getReminderPreventRule(PollDTO oldPoll) { - PreventRuleDTO preventRule = new PreventRuleDTO(); - for (PreventRuleDTO oldRule : oldPoll.getPreventRuleDTOs()) { - if ("rappel".equals(oldRule.getScope())) { - preventRule.setScope(oldRule.getScope()); - preventRule.setSensibility(oldRule.getSensibility()); - preventRule.setRepeated(oldRule.isRepeated()); - preventRule.setMethod(oldRule.getMethod()); - } - } - return preventRule; - } +// public static PollDTO getPoll(PollDTO oldPoll) { +// PollDTO newPoll = new PollDTO(); +// newPoll.setTitle(oldPoll.getTitle()); +// newPoll.setDescription(oldPoll.getDescription()); +// newPoll.setBeginChoiceDate(oldPoll.getBeginChoiceDate()); +// newPoll.setBeginDate(oldPoll.getBeginDate()); +// newPoll.setEndDate(oldPoll.getEndDate()); +// newPoll.setAnonymous(oldPoll.isAnonymous()); +// newPoll.setAnonymousVoteAllowed(oldPoll.isAnonymousVoteAllowed()); +// newPoll.setPublicResults(oldPoll.isPublicResults()); +// newPoll.setContinuousResults(oldPoll.isContinuousResults()); +// newPoll.setChoiceAddAllowed(oldPoll.isChoiceAddAllowed()); +// newPoll.setMaxChoiceNb(oldPoll.getMaxChoiceNb()); +// newPoll.setChoiceType(oldPoll.getChoiceType()); +// newPoll.setPollType(oldPoll.getPollType()); +// newPoll.setVoteCounting(oldPoll.getVoteCounting()); +// return newPoll; +// } +// +// /** +// * Création de listes de votants à partir d'un sondage existant. +// * +// * @param oldPoll le sondage existant +// * @return les listes de votants +// */ +// public static List<VotingListDTO> getVotingLists(PollDTO oldPoll) { +// List<VotingListDTO> votingLists = new ArrayList<VotingListDTO>(); +// for (VotingListDTO oldList : oldPoll.getVotingListDTOs()) { +// VotingListDTO votingList = new VotingListDTO(); +// votingList.setName(oldList.getName()); +// votingList.setWeight(oldList.getWeight()); +// votingList.setPollAccountDTOs(getPollAccounts(oldList)); +// votingLists.add(votingList); +// } +// return votingLists; +// } +// +// private static List<PollAccountDTO> getPollAccounts(VotingListDTO oldList) { +// List<PollAccountDTO> pollAccounts = new ArrayList<PollAccountDTO>(); +// for (PollAccountDTO oldAccount : oldList.getPollAccountDTOs()) { +// PollAccountDTO pollAccount = new PollAccountDTO(); +// pollAccount.setVotingId(oldAccount.getVotingId()); +// pollAccount.setEmail(oldAccount.getEmail()); +// pollAccount.setWeight(oldAccount.getWeight()); +// pollAccounts.add(pollAccount); +// } +// return pollAccounts; +// } +// +// /** +// * Création de choix de type Texte à partir d'un sondage existant. +// * +// * @param oldPoll le sondage existant +// * @return les choix +// */ +// public static List<ChoiceDTO> getTextChoices(PollDTO oldPoll) { +// List<ChoiceDTO> choices = new ArrayList<ChoiceDTO>(); +// if (oldPoll.getChoiceType() == ChoiceType.TEXT) { +// for (ChoiceDTO oldChoice : oldPoll.getChoices()) { +// ChoiceDTO choice = new ChoiceDTO(); +// choice.setName(oldChoice.getName()); +// choice.setDescription(oldChoice.getDescription()); +// choices.add(choice); +// } +// } +// return choices; +// } +// +// /** +// * Création de choix de type Date à partir d'un sondage existant. +// * +// * @param oldPoll le sondage existant +// * @return les choix +// */ +// public static List<DateChoiceUIO> getDateChoices(PollDTO oldPoll) { +// List<DateChoiceUIO> choices = new ArrayList<DateChoiceUIO>(); +// if (oldPoll.getChoiceType() == ChoiceType.DATE) { +// for (ChoiceDTO oldChoice : oldPoll.getChoices()) { +// DateChoiceUIO choice = new DateChoiceUIO(); +// choice.setName(oldChoice.getName()); +// choice.setDescription(oldChoice.getDescription()); +// Date date = new Date(Long.valueOf(choice.getName())); +// choice.setDate(date); +// choices.add(choice); +// } +// } +// return choices; +// } +// +// /** +// * Création de choix de type Image à partir d'un sondage existant. +// * +// * @param oldPoll le sondage existant +// * @return les choix +// */ +// public static List<ImageChoiceUIO> getImageChoices(PollDTO oldPoll) { +// List<ImageChoiceUIO> choices = new ArrayList<ImageChoiceUIO>(); +// if (oldPoll.getChoiceType() == ChoiceType.IMAGE) { +// /*for (ChoiceDTO oldChoice : oldPoll.getChoiceDTOs()) { +// ImageChoiceUIO choice = new ImageChoiceUIO(); +// choice.setName(oldChoice.getName()); +// choice.setDescription(oldChoice.getDescription()); +// //TODO copie des images de l'ancien sondage et initialisation UploadedFile +// choices.add(choice); +// }*/ +// } +// return choices; +// } +// +// /** +// * Création de la règle de notification à partir d'un sondage existant. +// * +// * @param oldPoll le sondage existant +// * @return la règle +// */ +// public static PreventRuleDTO getNotificationPreventRule(PollDTO oldPoll) { +// PreventRuleDTO preventRule = new PreventRuleDTO(); +// for (PreventRuleDTO oldRule : oldPoll.getPreventRuleDTOs()) { +// if ("vote".equals(oldRule.getScope())) { +// preventRule.setScope(oldRule.getScope()); +// preventRule.setSensibility(oldRule.getSensibility()); +// preventRule.setRepeated(oldRule.isRepeated()); +// preventRule.setMethod(oldRule.getMethod()); +// } +// } +// return preventRule; +// } +// +// /** +// * Création de la règle de rappel à partir d'un sondage existant. +// * +// * @param oldPoll le sondage existant +// * @return la règle +// */ +// public static PreventRuleDTO getReminderPreventRule(PollDTO oldPoll) { +// PreventRuleDTO preventRule = new PreventRuleDTO(); +// for (PreventRuleDTO oldRule : oldPoll.getPreventRuleDTOs()) { +// if ("rappel".equals(oldRule.getScope())) { +// preventRule.setScope(oldRule.getScope()); +// preventRule.setSensibility(oldRule.getSensibility()); +// preventRule.setRepeated(oldRule.isRepeated()); +// preventRule.setMethod(oldRule.getMethod()); +// } +// } +// return preventRule; +// } } Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/DateChoiceUIO.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/DateChoiceUIO.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/DateChoiceUIO.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,41 +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.data.uio; - -import java.util.Date; - -import org.chorem.pollen.business.dto.ChoiceDTO; - -/** - * Classe représentant un choix de type Date. Un DateChoiceUIO est un Choice - * avec un champs date supplémentaire permettant à l'interface de gérer la date. - * - * @author kmorin - * @version $Id$ - */ -public class DateChoiceUIO extends ChoiceDTO { - - private Date date; - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } -} Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/ImageChoiceUIO.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/ImageChoiceUIO.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/uio/ImageChoiceUIO.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,40 +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.data.uio; - -import org.apache.tapestry5.upload.services.UploadedFile; -import org.chorem.pollen.business.dto.ChoiceDTO; - -/** - * Classe représentant un choix de type Image. Un ImageChoiceUIO est un Choice - * avec un champs img supplémentaire permettant de gérer l'upload du fichier. - * - * @author kmorin - * @version $Id$ - */ -public class ImageChoiceUIO extends ChoiceDTO { - - private UploadedFile img; - - public UploadedFile getImg() { - return img; - } - - public void setImg(UploadedFile img) { - this.img = img; - } -} Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/PollsAdmin.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -24,9 +24,9 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServicePoll; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.base.Polls; import org.chorem.pollen.ui.components.FeedBack; @@ -48,7 +48,7 @@ * Objet de session représentant l'utilisateur identifié. */ @SessionState - private UserDTO user; + private UserAccount user; private boolean userExists; /** @@ -56,7 +56,7 @@ */ @SuppressWarnings("unused") @Property - private List<PollDTO> polls; + private List<Poll> polls; /** * Messages. @@ -74,10 +74,10 @@ @Override public void onActivate() { super.onActivate(); - polls = servicePoll.selectPolls(null); + polls = servicePoll.getAllPolls(); // Affichage des erreurs - if (userExists && !user.isAdministrator()) { + if (userExists && !user.getAdmin()) { feedback.addError(messages.get("userNotAllowed")); } } 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/admin/UsersAdmin.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -31,16 +31,13 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -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; -import org.chorem.pollen.business.services.ServiceList; -import org.chorem.pollen.business.services.ServiceUser; -import org.chorem.pollen.business.utils.MD5; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenProperty; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.mail.PreventRuleManager; +import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.ui.utils.PasswordGenerator; /** * Classe d'administration des comptes utilisateurs. Si l'utilisateur n'est pas @@ -67,7 +64,7 @@ */ @SessionState @Property - private UserDTO user; + private UserAccount user; @Property private boolean userExists; @@ -90,13 +87,13 @@ */ @Property @Persist - private List<UserDTO> accounts; + private List<UserAccount> accounts; /** * Utilisateur courant. */ @Property - private UserDTO account; + private UserAccount account; /** * Ressources de la page. @@ -113,15 +110,15 @@ /** Injection des services */ @Inject private ServiceUser serviceUser; - @Inject - private ServiceList serviceList; +// @Inject +// private ServiceList serviceList; /** * Initialisation du formulaire. */ public void onPrepareFromUsersForm() { if (accounts == null) { - accounts = serviceUser.selectUsers(null); + accounts = serviceUser.getUsers(); } } @@ -129,20 +126,24 @@ * Méthode appelée lors de la soumission du formulaire. */ public Object onSuccessFromUsersForm() { - for (UserDTO usr : accounts) { - if (serviceUser.findUserById(usr.getId()) != null) { - serviceUser.updateUser(usr); - } else { - String password = PasswordGenerator.generate(8); - if (serviceUser.createUser(usr, MD5.encode(password)) != null) { - feedback.addInfo(messages.format("userCreated", usr - .getLogin())); - sendMailNotification(usr, password); - } else { - feedback.addError(messages.format("userNotCreated", usr - .getLogin())); - } - } + for (UserAccount usr : accounts) { + serviceUser.createUpdateUser(usr); + + // FIXME : test and refactor to manage errors + +// if (serviceUser.findUserById(usr.getId()) != null) { +// serviceUser.createUpdateUser(usr); +// } else { +// String password = PasswordGenerator.generate(8); +// if (serviceUser.createUser(usr, MD5.encode(password)) != null) { +// feedback.addInfo(messages.format("userCreated", usr +// .getLogin())); +// sendMailNotification(usr, password); +// } else { +// feedback.addError(messages.format("userNotCreated", usr +// .getLogin())); +// } +// } } feedback.addInfo(messages.get("dataSaved")); resources.discardPersistentFieldChanges(); @@ -152,44 +153,47 @@ /** * Méthode appelée lors de l'ajout d'un utilisateur. */ - Object onAddRowFromUsersLoop() { - UserDTO usr = new UserDTO(); - usr.setId(String.valueOf(System.nanoTime())); - accounts.add(usr); - return usr; - } +// Object onAddRowFromUsersLoop() { +// // FIXME : wtf ? +// +// +// UserAccount usr = new UserAccountImpl(); +// //usr.setId(String.valueOf(System.nanoTime())); +// accounts.add(usr); +// return usr; +// } /** * Méthode appelée lors de la suppression d'un utilisateur. */ - void onRemoveRowFromUsersLoop(UserDTO usr) { - if (serviceUser.findUserById(usr.getId()) != null) { +// void onRemoveRowFromUsersLoop(UserAccount usr) { +// if (serviceUser.findUserById(usr.getId()) != null) { +// +// // suppression des listes de votants de l'utilisateur +// serviceList.deletePersonLists(usr.getId()); +// +// // suppression de l'utilisateur +// if (serviceUser.deleteUser(usr)) { +// accounts.remove(usr); +// } +// } else { +// accounts.remove(usr); +// } +// } - // suppression des listes de votants de l'utilisateur - serviceList.deletePersonLists(usr.getId()); - - // suppression de l'utilisateur - if (serviceUser.deleteUser(usr)) { - accounts.remove(usr); - } - } else { - accounts.remove(usr); - } - } - /** * Encoder permettant de transformer un ID en user. */ - public ValueEncoder<UserDTO> getUserEncoder() { - return new ValueEncoder<UserDTO>() { + public ValueEncoder<UserAccount> getUserEncoder() { + return new ValueEncoder<UserAccount>() { - public String toClient(UserDTO value) { - return value.getId(); + public String toClient(UserAccount value) { + return value.getTopiaId(); } - public UserDTO toValue(String key) { - for (UserDTO usr : accounts) { - if (key.equals(usr.getId())) { + public UserAccount toValue(String key) { + for (UserAccount usr : accounts) { + if (key.equals(usr.getTopiaId())) { return usr; } } @@ -203,7 +207,7 @@ private PollenContext pollen; /** Envoi du mail de notification */ - private void sendMailNotification(UserDTO newUser, String password) { + private void sendMailNotification(UserAccount newUser, String password) { Map<String, String> data = new HashMap<String, String>(); data.put("host", pollen.getProperty(PollenProperty.EMAIL_HOST)); data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT)); @@ -225,7 +229,7 @@ */ public boolean isMyAccount() { if (userExists) { - return user.getId().equals(account.getId()); + return user.equals(account); } return false; } @@ -236,7 +240,7 @@ public void onActivate() { // Affichage des erreurs - if (userExists && !user.isAdministrator()) { + if (userExists && !user.getAdmin()) { feedback.addError(messages.get("userNotAllowed")); } } @@ -245,7 +249,7 @@ * Initialisation de l'affichage. */ public void setupRender() { - accounts = serviceUser.selectUsers(null); + accounts = serviceUser.getUsers(); address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), new AddressBarItem(title, null) }; 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CloseValidation.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -24,9 +24,10 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.PollAccountDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.services.ServicePollAccount; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; @@ -55,13 +56,13 @@ * Sondage créé */ @Persist - private PollDTO poll; + private Poll poll; /** * Créateur du sondage */ @Property - private PollAccountDTO creator; + private PollAccount creator; @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property @@ -77,14 +78,16 @@ /** Injection des services */ @Inject - private ServicePollAccount servicePollAccount; + private ServicePoll servicePoll; + @Inject + private ServiceUser serviceUser; /** * Retoure le sondage créé * * @return poll */ - public PollDTO getPoll() { + public Poll getPoll() { return poll; } @@ -93,7 +96,7 @@ * * @param poll la nouvelle valeur de l'attribut poll */ - public void setPoll(PollDTO poll) { + public void setPoll(Poll poll) { this.poll = poll; } @@ -103,11 +106,11 @@ * @return l'identifiant. */ public String getAdminId() { - return poll.getPollUId() + ":" + creator.getAccountUId(); + return poll.getUId() + ":" + creator.getUId(); } void onActivate() { - creator = servicePollAccount.findPollAccountById(poll.getCreatorId()); + creator = poll.getCreator(); feedback.addInfo(messages.get("closed")); } 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ConfirmPoll.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -25,9 +25,9 @@ import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.ChoiceDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.services.ServicePoll; +import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.data.AddressBarItem; import org.chorem.pollen.ui.data.PollAction; @@ -41,7 +41,7 @@ public class ConfirmPoll { @Persist - private PollDTO poll; + private Poll poll; @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property @@ -72,11 +72,11 @@ @Inject private ServicePoll servicePoll; - public PollDTO getPoll() { + public Poll getPoll() { return poll; } - public void setPoll(PollDTO poll) { + public void setPoll(Poll poll) { this.poll = poll; } @@ -114,9 +114,11 @@ * @return la page de validation de cloture */ private Object closePoll() { - for (ChoiceDTO choice : poll.getChoices()) { - choice.setValidate(true); - } + // FIXME : carefull, validate attribute is not keep from 1.0 + +// for (Choice choice : poll.getChoice()) { +// choice.setValidate(true); +// } Date now = new Date(); if (poll.getEndDate() == null || now.before(poll.getEndDate())) { poll.setEndDate(now); @@ -133,7 +135,7 @@ * @return la page des sondages */ private Object deletePoll() { - servicePoll.deletePoll(poll.getId()); + servicePoll.deletePoll(poll); return backPage; } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/CreationValidation.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -24,11 +24,11 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.PollAccountDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.services.ServicePollAccount; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; +import org.chorem.pollen.votecounting.dto.PollDTO; /** * Classe de la page de confirmation de la création d'un sondage. @@ -55,13 +55,13 @@ * Sondage créé */ @Persist - private PollDTO poll; + private Poll poll; /** * Créateur du sondage */ @Property - private PollAccountDTO creator; + private PollAccount creator; @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property @@ -75,16 +75,16 @@ @Inject private Messages messages; - /** Injection des services */ - @Inject - private ServicePollAccount servicePollAccount; +// /** Injection des services */ +// @Inject +// private ServicePollAccount servicePollAccount; /** * Retoure le sondage créé * * @return poll */ - public PollDTO getPoll() { + public Poll getPoll() { return poll; } @@ -93,7 +93,7 @@ * * @param poll la nouvelle valeur de l'attribut poll */ - public void setPoll(PollDTO poll) { + public void setPoll(Poll poll) { this.poll = poll; } @@ -103,11 +103,11 @@ * @return l'identifiant. */ public String getAdminId() { - return poll.getPollUId() + ":" + creator.getAccountUId(); + return poll.getUId() + ":" + creator.getUId(); } void onActivate() { - creator = servicePollAccount.findPollAccountById(poll.getCreatorId()); + creator = poll.getCreator(); feedback.addInfo(messages.get("created")); } Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ImageDisplay.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,124 +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 org.apache.tapestry5.BindingConstants; -import org.apache.tapestry5.annotations.InjectComponent; -import org.apache.tapestry5.annotations.Parameter; -import org.apache.tapestry5.annotations.Persist; -import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.ioc.Messages; -import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.ChoiceDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.ui.components.ImageContextLink; -import org.chorem.pollen.ui.data.AddressBarItem; - -/** - * Classe de la page de visualisation d'une image. - * - * @author rannou - * @version $Id$ - * - * @deprecated not used anymore (displayed by ligthbox now) - */ -public class ImageDisplay { - - @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") - @Property - private String title; - - @SuppressWarnings("unused") - @Property - private AddressBarItem[] address; - - @Inject - private Messages messages; - - /** Sondage */ - @Persist - private PollDTO poll; - - /** Identifiant du choix */ - @Persist - private String choiceId; - - /** Chaine définissant le style de la page */ - @Persist - private String pageStyle; - - /** Choix */ - @Property - private ChoiceDTO choice; - - @InjectComponent - private ImageContextLink imgContext; - - public ImageContextLink getImgContext() { - return imgContext; - } - - public PollDTO getPoll() { - return poll; - } - - public void setPoll(PollDTO poll) { - this.poll = poll; - } - - public String getChoiceId() { - return choiceId; - } - - public void setChoiceId(String choiceId) { - this.choiceId = choiceId; - } - - public String getPageStyle() { - if (pageStyle == null) { - pageStyle = "Index"; - } - return pageStyle; - } - - public void setPageStyle(String pageStyle) { - this.pageStyle = pageStyle; - } - - /** - * Initialisation de la page - */ - void onActivate() { - choice = new ChoiceDTO(); - for (ChoiceDTO c : poll.getChoices()) { - if (choiceId.equals(c.getId())) { - choice = c; - } - } - } - - /** - * Initialisation de l'affichage - */ - void setupRender() { - address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), - new AddressBarItem(title, null), new AddressBarItem(messages.get("title2"), null) }; - } - -} 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/ModificationValidation.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -24,9 +24,8 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.PollAccountDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.services.ServicePollAccount; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.AddressBarItem; @@ -55,13 +54,13 @@ * Sondage créé */ @Persist - private PollDTO poll; + private Poll poll; /** * Créateur du sondage */ @Property - private PollAccountDTO creator; + private PollAccount creator; @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") @Property @@ -76,15 +75,15 @@ private Messages messages; /** Injection des services */ - @Inject - private ServicePollAccount servicePollAccount; +// @Inject +// private ServicePollAccount servicePollAccount; /** * Retourne le sondage créé * * @return poll */ - public PollDTO getPoll() { + public Poll getPoll() { return poll; } @@ -93,7 +92,7 @@ * * @param poll la nouvelle valeur de l'attribut poll */ - public void setPoll(PollDTO poll) { + public void setPoll(Poll poll) { this.poll = poll; } @@ -103,11 +102,13 @@ * @return l'identifiant. */ public String getAdminId() { - return poll.getPollUId() + ":" + creator.getAccountUId(); + // FIXME : user PollUri + + return poll.getUId() + ":" + creator.getUId(); } - void onActivate() { - creator = servicePollAccount.findPollAccountById(poll.getCreatorId()); + void onActivate() { + creator = poll.getCreator(); feedback.addInfo(messages.get("modified")); } Deleted: 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,1291 +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.io.IOException; -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.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; -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.services.ServiceImage; -import org.chorem.pollen.ui.utils.FeedUtil; -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$ - */ -@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() throws FileUploadException { - 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.getChoices().add(choice); - } - } - } else if (isDateChoices()) { - for (DateChoiceUIO choice : dateTypeChoices) { - if (choice.getDate() != null) { - choice.setValidate(true); - choice.setName(String.valueOf(choice.getDate().getTime())); - poll.getChoices().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.getChoices().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.getChoices().size()) { - poll.setMaxChoiceNb(poll.getChoices().size()); - } - - return true; - } - - @Inject - private ServiceImage serviceImage; - - /** - * Création du sondage. - */ - private void createPoll() throws FileUploadException { - - - // 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) { - 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 : - //poll = servicePoll.findPollById(poll.getId()); - - // Mise à jour du flux Atom et envoi d'un mail de confirmation - addFeedEntry(); - - // on les passe en parametres car au - // moment de l'execution du thread, il y a des NPE - // à l'utilisation des valeurs - final String localSiteURL = siteURL; - final ServicePollAccount localServicePollAccount = servicePollAccount; - final PollDTO localPoll = poll; - final Messages localMessages = messages; - - // Mise à jour du flux Atom et envoi d'un mail de confirmation - // FIXME replace this ugly thread code !!! - new Thread() { - @Override - public void run() { - sendMailNotification(localSiteURL, localServicePollAccount, - localPoll, localMessages); - } - }.start(); - - } - - /** 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.getPollUId(); - File feedFile = feedContext.getFile(poll.getPollUId()); - - 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")); - } - - @Inject - private PollenContext pollen; - - /** Envoi du mail de notification */ - private void sendMailNotification(String siteURL, ServicePollAccount servicePollAccount, - 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.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)); - data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM)); - - // 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)); - - // FIXME call directly MailUtil.sendMail() - // skip fill map, get from map... - PreventRuleManager.emailAction(data); - } - - // Mails aux votants - for (VotingListDTO list : poll.getVotingListDTOs()) { - - List<Map<String, String>> mailList = new ArrayList<Map<String, String>>(); - for (PollAccountDTO account : list.getPollAccountDTOs()) { - if (account.getEmail() != null) { - String accountVoteURL = voteURL + ":" + account.getAccountUId(); - - /*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)); - - // FIXME call directly MailUtil.sendMail() - // skip fill map, get from map... - PreventRuleManager.emailAction(data);*/ - - Map<String, String> mailData = new HashMap<String, String>(); - mailData.put("receiver", account.getEmail()); - mailData.put("subject", messages.format("votingEmail_subject", poll.getTitle())); - mailData.put("body", messages.format("votingEmail_msg", poll.getTitle(), account.getVotingId(), accountVoteURL)); - mailList.add(mailData); - } - } - - // send mail preparation - try { - 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); - } - } - } - } - - 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) { - JSONObject result = new JSONObject(); - 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()); - - int size = personList.getPollAccounts().size(); - - if (log.isDebugEnabled()) { - log.debug("List size : " + size); - } - - // If the list size is too large, an alert message will be shown - if (size > LIST_MAX_SHOW_PERSONS) { - result.put("listAlert", messages.format("list-maxSize-alert", - personList.getName(), size)); - } - } - return createParamsForCallback(result); - } - /** TODO : move this value to pollen.properties, waiting for 1.3 version **/ - public static final int LIST_MAX_SHOW_PERSONS = 20; - - /** - * Test if the list size made an alert (too large to be shown). - * - * @return true if the current list size is > to LIST_MAX_SHOW_PERSONS - */ - public boolean isListSizeAlert() { - return votingList.getPollAccountDTOs().size() > LIST_MAX_SHOW_PERSONS; - } - - /** - * Get the message to show when the too large list size is loaded. - * - * @return the localized message to show when big list is loaded. - */ - public String getListMaxSizeLoadedMessage() { - return messages.format("list-maxSize-loaded", votingList.getName(), - votingList.getPollAccountDTOs().size()); - } - - /** - * 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(new JSONObject()); - } - - /** - * 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) { - //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.getPollUId())) { - oldPoll = servicePoll.getPoll(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(); - poll = servicePoll.getNewPoll(); - 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -21,14 +21,15 @@ import org.apache.tapestry5.corelib.components.FormFragment; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.business.PreventRuleManager; -import org.chorem.pollen.business.dto.ChoiceDTO; -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.services.ServicePoll; +import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.common.PollType; import org.chorem.pollen.common.VoteCountingType; +import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PreventRule; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.mail.PreventRuleManager; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.data.AddressBar; import org.chorem.pollen.ui.data.ChoiceField; import org.slf4j.Logger; @@ -66,7 +67,7 @@ private Logger log; @SessionState - private UserDTO user; + private UserAccount user; @Property private boolean userExists; @@ -80,7 +81,7 @@ private String pollUID; @Persist - private PollDTO poll; + private Poll poll; void onActivate(String id) { pollUID = id; @@ -102,26 +103,29 @@ * * @return poll existing or a new one */ - public PollDTO getPoll() { + public Poll getPoll() throws PollenBusinessException { if (poll == null) { if (StringUtils.isNotEmpty(pollUID)) { if (log.isDebugEnabled()) { log.debug("Get existing poll with pollUID = " + pollUID); } - poll = servicePoll.getPoll(pollUID); + poll = servicePoll.getPollForUpdate(pollUID); // TODO : init advancedOptions } else { if (log.isDebugEnabled()) { log.debug("Init new poll"); } poll = servicePoll.getNewPoll(); - if (userExists) { - String creatorName = - user.getFirstName() + " " + user.getLastName(); - poll.setCreatorName(creatorName); - poll.setCreatorEmail(user.getEmail()); - poll.setUserId(user.getId()); - } + + // FIXME : manage PollAccount creator + +// if (userExists) { +// String creatorName = +// user.getFirstName() + " " + user.getLastName(); +// poll.setCreatorName(creatorName); +// poll.setCreatorEmail(user.getEmail()); +// poll.setUserId(user.getId()); +// } } } return poll; @@ -132,8 +136,8 @@ * * @return true if it's the create mode, false otherwise */ - public boolean isCreateMode() { - return StringUtils.isEmpty(getPoll().getId()); + public boolean isCreateMode() throws PollenBusinessException { + return StringUtils.isEmpty(getPoll().getTopiaId()); } /** @@ -141,7 +145,7 @@ * * @return the page title depends on create or update mode. */ - public String getPageTitle() { + public String getPageTitle() throws PollenBusinessException { String title = ""; if (isCreateMode()) { title = messages.get("pageTitle-create"); @@ -156,11 +160,11 @@ * * @return the address bar. */ - public AddressBar getAddressBar() { + public AddressBar getAddressBar() throws PollenBusinessException { return new AddressBar().appendCurrent(getPageTitle()); } - public void setPollCopyFromPoll(PollDTO poll) { + public void setPollCopyFromPoll(Poll poll) { this.poll = servicePoll.getNewPoll(poll); } @@ -234,7 +238,7 @@ * * @return a list of ChoiceDTO */ - public List<ChoiceField> getChoices() { + public List<ChoiceField> getChoices() throws PollenBusinessException { if (choices == null) { choices = new ArrayList<ChoiceField>(); if (isCreateMode()) { @@ -243,8 +247,8 @@ choices.add(ChoiceField.getChoiceText()); } } else { - for (ChoiceDTO current : getPoll().getChoices()) { - choices.add((ChoiceField)current); + for (Choice current : getPoll().getChoice()) { + choices.add(new ChoiceField(getPoll(), current)); } } } @@ -298,7 +302,7 @@ private boolean hasNotification; @Persist - private PreventRuleDTO notification; + private PreventRule notification; /** Reminder option **/ @Property @@ -306,7 +310,7 @@ private boolean hasReminder; @Persist - private PreventRuleDTO reminder; + private PreventRule reminder; protected void initOptions() { anonymousVoteAllowedDisabled = false; @@ -316,9 +320,9 @@ hasReminder = false; } - public boolean isChoiceNbDisabled() { + public boolean isChoiceNbDisabled() throws PollenBusinessException { // voteCounting not set to NORMAL - return getPoll().getVoteCounting() != VoteCountingType.NORMAL; + return !getPoll().getVoteCountingType().isNormal(); } @@ -329,10 +333,11 @@ * * @return the notification */ - public PreventRuleDTO getNotification() { + public PreventRule getNotification() { if (notification == null) { - notification = new PreventRuleDTO("vote", 0, true, - PreventRuleManager.EMAIL_ACTION); +// notification = new PreventRuleImpl("vote", 0, true, +// PreventRuleManager.EMAIL_ACTION); +// notification.set } return notification; } @@ -342,10 +347,10 @@ * * @return true if the mail is not defined */ - public boolean isNotificationDisabled() { - // no email defined - return StringUtils.isEmpty(getPoll().getCreatorEmail()); - } +// public boolean isNotificationDisabled() { +// // no email defined +// return StringUtils.isEmpty(getPoll().getCreatorEmail()); +// } //~~~~~~~~ OPTION REMINDER ~~~~~~~~~~~~~~~~// @@ -354,10 +359,10 @@ * * @return the reminder */ - public PreventRuleDTO getReminder() { + public PreventRule getReminder() { if (reminder == null) { - reminder = new PreventRuleDTO("rappel", 0, false, - PreventRuleManager.EMAIL_ACTION); +// reminder = new PreventRuleDTO("rappel", 0, false, +// PreventRuleManager.EMAIL_ACTION); } return reminder; } @@ -366,10 +371,11 @@ * Condition to enable or not the reminder option. * * @return true if the poll has a FREE pollType + * @throws PollenBusinessException */ - public boolean isReminderDisabled() { + public boolean isReminderDisabled() throws PollenBusinessException { // pollType is FREE - return getPoll().getPollType() == PollType.FREE; + return getPoll().getPollType().isFree(); } Deleted: 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollModification.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,675 +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.text.DateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.apache.tapestry5.BindingConstants; -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.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.Zone; -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.PollenContext; -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.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.ui.components.FeedBack; -import org.chorem.pollen.ui.data.AddressBarItem; -import org.chorem.pollen.ui.data.PollAction; -import org.chorem.pollen.ui.data.PollStep; - -/** - * Classe de la page de modification d'un sondage. - * - * @author kmorin - * @author rannou - * @version $Id$ - */ -@IncludeStylesheet("context:css/pollCreation.css") -public class PollModification { - - @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") - @Property - private String title; - - @SuppressWarnings("unused") - @Property - private AddressBarItem[] address; - - /** Paramètres de la page */ - private String param; - - /** Affichage des messages pour l'utilisateur */ - @Component(id = "feedback") - private FeedBack feedback; - - /** Étape courante du formulaire */ - @Persist - private PollStep step; - - /** - * Objet de session représentant l'utilisateur identifié. - */ - @SuppressWarnings("unused") - @SessionState - private UserDTO user; - @SuppressWarnings("unused") - @Property - private boolean userExists; - - /** - * Objet de session représentant l'url du site. - */ - @SessionState - @Property - private String siteURL; - - /** Composants DateTimeField pour le début des ajouts de choix */ - @SuppressWarnings("unused") - @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) - private DateTimeField beginChoiceDate; - @SuppressWarnings("unused") - @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) - private DateTimeField endChoiceDate; - - /** Composants DateTimeField pour le début et la fin du sondage */ - @SuppressWarnings("unused") - @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) - private DateTimeField beginDate; - @SuppressWarnings("unused") - @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) - private DateTimeField endDate; - - /** Format des dates */ - @SuppressWarnings("unused") - @Persist - @Property - private DateFormat dateFormat; - - /** Locale courante */ - @Inject - private Locale currentLocale; - - /** - * Sondage - */ - @Property - @Persist - private PollDTO poll; - - /** - * Créateur du sondage - */ - @Property - @Persist - private PollAccountDTO creator; - - /** Indique si l'utilisateur est authorisé */ - @Property - private boolean userAllowed = false; - - /** 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; - - @InjectComponent - private Zone pollCreationZone; - - @InjectPage - private ConfirmPoll confirmPoll; - - /** variable utilisée pour l'affichage de la notificationCheckBox */ - @Property - @Persist - private boolean notificationCheckBox; - - /** Règle de notification */ - @Property - @Persist - private PreventRuleDTO newRule; - - /** - * Objet utilisé dans la boucle de parcours de la liste des votants - */ - @Property - private VotingListDTO votingList; - - /** - * Objet utilisé dans la boucle de parcours de la liste des votants - */ - @SuppressWarnings("unused") - @Property - private PollAccountDTO votingListPerson; - - /** - * Objet utilisé dans la boucle de parcours de la liste des choix - */ - @Property - private ChoiceDTO choice; - - @InjectPage - private ModificationValidation modificationValidation; - - @Inject - private Messages messages; - - /** 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 - * modification de sondage. - */ - Object onSuccessFromPollCreationForm() { - switch (step) { - case POLL: - step = PollStep.OPTIONS; - break; - case OPTIONS: - if (poll.isContinuousResults()) { - poll.setPublicResults(true); - } - - if (isFreePoll()) { - step = PollStep.CHOICES; - } else { - step = PollStep.LISTS; - } - break; - case LISTS: - step = PollStep.CHOICES; - break; - case CHOICES: - - // Règles de notification - PreventRuleDTO oldRule = null; - for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) { - if (rule.getId().equals(newRule.getId())) { - oldRule = rule; - } - } - if (oldRule != null) { // remplacement de oldRule par newRule - poll.getPreventRuleDTOs().remove(oldRule); - if (notificationCheckBox) { - poll.getPreventRuleDTOs().add(newRule); - } - } else { // création d'une nouvelle règle - if (notificationCheckBox) { - poll.getPreventRuleDTOs().add(newRule); - } - } - - // sauvegarde des comptes modifiés - List<PollAccountDTO> modifiedAccounts = getModifiedAccounts(); - - // mise à jour des listes de votants du sondage - servicePollAccount.updatePollAccount(creator); - for (VotingListDTO votingList : poll.getVotingListDTOs()) { - for (PollAccountDTO account : votingList.getPollAccountDTOs()) { - servicePollAccount.updatePollAccount(account); - } - serviceList.updateVotingList(votingList); - } - - if (poll.isContinuousResults()) { - poll.setPublicResults(true); - } - - for (ChoiceDTO choice : poll.getChoices()) { - choice.setValidate(true); - } - servicePoll.updatePoll(poll); - - // envoi de mails aux comptes modifiés - sendMailNotification(modifiedAccounts); - - step = PollStep.POLL; - modificationValidation.setPoll(poll); - return modificationValidation; - default: - step = PollStep.POLL; - break; - } - return pollCreationZone.getBody(); - } - - /** - * 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. - */ - Object onSubmitFromPollCreationForm() { - return pollCreationZone.getBody(); - } - - /** - * 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 pollCreationZone.getBody(); - } - - /** - * 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 { - - // Validation des votants - if (step == PollStep.LISTS) { - List<VotingListDTO> votingLists = poll.getVotingListDTOs(); - 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 (nbEqual > nbNotNull) { - throw new ValidationException(messages.get("list-validate")); - } - } - } - - Object onActionFromCloseButton() { - String backPage = "poll/modification"; - confirmPoll.setBackPage(backPage); - confirmPoll.setAction(PollAction.CLOSE); - confirmPoll.setPoll(poll); - return confirmPoll; - } - - public String getChoiceDateDisplay() { - return poll.isChoiceAddAllowed() ? "display: block;" : "display: none;"; - } - - public String getNotificationDisplay() { - return notificationCheckBox ? "display: block;" : "display: none;"; - } - - /** Retourne la date correspondant au choix courant */ - public Date getChoiceNameAsDate() { - return new Date(Long.valueOf(choice.getName())); - } - - /** Retourne le poids en entier de la liste courante */ - public int getWeightAsInt() { - return votingList.getWeight().intValue(); - } - - /** Retourne le numéro de la liste courante (index+1) */ - public int getVotingListNumber() { - return poll.getVotingListDTOs().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 (poll.getPollType() == PollType.FREE) { - 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 ""; - } - } - - public boolean isListSizeAlert() { - return votingList.getPollAccountDTOs().size() > - PollCreation.LIST_MAX_SHOW_PERSONS; - } - - 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 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; - } - - @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", 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) { - if (account.getEmail() != null) { - String accountVoteURL = voteURL + ":" + account.getAccountUId(); - - 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)); - - // FIXME call directly MailUtil.sendMail() - // skip fill map, get from map... - PreventRuleManager.emailAction(data); - } - } - } - - /** Récupération des votants modifiés */ - private List<PollAccountDTO> getModifiedAccounts() { - List<PollAccountDTO> modifiedAccounts = new ArrayList<PollAccountDTO>(); - - // Parcours des listes de votants du sondage et comparaison - // avec les listes de votants de la base de données - for (VotingListDTO list : poll.getVotingListDTOs()) { - for (PollAccountDTO newAccount : list.getPollAccountDTOs()) { - PollAccountDTO oldAccount = servicePollAccount - .findPollAccountById(newAccount.getId()); - - if (oldAccount.getEmail() == null - && newAccount.getEmail() != null) { - modifiedAccounts.add(newAccount); - } else if (oldAccount.getEmail() != null - && newAccount.getEmail() != null) { - if (!newAccount.getVotingId().equals( - oldAccount.getVotingId()) - || !newAccount.getEmail().equals( - oldAccount.getEmail())) { - modifiedAccounts.add(newAccount); - } - } - } - } - - return modifiedAccounts; - } - - void onActivate(String id) { - param = id; - - if (id != null && !"".equals(id)) { - String pollId = id.split(":", 2)[0]; - - // Réinitialisation des variables de session - if (poll == null || !pollId.equals(poll.getPollUId())) { - poll = servicePoll.getPoll(pollId); - creator = null; - newRule = null; - } - - if (poll != null) { - - // Identification de l'utilisateur - if (creator == null) { - creator = servicePollAccount.findPollAccountById(poll - .getCreatorId()); - } - if (id.split(":", 2).length == 2) { - String creatorId = id.split(":", 2)[1]; - if (creatorId.equals(creator.getAccountUId())) { - userAllowed = true; - } - } - - // Règles de notification - if (newRule == null) { - initNotificationRule(); - } - } - } - - // Affichage des erreurs - if (poll == null) { - feedback.addError(messages.get("pollNotFound")); - } else if (poll.isClosed()) { - feedback.addError(messages.get("pollClosed")); - } else if (!userAllowed) { - feedback.addError(messages.get("userNotAllowed")); - } - } - - /** - * Méthode appelée au moment de la désactivation de la page - * - * @return l'identifiant du sondage et du créateur - */ - String onPassivate() { - return param; - } - - /** - * 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); - - // Réinitialisation des variables de session - if (poll != null) { - poll = servicePoll.getPoll(poll.getPollUId()); - creator = servicePollAccount.findPollAccountById(poll - .getCreatorId()); - initNotificationRule(); - } - step = PollStep.POLL; - } - - /** Initialisation de la règle de notification */ - private void initNotificationRule() { - notificationCheckBox = false; - newRule = new PreventRuleDTO("vote", 0, true, - PreventRuleManager.EMAIL_ACTION); - newRule.setPollId(poll.getId()); - for (PreventRuleDTO rule : poll.getPreventRuleDTOs()) { - if ("vote".equals(rule.getScope())) { - notificationCheckBox = true; - newRule = rule; - } - } - } -} 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/Results.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -17,6 +17,7 @@ package org.chorem.pollen.ui.pages.poll; import java.text.DateFormat; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -33,29 +34,25 @@ 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.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.ChoiceDTO; -import org.chorem.pollen.business.dto.PollAccountDTO; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.dto.ResultDTO; -import org.chorem.pollen.business.dto.ResultListDTO; -import org.chorem.pollen.business.services.ServicePoll; -import org.chorem.pollen.business.services.ServicePollAccount; -import org.chorem.pollen.business.services.ServiceResults; +import org.chorem.pollen.PollenBusinessException; import org.chorem.pollen.common.ChoiceType; import org.chorem.pollen.common.PollType; import org.chorem.pollen.common.VoteCountingType; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.Result; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.components.Chart; import org.chorem.pollen.ui.components.FeedBack; -import org.chorem.pollen.ui.components.ImageContextLink; import org.chorem.pollen.ui.data.AddressBarItem; import org.chorem.pollen.votecounting.business.NumberMethod; +import org.chorem.pollen.votecounting.dto.ChoiceDTO; import org.chorem.pollen.votecounting.dto.VoteCountingResultDTO; import org.slf4j.Logger; @@ -105,16 +102,16 @@ /** Sondage concerné par les résultats */ @Property @Persist - private PollDTO poll; + private Poll poll; /** Créateur du sondage */ @Property - private PollAccountDTO creator; + private PollAccount creator; /** Résultats du sondage */ @Persist @Property(write = false) - private List<ResultDTO> results; + private List<Result> results; /** * Résultats du sondage. @@ -136,7 +133,7 @@ /** Résultat courant */ @Property - private ResultDTO result; + private Result result; /** Choix courant (diagramme) */ @SuppressWarnings("unused") @@ -148,8 +145,8 @@ private Messages messages; /** Page d'affichage d'une image */ - @InjectPage - private ImageDisplay imageDisplay; +// @InjectPage +// private ImageDisplay imageDisplay; /** Format des dates */ @Persist @@ -169,27 +166,27 @@ /** Injection des services */ @Inject private ServicePoll servicePoll; - @Inject - private ServicePollAccount servicePollAccount; - @Inject - private ServiceResults serviceResults; +// @Inject +// private ServicePollAccount servicePollAccount; +// @Inject +// private ServiceResults serviceResults; - @InjectComponent - private ImageContextLink imgContext; +// @InjectComponent +// private ImageContextLink imgContext; +// +// public ImageContextLink getImgContext() { +// return imgContext; +// } - public ImageContextLink getImgContext() { - return imgContext; - } - /** Récupération de la liste des résultats pour le diagramme. */ public ArrayList<ArrayList<String>> getChoices() { ArrayList<ArrayList<String>> choices = new ArrayList<ArrayList<String>>(); ArrayList<String> choiceValues = new ArrayList<String>(); - countPoll(); - for (ResultDTO result : results) { - String name = result.getName(); - String value = result.getValue(); + //countPoll(); + for (Result result : results) { + String name = result.getChoice().getName(); + String value = String.valueOf(result.getValue()); if (poll.getChoiceType() == ChoiceType.DATE) { // mise en forme de la date Date date = new Date(Long.parseLong(name)); @@ -205,15 +202,15 @@ } /** Récupération de la liste des résultats pour le classement. */ - public List<ResultDTO> getRanking() { - countPoll(); - List<ResultDTO> ranking = results; + public List<Result> getRanking() { + //countPoll(); + List<Result> ranking = results; - Collections.sort(ranking, new Comparator<ResultDTO>() { + Collections.sort(ranking, new Comparator<Result>() { @Override - public int compare(ResultDTO o1, ResultDTO o2) { - Double result1 = Double.parseDouble(o1.getValue()); - Double result2 = Double.parseDouble(o2.getValue()); + public int compare(Result o1, Result o2) { + double result1 = o1.getValue(); + double result2 = o2.getValue(); int comp = 0; // résultat de la comparaison if (result1 > result2) { @@ -222,7 +219,8 @@ comp = 1; } if (comp == 0) { - comp = o1.getName().compareTo(o2.getName()); + comp = o1.getChoice().getName().compareTo( + o2.getChoice().getName()); } return comp; } @@ -232,19 +230,19 @@ } /** Récupération des résultats gagnants. */ - public List<ResultDTO> getTopRanking() { - List<ResultDTO> ranking = getRanking(); - List<ResultDTO> winners = new ArrayList<ResultDTO>(); + public List<Result> getTopRanking() { + List<Result> ranking = getRanking(); + List<Result> winners = new ArrayList<Result>(); - String winValue = null; + double winValue = 0.; if (ranking.size() > 0) { winValue = ranking.get(0).getValue(); } else { return winners; } - for (ResultDTO r : ranking) { - if (winValue.equals(r.getValue())) { + for (Result r : ranking) { + if (winValue == r.getValue()) { winners.add(r); } } @@ -297,7 +295,7 @@ /** Retourne le message d'aide correspondant au type de sondage. */ public String getHelpMessage() { - switch (poll.getVoteCounting()) { + switch (poll.getVoteCountingType()) { case NORMAL: return messages.get("normalVote-help"); case PERCENTAGE: @@ -313,11 +311,11 @@ /** Retourne le message de victoire indiquant le ou les gagnants. */ public String getVictoryMessage() { - if (poll.getVoteCounting() == VoteCountingType.NUMBER) { + if (poll.getVoteCountingType().equals(VoteCountingType.NUMBER)) { return null; } - List<ResultDTO> winners = getTopRanking(); + List<Result> winners = getTopRanking(); if (winners.size() == 0) { return ""; @@ -330,159 +328,164 @@ /** Retourne la valeur du résultat courant sans le .0 final */ public String getTrimValue() { - String value = result.getValue(); +// String value = result.getValue(); +// +// // le résultat peut-être un double : 1,0 -> 1 et 1,2 -> 1,2 +// if (value.endsWith(".0")) { +// value = value.substring(0, value.indexOf('.')); +// } - // le résultat peut-être un double : 1,0 -> 1 et 1,2 -> 1,2 - if (value.endsWith(".0")) { - value = value.substring(0, value.indexOf('.')); - } - return value; + // FIXME : carefull with Locale !! + + return NumberFormat.getNumberInstance().format(result.getValue()); } /** Retourne la date correspondant au résultat courant */ public Date getResultNameAsDate() { - return new Date(Long.valueOf(result.getName())); + return new Date(Long.valueOf(result.getChoice().getName())); } /** Action réalisée lorsqu'on clique sur l'image */ - Object onDisplayImage(String resultName) { - String choiceId = ""; +// Object onDisplayImage(String resultName) { +// String choiceId = ""; +// +// // Récupération du choix correspondant au résultat +// for (Choice choice : poll.getChoice()) { +// if (resultName.equals(choice.getName())) { +// choiceId = choice.getTopiaId(); +// } +// } +// +// imageDisplay.setPoll(poll); +// imageDisplay.setChoiceId(choiceId); +// imageDisplay.setPageStyle("VoteCounting"); +// return imageDisplay; +// } - // Récupération du choix correspondant au résultat - for (ChoiceDTO choice : poll.getChoices()) { - if (resultName.equals(choice.getName())) { - choiceId = choice.getId(); - } - } - - imageDisplay.setPoll(poll); - imageDisplay.setChoiceId(choiceId); - imageDisplay.setPageStyle("VoteCounting"); - return imageDisplay; - } - /** Dépouillement du sondage. Mise à jour des résultats. */ - private void countPoll() { - ResultListDTO resultListDTO = null; - - if (byGroup) { - resultListDTO = serviceResults.getGroupResults(poll.getPollUId()); - } else { - resultListDTO = serviceResults.getNormalResults(poll.getPollUId()); - } +// private void countPoll() { +// ResultListDTO resultListDTO = null; +// +// if (byGroup) { +// resultListDTO = serviceResults.getGroupResults(poll.getPollUId()); +// } else { +// resultListDTO = serviceResults.getNormalResults(poll.getPollUId()); +// } +// +// results = resultListDTO.getResultDTOs(); +// computeResults(resultListDTO); +// +// for (ResultDTO res : results) { +// logger.debug(res.getName() + ": " + res.getValue() +// + ", (voteCounting=" + res.getVoteCounting() + ", byGroup=" +// + res.isByGroup() + ")"); +// } +// } - results = resultListDTO.getResultDTOs(); - computeResults(resultListDTO); - - for (ResultDTO res : results) { - logger.debug(res.getName() + ": " + res.getValue() - + ", (voteCounting=" + res.getVoteCounting() + ", byGroup=" - + res.isByGroup() + ")"); - } - } - - private void computeResults(ResultListDTO resultListDTO) { - if (poll.getVoteCounting() == VoteCountingType.NUMBER) { - // resultats des choix cachés - choicesResults = new LinkedHashMap<String, List<String>>(); - - // sous-titres des vrais choix (les choix pas cachés) - subtitles = new LinkedHashMap<String, List<String>>(); - - /* - * liste des vrais choix (les choix pas cachés). - * cette variable sera affectée à la variable results - */ - List<ResultDTO> results2 = new ArrayList<ResultDTO>(); - - // Ajout des résultats des choix cachés - for (ResultDTO result : results) { - if (result.isHidden()) { - String name = result.getName(); - int indexOf = name.indexOf('#'); - String choice = name.substring( - NumberMethod.HIDDEN_PREFIX.length(), indexOf); - - List<String> votes = choicesResults.get(choice); - if (votes == null) { - votes = new ArrayList<String>(); - } - - String votingId = name.substring(indexOf + 1); - String value = result.getValue(); - - votes.add(votingId); - votes.add(value); - - choicesResults.put(choice, votes); - - } else { - results2.add(result); - } - } - - Set<Entry<String, List<String>>> entries = choicesResults.entrySet(); - for (Entry<String, List<String>> entry : entries) { - String choiceName = entry.getKey(); - List<String> values = entry.getValue(); - - // Récupération du choix correspondant au résultat - VoteCountingResultDTO voteCountingResultDTO = resultListDTO - .getVoteCountingResultDTO(); - - for (org.chorem.pollen.votecounting.dto.ChoiceDTO choice : - voteCountingResultDTO.getChoices()) { - if (choiceName.equals(choice.getName())) { - List<String> choiceSubtitles = subtitles.get(choice); - if (choiceSubtitles == null) { - choiceSubtitles = new ArrayList<String>(); - } - - choiceSubtitles.add(messages.get("numberVote-total")); - choiceSubtitles.add(String.valueOf(choice.getValue())); - - choiceSubtitles.add(messages.get("numberVote-average")); - choiceSubtitles.add(String.valueOf(choice.getAverage())); - - choiceSubtitles.add(messages.get("numberVote-blank-votes")); - choiceSubtitles.add(String.valueOf(choice.getNbBlankVotes())); - - choiceSubtitles.add(messages.get("numberVote-total-votes")); - choiceSubtitles.add(String.valueOf(values.size() / 2)); - - subtitles.put(choiceName, choiceSubtitles); - break; - } - } - - } - - results = results2; - if (results.size() == 1) { - results.remove(0); - } - } - } +// private void computeResults(ResultListDTO resultListDTO) { +// if (poll.getVoteCounting() == VoteCountingType.NUMBER) { +// // resultats des choix cachés +// choicesResults = new LinkedHashMap<String, List<String>>(); +// +// // sous-titres des vrais choix (les choix pas cachés) +// subtitles = new LinkedHashMap<String, List<String>>(); +// +// /* +// * liste des vrais choix (les choix pas cachés). +// * cette variable sera affectée à la variable results +// */ +// List<ResultDTO> results2 = new ArrayList<ResultDTO>(); +// +// // Ajout des résultats des choix cachés +// for (ResultDTO result : results) { +// if (result.isHidden()) { +// String name = result.getName(); +// int indexOf = name.indexOf('#'); +// String choice = name.substring( +// NumberMethod.HIDDEN_PREFIX.length(), indexOf); +// +// List<String> votes = choicesResults.get(choice); +// if (votes == null) { +// votes = new ArrayList<String>(); +// } +// +// String votingId = name.substring(indexOf + 1); +// String value = result.getValue(); +// +// votes.add(votingId); +// votes.add(value); +// +// choicesResults.put(choice, votes); +// +// } else { +// results2.add(result); +// } +// } +// +// Set<Entry<String, List<String>>> entries = choicesResults.entrySet(); +// for (Entry<String, List<String>> entry : entries) { +// String choiceName = entry.getKey(); +// List<String> values = entry.getValue(); +// +// // Récupération du choix correspondant au résultat +// VoteCountingResultDTO voteCountingResultDTO = resultListDTO +// .getVoteCountingResultDTO(); +// +// for (org.chorem.pollen.votecounting.dto.ChoiceDTO choice : +// voteCountingResultDTO.getChoices()) { +// if (choiceName.equals(choice.getName())) { +// List<String> choiceSubtitles = subtitles.get(choice); +// if (choiceSubtitles == null) { +// choiceSubtitles = new ArrayList<String>(); +// } +// +// choiceSubtitles.add(messages.get("numberVote-total")); +// choiceSubtitles.add(String.valueOf(choice.getValue())); +// +// choiceSubtitles.add(messages.get("numberVote-average")); +// choiceSubtitles.add(String.valueOf(choice.getAverage())); +// +// choiceSubtitles.add(messages.get("numberVote-blank-votes")); +// choiceSubtitles.add(String.valueOf(choice.getNbBlankVotes())); +// +// choiceSubtitles.add(messages.get("numberVote-total-votes")); +// choiceSubtitles.add(String.valueOf(values.size() / 2)); +// +// subtitles.put(choiceName, choiceSubtitles); +// break; +// } +// } +// +// } +// +// results = results2; +// if (results.size() == 1) { +// results.remove(0); +// } +// } +// } /** Initialisation des objets de session */ - void onActivate(String id) { + void onActivate(String id) throws PollenBusinessException { param = id; String pollId = null; if (id != null && !"".equals(id)) { pollId = id.split(":", 2)[0]; - poll = servicePoll.getPoll(pollId); + + poll = servicePoll.getPollForResults(pollId); if (poll != null) { // Identification de l'utilisateur - creator = servicePollAccount.findPollAccountById(poll - .getCreatorId()); - if (poll.isPublicResults()) { + creator = poll.getCreator(); +// creator = servicePollAccount.findPollAccountById(poll +// .getCreatorId()); + if (poll.getPublicResults()) { userAllowed = true; } else if (id.split(":", 2).length == 2) { String creatorId = id.split(":", 2)[1]; - if (creatorId.equals(creator.getAccountUId())) { + if (creatorId.equals(creator.getUId())) { userAllowed = true; } } @@ -494,7 +497,7 @@ feedback.addError(messages.get("pollNotFound")); } else if (!userAllowed) { feedback.addError(messages.get("userNotAllowed")); - } else if (!poll.isClosed()) { + } else if (!poll.getClosed()) { feedback.addError(messages.get("pollNotClosed")); } } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -16,77 +16,51 @@ package org.chorem.pollen.ui.pages.poll; -import java.io.File; import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.apache.commons.fileupload.FileUploadException; +import java.util.Locale; 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; 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.Retain; 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.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.apache.tapestry5.upload.services.UploadedFile; -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; -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.ResultDTO; -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.ServicePoll; -import org.chorem.pollen.business.services.ServicePollAccount; -import org.chorem.pollen.business.services.ServiceResults; -import org.chorem.pollen.business.services.ServiceVote; -import org.chorem.pollen.business.utils.MD5; -import org.chorem.pollen.common.ChoiceType; -import org.chorem.pollen.common.PollType; -import org.chorem.pollen.common.VoteCountingType; +import org.chorem.pollen.PollenBusinessException; +import org.chorem.pollen.PollenBusinessException.PollenExceptionType; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenProperty; +import org.chorem.pollen.entity.Choice; +import org.chorem.pollen.entity.Comment; +import org.chorem.pollen.entity.CommentImpl; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.entity.Vote; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.service.ServiceUser; 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.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.slf4j.Logger; /** @@ -99,862 +73,863 @@ @IncludeStylesheet({"context:css/vote.css", "context:css/lightbox.css"}) @IncludeJavaScriptLibrary({"${tapestry.scriptaculous}/builder.js","context:js/lightbox.js"}) public class VoteForPoll extends AbstractUploadPage { - - @Inject - private Logger log; - - @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") - @Property - private String title; - - /** Paramètres de la page */ - private String param; - - /** Affichage des messages pour l'utilisateur */ - @Component(id = "feedback") - private FeedBack feedback; - - - /** - * Objet de session représentant l'url du site. - */ - @SessionState - @Property - private String siteURL; - - @Component - private Form voteForm; - -// @Component(id = "pollAccountName") -// private TextField nameField; - -// /** Composant DateTimeField pour les choix du sondage */ +// +// @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") +// @Property +// private String title; +// +// /** Paramètres de la page */ +// private String param; +// +// /** Affichage des messages pour l'utilisateur */ +// @Component(id = "feedback") +// private FeedBack feedback; +// +// +// /** +// * Objet de session représentant l'url du site. +// */ +// @SessionState +// @Property +// private String siteURL; +// +// @Component +// private Form voteForm; +// +//// @Component(id = "pollAccountName") +//// private TextField nameField; +// +//// /** Composant DateTimeField pour les choix du sondage */ +//// @SuppressWarnings("unused") +//// @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) +//// private DateTimeField dateDTF; +// +// /** Locale courante */ +// @Inject +// private Locale currentLocale; +// +// @Inject +// private Logger logger; +// +// @Inject +// private Messages messages; +// +// /** +// * Vote courant de l'utilisateur +// */ +// @Property +// private Vote vote; +// +// /** Choix courant du sondage */ +// @Property +// private Choice choiceOfPoll; +// /** Choix courant du nouveau vote */ +// @Property +// private Choice choiceOfVote; +// +// /** Résultats du sondage */ +// @Persist +// private List<Result> results; +// +// /** +// * Modèle pour l'affichage de la liste des sondages +// */ +// @SuppressWarnings( { "unchecked", "unused" }) +// @Property +// @Retain +// private BeanModel voteModel; +// +// /*@InjectPage +// private ImageDisplay imageDisplay;*/ +// +//// @InjectComponent +//// private Zone pollZone; +// +// /** +// * Objet servant à changer la couleur à chaque ligne de la liste des +// * sondages +// */ // @SuppressWarnings("unused") -// @Component(parameters = { "timePicker=true", "timePickerAdjacent=true" }) -// private DateTimeField dateDTF; - - /** Locale courante */ - @Inject - private Locale currentLocale; - - @Inject - private Logger logger; - - @Inject - private Messages messages; - - /** - * Vote courant de l'utilisateur - */ - @Property - private VoteDTO vote; - - /** Choix courant du sondage */ - @Property - private ChoiceDTO choiceOfPoll; - /** Choix courant du nouveau vote */ - @Property - private ChoiceDTO choiceOfVote; - - /** Résultats du sondage */ - @Persist - private List<ResultDTO> results; - - /** - * Modèle pour l'affichage de la liste des sondages - */ - @SuppressWarnings( { "unchecked", "unused" }) - @Property - @Retain - private BeanModel voteModel; - - /*@InjectPage - private ImageDisplay imageDisplay;*/ - -// @InjectComponent -// private Zone pollZone; - - /** - * Objet servant à changer la couleur à chaque ligne de la liste des - * sondages - */ - @SuppressWarnings("unused") - @Property - private EvenOdd evenOdd = new EvenOdd(); - - /** Choix courant (type texte) */ - private boolean addChoice; - - /** Le votant a déjà voté ? */ - private boolean alreadyVoted; - - /** Le vote est anonyme */ - @Property - private boolean anonymousVote = false; - - /** Liste des choix */ -// private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>(); - - /** Identifiant du compte correspondant à l'adresse forgée */ -// private String pollAccountId; - - /** Compte du votant */ // @Property -// private PollAccountDTO pollAccount; - -// /** Nouveau choix de type texte */ +// private EvenOdd evenOdd = new EvenOdd(); +// +// /** Choix courant (type texte) */ +// private boolean addChoice; +// +// /** Le votant a déjà voté ? */ +// private boolean alreadyVoted; +// +// /** Le vote est anonyme */ // @Property +// private boolean anonymousVote = false; +// +// /** Liste des choix */ +//// private List<ChoiceDTO> voteChoices = new ArrayList<ChoiceDTO>(); +// +// /** Identifiant du compte correspondant à l'adresse forgée */ +//// private String pollAccountId; +// +// /** Compte du votant */ +//// @Property +//// private PollAccountDTO pollAccount; +// +//// /** Nouveau choix de type texte */ +//// @Property +//// @Persist +//// private ChoiceDTO newChoice; +// +// /** Nouveau choix de type date */ +// @Property // @Persist -// private ChoiceDTO newChoice; - - /** Nouveau choix de type date */ - @Property - @Persist - private DateChoiceUIO newDateChoice; - - /** Nouveau choix de type image */ - @Property - @Persist - private ImageChoiceUIO newImageChoice; - - /** Injection des services */ - @Inject - private ServicePoll servicePoll; - @Inject - private ServiceVote serviceVote; - - @Inject - private ServicePollAccount servicePollAccount; - @Inject - private ServiceResults serviceResults; - - /** - * Composant pour la gestion des flux RSS - */ - @InjectComponent - private ContextLink feedContext; - - /** - * Context to get feed of the current poll - * @return a FeedContext defined in .tml file - */ - public ContextLink getFeedContext() { - return feedContext; - } - +// private DateChoiceUIO newDateChoice; +// +// /** Nouveau choix de type image */ +// @Property +// @Persist +// private ImageChoiceUIO newImageChoice; +// +// /** Injection des services */ +// @Inject +// private ServicePoll servicePoll; +// @Inject +// private ServiceVote serviceVote; +// +// @Inject +// private ServicePollAccount servicePollAccount; +// @Inject +// private ServiceResults serviceResults; +// // /** -// * Composant pour la gestion des upload d'images +// * Composant pour la gestion des flux RSS // */ // @InjectComponent -// private ImageContextLink imgContext; +// private ContextLink feedContext; // // /** -// * Context to get images for choices. -// * @return an ImageContextLink defined in .tml file +// * Context to get feed of the current poll +// * @return a FeedContext defined in .tml file // */ -// public ImageContextLink getImgContext() { -// return imgContext; +// public ContextLink getFeedContext() { +// return feedContext; // } - - @InjectComponent - private FeedBack voteFeedback; - - public String getVoteSizeMessage() throws PollenBusinessException { - if (log.isDebugEnabled()) { - log.debug("poll voteDTOs list size : " + getVotes().size()); - log.debug("poll nbVotes : " + getPoll().getNbVotes()); - } - return messages.format("vote-size", getPoll().getNbVotes()); - } - - /** 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(); -// } +//// /** +//// * 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; +//// } // -// } else if (getPoll().getVoteCounting() == VoteCountingType.CONDORCET) { -// for (ChoiceDTO choice : getPoll().getChoices()) { -// if (choice.getValue() == 0) { -// choice.setValue(100); -// } -// choiceDTOs.add(choice); -// } +// @InjectComponent +// private FeedBack voteFeedback; // -// } else if (getPoll().getVoteCounting() == VoteCountingType.NUMBER) { -// String votingId = pollAccount.getVotingId(); -// if (anonymousVote) { -// votingId = "anonymous" + UUID.randomUUID().toString().replaceAll("-", ""); -// } +// public String getVoteSizeMessage() throws PollenBusinessException { +// if (log.isDebugEnabled()) { +// log.debug("poll voteDTOs list size : " + getVotes().size()); +// log.debug("poll nbVotes : " + getPoll().getNbVotes()); +// } +// return messages.format("vote-size", getPoll().getNbVotes()); +// } // -// for (ChoiceDTO choice : getPoll().getChoices()) { -// if (!choice.isHidden()) { -// choiceDTOs.add(choice); +// /** 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); +//// 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(); +//// } // -// // 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); +//// 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(); +//// } // -// String choiceId = -// serviceChoice.createChoice(hiddenChoice); -// hiddenChoice.setId(choiceId); -// choiceDTOs.add(hiddenChoice); -// } -// } -// } +// /** 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 = 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); +//// } // -// VoteDTO vote = new VoteDTO(null, getPoll().getId(), null); -// vote.setChoiceDTOs(choiceDTOs); -// vote.setWeight(pollAccount.getWeight()); -// vote.setAnonymous(anonymousVote); +// /** +// * 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 +// * l'url est l'auteur du vote. +// * +// * @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; +//// +//// // 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; +//// } // -// // mise à jour du vote ou création d'un nouveau vote -// if (alreadyVoted) { -// for (VoteDTO v : getVotes()) { -// PollAccountDTO voteAccount = servicePollAccount -// .findPollAccountById(v.getPollAccountId()); +// /** 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().getPollUId(); +// File feedFile = getFeedContext().getFile(getPoll().getPollUId()); +// String title = null; +// String content = null; // -// if (voteAccount.getVotingId().equals(getPollAccount().getVotingId())) { -// vote.setId(v.getId()); -// deleteVote(vote.getId()); -// serviceVote.createVote(vote, getPollAccount()); -// } -// } -// } else { -// serviceVote.createVote(vote, getPollAccount()); +// switch (pollAction) { +// case ADDVOTE: +// if (isVoteAnonymous()) { +// titleStr = messages.get("anonymous"); // } +// title = messages.format("pollFeed_voteTitle", titleStr); +// content = messages.format("pollFeed_voteContent", contentStr); +// break; +// case ADDCHOICE: +// title = messages.format("pollFeed_choiceTitle", titleStr); +// content = messages.format("pollFeed_choiceContent", contentStr); +// break; +// case ADDCOMMENT: +// title = messages.format("pollFeed_commentTitle", titleStr); +// content = messages.format("pollFeed_commentContent", contentStr); +// break; +// } // -// // 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; +// if (!feedFile.exists()) { +// FeedUtil.createFeed(feedFile, "atom_1.0", messages.format( +// "pollFeed_title", getPoll().getTitle()), siteURL, messages +// .format("pollFeed_desc", getPoll().getDescription())); // } -//// voteChoices.clear(); -// return pollZone.getBody(); +// FeedUtil.feedFeed(feedFile, title, voteURL, content); // } - -// 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) { +// /** Envoi du mail de notification */ +// private void sendMailNotification() throws PollenBusinessException { +// 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", pollen.getProperty(PollenProperty.EMAIL_HOST)); +// data.put("port", pollen.getProperty(PollenProperty.EMAIL_PORT)); +// data.put("from", pollen.getProperty(PollenProperty.EMAIL_FROM)); // -// if (choiceDTO.isHidden()) { -// serviceChoice.deleteChoice(choiceDTO.getId()); -// } -// } +// // Mail au créateur +// 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)); // -// break; -// } +// for (PreventRuleDTO rule : getPoll().getPreventRuleDTOs()) { +// PreventRuleManager manager = new PreventRuleManager(rule); +// manager.execute("vote", getVotes().size(), data); // } +// } // -// serviceVote.deleteVote(voteId); +// public boolean isAddChoice() { +// return addChoice; // } // -// /** Méthode appelée lors de la suppression d'un vote. */ -// Object onActionFromDeleteVote(String voteId) throws PollenBusinessException { -// deleteVote(voteId); +// public void setAddChoice(boolean addChoice) { +// choiceOfVote.setValue((addChoice) ? 1 : 0); +// } // -// // Mise à jour du sondage et des résultats -//// poll = servicePoll.findPollByPollId(poll.getPollId()); -// poll = null; -// countPoll(); +// public void setAddNumberVote(Integer value) { +// if (value != null) { +// choiceOfVote.setValue(value); // -// return pollZone.getBody(); +// } else { +// choiceOfVote.setValue(-1); +// } // } - - /** 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; +// public Integer getAddNumberVote() { +// return null; +// } // -// // 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() + ")"); -//// } -//// } +// /** +// * Retourne si le choix fait partie du vote (s'il a été renseigné par le +// * votant). +// * +// * @param choice le choix concerné +// * @return true si le choix est dans le vote +// */ +// public Boolean isChoiceInVote(ChoiceDTO choice) throws PollenBusinessException { +// if (choice != null) { +// switch (getPoll().getVoteCounting()) { +// case NORMAL: +// return choice.getValue() > 0; +// case PERCENTAGE: +// return true; +// case CONDORCET: +// return choice.getValue() < 100; +// case NUMBER: +// return choice.getValue() >= 0; +// } +// } +// return null; +// } +// +// public boolean isChoiceHidden() { +// return choiceOfPoll.isHidden(); +// } +// +// /** +// * Retourne le choix de vote correspondant au choix de sondage courant. +// * +// * @return un choix de vote +// */ +// @Property(write = false) +// private ChoiceDTO currentVoteChoice; +// +// public char setCurrentVoteChoice() { +//// currentVoteChoice = null; +//// for (ChoiceDTO choice : vote.getChoiceDTOs()) { +//// if (choice.getId().equals(choiceOfPoll.getId())) { +//// currentVoteChoice = choice; +//// break; //// } //// } // -// // The calcul of alreadyVoted will be needed for no double votingId -// // Carefull, not correct for an anonymous vote -// alreadyVoted = serviceVote.hasAlreadyVoted(votingId, getPoll()); +// return 0; +// } // -// // 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()); +// /** +// * Retourne le résultat correspondant au choix de sondage courant. +// * +// * @return le résultat du choix +// */ +// public String getCurrentChoiceResult() { +// String val = ""; +// for (ResultDTO result : results) { +// if (result.getName().equals(choiceOfPoll.getName())) { +// val = removeTrailing0(result.getValue()); +// } +// } +// return val; +// } // -// 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 +// /** +// * Vérifie que le fichier de flux de syndication existe. +// * +// * @return vrai si le fichier existe +// */ +// @Log +// public boolean isFeedFileExisting() throws PollenBusinessException { +// File feedFile = getFeedContext().getFile(getPoll().getPollUId()); +// if (log.isDebugEnabled()) { +// log.debug("feed context path : " + getFeedContext().getContextPath()); +// log.debug("feed absolute path : " + feedFile.getAbsolutePath()); +// } +// return feedFile.exists() ? true : false; +// } +// +// /** +// * Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un +// * double : 1,0 -> 1 et 1,2 -> 1,2. +// * +// * @param val le nombre +// * @return le nombre sans 0 final +// */ +// private String removeTrailing0(String val) { +// if (val.endsWith(".0")) { +// val = val.substring(0, val.indexOf('.')); +// } +// return val; +// } +// +// /** +// * Retourne une chaîne contenant les résultats du sondage. +// * +// * @return les résultats +// */ +// public String getResultsAsString() throws PollenBusinessException { +// StringBuffer res = new StringBuffer(""); +// Iterator<ResultDTO> it = results.iterator(); +// while (it.hasNext()) { +// ResultDTO result = it.next(); +// if (isDateType()) { +// Date date = new Date(Long.parseLong(result.getName())); +// res.append(dateFormat.format(date)); // } else { -// restrictedListsForbidden = true; +// res.append(result.getName()); // } -// -// if (restrictedListsForbidden) { -//// voteForm.recordError(nameField, -//// messages.get("restrictedListsForbidden")); +// res.append("=" + removeTrailing0(result.getValue())); +// if (it.hasNext()) { +// res.append(", "); // } // } +// return res.toString(); +// } // -// // 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("-", "")); +// /** +// * Retourne true si le sondage est anonyme ou si le vote soumis est anonyme. +// * Utilisé lors de la soumission d'un vote. +// * +// * @return true si le vote est anonyme +// */ +// public boolean isVoteAnonymous() throws PollenBusinessException { +// return getPoll().isAnonymous() || anonymousVote; +// } +// +// /** +// * Retourne true si le sondage est anonyme ou si le vote courant est +// * anonyme. Utilisé dans la boucle de parcours des votes. +// * +// * @return true si le vote est anonyme +// */ +// public boolean isCurrentVoteAnonymous() throws PollenBusinessException { +// return getPoll().isAnonymous() || vote.isAnonymous(); +// } +// +// /** Retourne vrai si la checkbox anonymousVote doit être affichée. */ +// public boolean isAnonymousVoteDisplayed() throws PollenBusinessException { +// return getPoll().isAnonymousVoteAllowed() && !getPoll().isAnonymous(); +// } +// +// /** Retourne l'identifiant du votant du vote courant */ +// public String getCurrentVotingId() { +// return vote.getName(); +// } +// +// /** Validation du champs de saisie du choix (texte). */ +// void onValidateFromTextName(String value) throws ValidationException, PollenBusinessException { +// validateNewChoice(value); +// } +// +// /** Validation du champs de saisie du choix (date). */ +// 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, PollenBusinessException { +// validateNewChoice(value.getFileName().replace(' ', '_')); +// } +// +// /** Validation du champs de saisie du choix. */ +// 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)); // } // } +// } // -// //// Définition de l'userId -// if (userExists) { -// getPollAccount().setUserId(user.getId()); -// } else { -// getPollAccount().setUserId(""); +// /** Méthode appelée lors de l'ajout d'un choix. */ +// Object onSuccessFromChoiceForm() throws PollenBusinessException { +// String choiceName = null; +// String choiceDesc = null; +// if (isTextType()) { +// if (newChoice.getName() != null) { +// newChoice.setValidate(true); +// newChoice.setPollUId(getPoll().getPollUId()); +// getPoll().getChoices().add(newChoice); +// choiceName = newChoice.getName(); +// choiceDesc = newChoice.getDescription(); +// } +// } else if (isDateType()) { +// if (newDateChoice.getDate() != null) { +// newDateChoice.setValidate(true); +// newDateChoice.setPollUId(getPoll().getPollUId()); +// newDateChoice.setName(String.valueOf(newDateChoice.getDate() +// .getTime())); +// getPoll().getChoices().add(newDateChoice); +// Date date = new Date(Long.parseLong(newDateChoice.getName())); +// choiceName = dateFormat.format(date); +// choiceDesc = newDateChoice.getDescription(); +// } +// } else if (isImageType()) { +// if (newImageChoice.getImg() != null) { +// newImageChoice.setValidate(true); +// newImageChoice.setPollUId(getPoll().getPollUId()); +// newImageChoice.setName(newImageChoice.getImg().getFileName() +// .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); +// choiceName = newImageChoice.getName(); +// choiceDesc = newImageChoice.getDescription(); +// } // } // -// modifAllowed = isModifAllowed(getPollAccount().getVotingId()); -// if (alreadyVoted && !modifAllowed) { -//// voteForm.recordError(nameField, messages.format("alreadyVoted", -//// getPollAccount().getVotingId())); -// } +// servicePoll.updatePoll(getPoll()); +// poll = null; +// //poll = servicePoll.findPollByPollId(getPoll().getPollId()); +// addFeedEntry(PollAction.ADDCHOICE, choiceName, choiceDesc); +//// newChoice = new ChoiceDTO(); +//// newDateChoice = new DateChoiceUIO(); +//// newImageChoice = new ImageChoiceUIO(); +// return this; +// } // -// logger.debug("votingId: " + getPollAccount().getVotingId()); -// logger.debug("alreadyVoted: " + alreadyVoted); -// logger.debug("modifAllowed: " + modifAllowed); -// logger.debug("restrictedListsForbidden: " + restrictedListsForbidden); -// return ((!alreadyVoted || modifAllowed) && !restrictedListsForbidden); +//// public boolean isPollNull() { +//// return poll == null; +//// } +// +// +// public boolean isPollChoiceOrVoteStarted() throws PollenBusinessException { +// return isPollChoiceStarted() || isPollStarted(); // } - - /** - * 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 - * l'url est l'auteur du vote. - * - * @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; // -// // parcours des votes pour trouver celui correspondant au votingId -// // et contrôle du droit de modification -// while (i < getVotes().size() && !modifAllowed) { +//// public boolean isDescNull() { +//// return choiceOfPoll.getDescription() == null +//// || "".equals(choiceOfPoll.getDescription()); +//// } // -// // 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); -// } +// public boolean isFreePoll() throws PollenBusinessException { +// return getPoll().getPollType() == PollType.FREE; +// } // -// // si le votant du vote correspond au votant actuel (pollAccountId) -//// if (pollAccountId != null -//// && pollAccountId.equals(curr.getPollAccountId())) { -//// modifAllowed = true; -//// } +// public boolean isRestrictedPoll() throws PollenBusinessException { +// return getPoll().getPollType() == PollType.RESTRICTED; +// } // -// // si l'utilisateur du vote correspond à l'utilisateur actuel (user) -// if (userExists && user.getId().length() > 0) { -// modifAllowed = user.getId().equals(curr.getUserId()); -// } -// } +// public boolean isGroupPoll() throws PollenBusinessException { +// return getPoll().getPollType() == PollType.GROUP; +// } // -// i++; +// public boolean isTextType() throws PollenBusinessException { +// return getPoll().getChoiceType() == ChoiceType.TEXT; +// } +// +// public boolean isDateType() throws PollenBusinessException { +// return getPoll().getChoiceType() == ChoiceType.DATE; +// } +// +// public boolean isImageType() throws PollenBusinessException { +// return getPoll().getChoiceType() == ChoiceType.IMAGE; +// } +// +// public boolean isNormalVoteCounting() throws PollenBusinessException { +// return getPoll().getVoteCounting() == VoteCountingType.NORMAL; +// } +// +// public boolean isPercentageVoteCounting() throws PollenBusinessException { +// return getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE; +// } +// +// public boolean isCondorcetVoteCounting() throws PollenBusinessException { +// return getPoll().getVoteCounting() == VoteCountingType.CONDORCET; +// } +// +// public boolean isNumberVoteCounting() throws PollenBusinessException { +// return getPoll().getVoteCounting() == VoteCountingType.NUMBER; +// } +// +// /** Retourne le message d'aide correspondant au type de sondage. */ +// public String getHelpMessage() throws PollenBusinessException { +// switch (getPoll().getVoteCounting()) { +// case NORMAL: +// return messages.get("normalVote-help"); +// case PERCENTAGE: +// return messages.get("percentageVote-help"); +// case CONDORCET: +// return messages.get("condorcetVote-help"); +// case NUMBER: +// return messages.get("numberVote-help"); +// default: +// return ""; // } +// } // -// return modifAllowed; +// /** +// * Retourne la date correspondant au choix courant +// * +// * @return date +// */ +// public Date getChoiceNameAsDate() { +// return new Date(Long.valueOf(choiceOfPoll.getName())); // } - - /** 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().getPollUId(); - File feedFile = getFeedContext().getFile(getPoll().getPollUId()); - String title = null; - String content = null; - - switch (pollAction) { - case ADDVOTE: - if (isVoteAnonymous()) { - titleStr = messages.get("anonymous"); - } - title = messages.format("pollFeed_voteTitle", titleStr); - content = messages.format("pollFeed_voteContent", contentStr); - break; - case ADDCHOICE: - title = messages.format("pollFeed_choiceTitle", titleStr); - content = messages.format("pollFeed_choiceContent", contentStr); - break; - case ADDCOMMENT: - title = messages.format("pollFeed_commentTitle", titleStr); - content = messages.format("pollFeed_commentContent", contentStr); - break; - } - - if (!feedFile.exists()) { - FeedUtil.createFeed(feedFile, "atom_1.0", messages.format( - "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() throws PollenBusinessException { - 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", 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()); - 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 : getPoll().getPreventRuleDTOs()) { - PreventRuleManager manager = new PreventRuleManager(rule); - manager.execute("vote", getVotes().size(), data); - } - } - - public boolean isAddChoice() { - return addChoice; - } - - public void setAddChoice(boolean addChoice) { - choiceOfVote.setValue((addChoice) ? 1 : 0); - } - - public void setAddNumberVote(Integer value) { - if (value != null) { - choiceOfVote.setValue(value); - - } else { - choiceOfVote.setValue(-1); - } - } - - public Integer getAddNumberVote() { - return null; - } - - - /** - * Retourne si le choix fait partie du vote (s'il a été renseigné par le - * votant). - * - * @param choice le choix concerné - * @return true si le choix est dans le vote - */ - public Boolean isChoiceInVote(ChoiceDTO choice) throws PollenBusinessException { - if (choice != null) { - switch (getPoll().getVoteCounting()) { - case NORMAL: - return choice.getValue() > 0; - case PERCENTAGE: - return true; - case CONDORCET: - return choice.getValue() < 100; - case NUMBER: - return choice.getValue() >= 0; - } - } - return null; - } - - public boolean isChoiceHidden() { - return choiceOfPoll.isHidden(); - } - - /** - * Retourne le choix de vote correspondant au choix de sondage courant. - * - * @return un choix de vote - */ - @Property(write = false) - private ChoiceDTO currentVoteChoice; - - public char setCurrentVoteChoice() { -// currentVoteChoice = null; -// for (ChoiceDTO choice : vote.getChoiceDTOs()) { -// if (choice.getId().equals(choiceOfPoll.getId())) { -// currentVoteChoice = choice; -// break; +// +// /** Dépouillement du sondage. Mise à jour des résultats. */ +// private void countPoll() throws PollenBusinessException { +// ResultListDTO resultListDTO = null; +// if (getPoll().getContinuousResults()) { +// +// if (isGroupPoll()) { +// resultListDTO = serviceResults.getGroupResults(getPoll().getPollUId()); +// } else { +// resultListDTO = serviceResults.getNormalResults(getPoll().getPollUId()); // } +// +// results = resultListDTO.getResultDTOs(); +// +// if (logger.isDebugEnabled()) { +// for (ResultDTO res : results) { +// logger.debug(res.getName() + ": " + res.getValue() +// + ", (voteCounting=" + res.getVoteCounting() +// + ", byGroup=" + res.isByGroup() + ")"); +// } +// } // } - - return 0; - } - - /** - * Retourne le résultat correspondant au choix de sondage courant. - * - * @return le résultat du choix - */ - public String getCurrentChoiceResult() { - String val = ""; - for (ResultDTO result : results) { - if (result.getName().equals(choiceOfPoll.getName())) { - val = removeTrailing0(result.getValue()); - } - } - return val; - } - - /** - * Vérifie que le fichier de flux de syndication existe. - * - * @return vrai si le fichier existe - */ - @Log - public boolean isFeedFileExisting() throws PollenBusinessException { - File feedFile = getFeedContext().getFile(getPoll().getPollUId()); - if (log.isDebugEnabled()) { - log.debug("feed context path : " + getFeedContext().getContextPath()); - log.debug("feed absolute path : " + feedFile.getAbsolutePath()); - } - return feedFile.exists() ? true : false; - } - - /** - * Supprime le 0 final d'un nombre à virgule. Le résultat peut-être un - * double : 1,0 -> 1 et 1,2 -> 1,2. - * - * @param val le nombre - * @return le nombre sans 0 final - */ - private String removeTrailing0(String val) { - if (val.endsWith(".0")) { - val = val.substring(0, val.indexOf('.')); - } - return val; - } - - /** - * Retourne une chaîne contenant les résultats du sondage. - * - * @return les résultats - */ - public String getResultsAsString() throws PollenBusinessException { - StringBuffer res = new StringBuffer(""); - Iterator<ResultDTO> it = results.iterator(); - while (it.hasNext()) { - ResultDTO result = it.next(); - if (isDateType()) { - Date date = new Date(Long.parseLong(result.getName())); - res.append(dateFormat.format(date)); - } else { - res.append(result.getName()); - } - res.append("=" + removeTrailing0(result.getValue())); - if (it.hasNext()) { - res.append(", "); - } - } - return res.toString(); - } - - /** - * Retourne true si le sondage est anonyme ou si le vote soumis est anonyme. - * Utilisé lors de la soumission d'un vote. - * - * @return true si le vote est anonyme - */ - public boolean isVoteAnonymous() throws PollenBusinessException { - return getPoll().isAnonymous() || anonymousVote; - } - - /** - * Retourne true si le sondage est anonyme ou si le vote courant est - * anonyme. Utilisé dans la boucle de parcours des votes. - * - * @return true si le vote est anonyme - */ - public boolean isCurrentVoteAnonymous() throws PollenBusinessException { - return getPoll().isAnonymous() || vote.isAnonymous(); - } - - /** Retourne vrai si la checkbox anonymousVote doit être affichée. */ - public boolean isAnonymousVoteDisplayed() throws PollenBusinessException { - return getPoll().isAnonymousVoteAllowed() && !getPoll().isAnonymous(); - } - - /** Retourne l'identifiant du votant du vote courant */ - public String getCurrentVotingId() { - return vote.getName(); - } - - /** Validation du champs de saisie du choix (texte). */ - void onValidateFromTextName(String value) throws ValidationException, PollenBusinessException { - validateNewChoice(value); - } - - /** Validation du champs de saisie du choix (date). */ - 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, PollenBusinessException { - validateNewChoice(value.getFileName().replace(' ', '_')); - } - - /** Validation du champs de saisie du choix. */ - 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)); - } - } - } - - /** Méthode appelée lors de l'ajout d'un choix. */ - Object onSuccessFromChoiceForm() throws PollenBusinessException { - String choiceName = null; - String choiceDesc = null; - if (isTextType()) { - if (newChoice.getName() != null) { - newChoice.setValidate(true); - newChoice.setPollUId(getPoll().getPollUId()); - getPoll().getChoices().add(newChoice); - choiceName = newChoice.getName(); - choiceDesc = newChoice.getDescription(); - } - } else if (isDateType()) { - if (newDateChoice.getDate() != null) { - newDateChoice.setValidate(true); - newDateChoice.setPollUId(getPoll().getPollUId()); - newDateChoice.setName(String.valueOf(newDateChoice.getDate() - .getTime())); - getPoll().getChoices().add(newDateChoice); - Date date = new Date(Long.parseLong(newDateChoice.getName())); - choiceName = dateFormat.format(date); - choiceDesc = newDateChoice.getDescription(); - } - } else if (isImageType()) { - if (newImageChoice.getImg() != null) { - newImageChoice.setValidate(true); - newImageChoice.setPollUId(getPoll().getPollUId()); - newImageChoice.setName(newImageChoice.getImg().getFileName() - .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); - choiceName = newImageChoice.getName(); - choiceDesc = newImageChoice.getDescription(); - } - } - - servicePoll.updatePoll(getPoll()); - poll = null; - //poll = servicePoll.findPollByPollId(getPoll().getPollId()); - addFeedEntry(PollAction.ADDCHOICE, choiceName, choiceDesc); -// newChoice = new ChoiceDTO(); -// newDateChoice = new DateChoiceUIO(); -// newImageChoice = new ImageChoiceUIO(); - return this; - } - -// public boolean isPollNull() { -// return poll == null; // } - public boolean isPollChoiceOrVoteStarted() throws PollenBusinessException { - return isPollChoiceStarted() || isPollStarted(); - } -// public boolean isDescNull() { -// return choiceOfPoll.getDescription() == null -// || "".equals(choiceOfPoll.getDescription()); -// } - public boolean isFreePoll() throws PollenBusinessException { - return getPoll().getPollType() == PollType.FREE; - } - public boolean isRestrictedPoll() throws PollenBusinessException { - return getPoll().getPollType() == PollType.RESTRICTED; - } - public boolean isGroupPoll() throws PollenBusinessException { - return getPoll().getPollType() == PollType.GROUP; - } - public boolean isTextType() throws PollenBusinessException { - return getPoll().getChoiceType() == ChoiceType.TEXT; - } - public boolean isDateType() throws PollenBusinessException { - return getPoll().getChoiceType() == ChoiceType.DATE; - } - - public boolean isImageType() throws PollenBusinessException { - return getPoll().getChoiceType() == ChoiceType.IMAGE; - } - - public boolean isNormalVoteCounting() throws PollenBusinessException { - return getPoll().getVoteCounting() == VoteCountingType.NORMAL; - } - - public boolean isPercentageVoteCounting() throws PollenBusinessException { - return getPoll().getVoteCounting() == VoteCountingType.PERCENTAGE; - } - - public boolean isCondorcetVoteCounting() throws PollenBusinessException { - return getPoll().getVoteCounting() == VoteCountingType.CONDORCET; - } - - public boolean isNumberVoteCounting() throws PollenBusinessException { - return getPoll().getVoteCounting() == VoteCountingType.NUMBER; - } - - /** Retourne le message d'aide correspondant au type de sondage. */ - public String getHelpMessage() throws PollenBusinessException { - switch (getPoll().getVoteCounting()) { - case NORMAL: - return messages.get("normalVote-help"); - case PERCENTAGE: - return messages.get("percentageVote-help"); - case CONDORCET: - return messages.get("condorcetVote-help"); - case NUMBER: - return messages.get("numberVote-help"); - default: - return ""; - } - } - - /** - * Retourne la date correspondant au choix courant - * - * @return date - */ - public Date getChoiceNameAsDate() { - return new Date(Long.valueOf(choiceOfPoll.getName())); - } - - /** Dépouillement du sondage. Mise à jour des résultats. */ - private void countPoll() throws PollenBusinessException { - ResultListDTO resultListDTO = null; - if (getPoll().getContinuousResults()) { - - if (isGroupPoll()) { - resultListDTO = serviceResults.getGroupResults(getPoll().getPollUId()); - } else { - resultListDTO = serviceResults.getNormalResults(getPoll().getPollUId()); - } - - results = resultListDTO.getResultDTOs(); - - if (logger.isDebugEnabled()) { - for (ResultDTO res : results) { - logger.debug(res.getName() + ": " + res.getValue() - + ", (voteCounting=" + res.getVoteCounting() - + ", byGroup=" + res.isByGroup() + ")"); - } - } - } - } - - - - - - - - - ////////////////// NEW IMPLEMENTATION + @Inject + private Logger log; + @Inject + private Messages messages; @Inject private PollenContext pollen; @@ -964,12 +939,30 @@ @InjectComponent private Border border; + + /** TEMP : Affichage des messages pour l'utilisateur */ + @Component(id = "feedback") + private FeedBack feedback; + @Parameter(defaultPrefix = BindingConstants.MESSAGE, value = "title") + @Property + private String title; + + /** Locale courante */ + @Inject + private Locale currentLocale; + + @Inject + private ServicePoll servicePoll; + + @Inject + private ServiceUser serviceUser; + /** * Sondage pour lequel l'utilisateur vote */ @Persist - private PollDTO poll; + private Poll poll; @Property private boolean pollNull; @@ -978,12 +971,13 @@ * Objet de session représentant l'utilisateur identifié. */ @SessionState - private UserDTO user; + private UserAccount user; + @Property private boolean userExists; /** Compte du votant */ - private PollAccountDTO pollAccount; + private PollAccount pollAccount; /** Format des dates */ private DateFormat dateFormat; @@ -1018,7 +1012,7 @@ poll = null; getPoll(); - if (getPoll().isClosed()) { + if (getPoll().getClosed()) { feedback.addInfo(messages.get("pollClosed")); } else if (!isPollStarted()) { feedback.addInfo(messages.get("pollNotStarted")); @@ -1029,7 +1023,7 @@ feedback.addInfo(messages.get("pollChoiceRunning")); } - countPoll(); + //countPoll(); } catch (PollenBusinessException eee) { feedback.addError(messages.get(eee.getMessage())); pollNull = true; @@ -1058,16 +1052,16 @@ return dateFormat; } - public PollDTO getPoll() throws PollenBusinessException { + public Poll getPoll() throws PollenBusinessException { if (poll == null) { - poll = servicePoll.getPoll(uri.getPollUId()); + poll = servicePoll.getPollForVote(uri.getPollUId()); if (poll != null) { // Initialisations pour les formulaires // newChoice = new ChoiceDTO(); - newDateChoice = new DateChoiceUIO(); - newImageChoice = new ImageChoiceUIO(); +// newDateChoice = new DateChoiceUIO(); +// newImageChoice = new ImageChoiceUIO(); } else { throw new PollenBusinessException( PollenExceptionType.POLL_NOT_EXIST); @@ -1089,7 +1083,7 @@ } public boolean isPollRunning() throws PollenBusinessException { - return isPollStarted() && !isPollFinished() && !getPoll().isClosed(); + return isPollStarted() && !isPollFinished() && !getPoll().getClosed(); } /** @@ -1100,17 +1094,16 @@ * * @return */ - public PollAccountDTO getPollAccount() { + public PollAccount getPollAccount() throws PollenBusinessException { if (pollAccount == null) { // Identification du votant if (uri.getAccountUId() != null) { - pollAccount = servicePollAccount - .findPollAccountByAccountId(uri.getAccountUId()); + pollAccount = serviceUser.getPerson(uri.getAccountUId()); // pollAccountId = pollAccount.getId(); } if (pollAccount == null) { - pollAccount = serviceVote.getNewPollAccount(user);//new PollAccountDTO(); + pollAccount = serviceUser.getNewPerson(user);//new PollAccountDTO(); // if (userExists) { // if (user.getFirstName() != null && user.getLastName() != null) { // pollAccount.setVotingId( @@ -1135,7 +1128,7 @@ * @throws PollenBusinessException */ public boolean isCreatorUser() throws PollenBusinessException { - return userExists && user.getId().equals(getPoll().getUserId()); + return userExists && user.equals(getPoll().getCreator().getUserAccount()); } /************** PAGER *****************************************************/ @@ -1182,11 +1175,14 @@ } 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()); + // FIXME : manage nbVotes in Poll + +// if (getPoll().getNbVotes() == 0) { +// return messages.get("pollen.ui.vote.noVote"); +// } +// return messages.format("pollen.ui.vote.noPager", +// getPoll().getNbVotes()); + return ""; } /************** CHOICES ***************************************************/ @@ -1236,7 +1232,7 @@ log.info("Prepare choices for render"); } choices = new ArrayList<ChoiceField>(); - for (ChoiceDTO curr : getPoll().getChoices()) { + for (Choice curr : getPoll().getChoice()) { ChoiceField field = new ChoiceField(getPoll(), curr); choices.add(field); } @@ -1326,7 +1322,7 @@ // newChoice = ChoiceField.getChoiceText(); // } // Don't know what validate is - newChoice.setValidate(true); +// newChoice.setValidate(true); } return newChoice; } @@ -1351,7 +1347,7 @@ // } public boolean isPollChoiceRunning() throws PollenBusinessException { - return getPoll().isChoiceAddAllowed() && isPollChoiceStarted(); + return getPoll().getChoiceAddAllowed() && isPollChoiceStarted(); } /** @@ -1379,7 +1375,8 @@ void onActionFromDeleteChoice(String choiceId) throws PollenBusinessException { if (getCanDeleteChoice()) { - servicePoll.deleteChoice(getPoll(), choiceId); + +// servicePoll.deleteChoice(getPoll(), choiceId); // Reset choices (ChoiceField list) to retrieve the updated one // from poll choices = null; @@ -1400,18 +1397,18 @@ // No validation done on choice with existing name // Save name depends on choice type newChoice.saveName(serviceImage); - servicePoll.createChoice(getPoll(), newChoice); + //getPoll().addChoice(newChoice.getChoice()); } } /************** VOTES *****************************************************/ - private List<VoteDTO> votes; + private List<Vote> votes; @Property private int voteIndex; - private VoteDTO currentVote; + private Vote currentVote; /** * Retrieve votes of the current poll from business module. @@ -1421,45 +1418,45 @@ * @return the list of votes to display * @throws PollenBusinessException */ - public List<VoteDTO> getVotes() throws PollenBusinessException { + public List<Vote> getVotes() throws PollenBusinessException { if (votes == null) { - votes = serviceVote.getVotesByPoll(getPoll(), - pager.getStartIndex(), pager.getEndIndex()); +// votes = servicePoll.getVotes(getPoll(), +// pager.getStartIndex(), pager.getEndIndex()); } return votes; } - public VoteDTO getCurrentVote() { + public Vote getCurrentVote() { if (currentVote == null) { - currentVote = serviceVote.getNewVote(getPollAccount()); +// 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(); - } +// /** +// * 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().getAnonymous() || isRestrictedPoll() || isGroupPoll(); +// } public void setChoiceValue(Integer value) { - getCurrentVote().setChoiceValue(choice.getId(), value); +// getCurrentVote().setChoiceValue(choice.getId(), value); } - public Integer getChoiceValue() { - return getCurrentVote().getChoiceValue(choice.getId()); - } +// public Integer getChoiceValue() { +// return getCurrentVote().getChoiceValue(choice.getId()); +// } public boolean getCanVote() throws PollenBusinessException { return isPollRunning(); @@ -1467,17 +1464,17 @@ 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; - } +// 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; } @@ -1493,20 +1490,20 @@ @InjectComponent private Zone commentZone; - private List<CommentDTO> comments; + private List<Comment> comments; /** Commentaire courant pour l'affichage des commentaires */ @SuppressWarnings("unused") @Property @Persist - private CommentDTO comment; + private Comment comment; /** Nouveau commentaire posté */ - private CommentDTO newComment; + private Comment newComment; - public List<CommentDTO> getComments() throws PollenBusinessException { + public List<Comment> getComments() throws PollenBusinessException { if (comments == null) { - comments = servicePoll.getComments(poll); + comments = servicePoll.getComments(poll, -1, -1); } return comments; } @@ -1516,9 +1513,9 @@ * * @return the current newComment. */ - public CommentDTO getNewComment() { + public Comment getNewComment() { if (newComment == null) { - newComment = new CommentDTO(); + newComment = new CommentImpl(); } return newComment; } @@ -1531,7 +1528,7 @@ * @throws PollenBusinessException */ Object onActionFromDeleteComment(String commentId) throws PollenBusinessException { - servicePoll.deleteComment(getPoll(), commentId); +// servicePoll.deleteComment(getPoll(), commentId); return commentZone.getBody(); } @@ -1547,11 +1544,11 @@ 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()); +// 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/pages/user/Account.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Account.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -29,10 +29,9 @@ import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServiceAuth; -import org.chorem.pollen.business.services.ServiceUser; -import org.chorem.pollen.business.utils.MD5; +import org.chorem.pollen.MD5; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.data.AddressBarItem; /** @@ -50,7 +49,7 @@ */ @SessionState @Property - private UserDTO user; + private UserAccount user; @Property private boolean userExists; @@ -60,7 +59,7 @@ */ @Property @Persist - private UserDTO newUser; + private UserAccount newUser; /** Ancien mot de passe */ @Persist @@ -119,8 +118,8 @@ /** Injection des services */ @Inject private ServiceUser serviceUser; - @Inject - private ServiceAuth serviceAuth; +// @Inject +// private ServiceAuth serviceAuth; /** * Méthode appelée quand l'utilisateur modifie ses données @@ -129,40 +128,40 @@ */ Object onSuccessFromMyAccountForm() { modify = true; +// +// // L'utilisateur a renseigné le mauvais mot de passe +// if (!serviceAuth.isLoginRight(newUser.getLogin(), MD5.encode(password))) { +// myAccountForm.recordError(passwordField, messages +// .get("badPassword")); +// } +// +// // L'utilisateur ne s'est pas trompé en répétant son mot de passe +// if (newPassword1 != null && !newPassword1.equals("")) { +// if (!newPassword1.equals(newPassword2)) { +// myAccountForm.recordError(newPasswordField, messages +// .get("passwords-dont-match")); +// } +// } +// +// // L'email existe déjà +// if (!oldEmail.equals(newUser.getEmail())) { +// if (serviceUser.isUserEmailExisting(newUser.getEmail())) { +// myAccountForm.recordError(emailField, messages +// .get("emailAlreadyExists")); +// } +// } +// +// // Modification de l'utilisateur +// if (!myAccountForm.getHasErrors()) { +// if (serviceUser.updateUser(newUser)) { +// if (newPassword1 != null && !newPassword1.equals("")) { +// serviceUser.updatePasswordUser(newUser, MD5 +// .encode(newPassword1)); +// } +// modify = false; +// } +// } - // L'utilisateur a renseigné le mauvais mot de passe - if (!serviceAuth.isLoginRight(newUser.getLogin(), MD5.encode(password))) { - myAccountForm.recordError(passwordField, messages - .get("badPassword")); - } - - // L'utilisateur ne s'est pas trompé en répétant son mot de passe - if (newPassword1 != null && !newPassword1.equals("")) { - if (!newPassword1.equals(newPassword2)) { - myAccountForm.recordError(newPasswordField, messages - .get("passwords-dont-match")); - } - } - - // L'email existe déjà - if (!oldEmail.equals(newUser.getEmail())) { - if (serviceUser.isUserEmailExisting(newUser.getEmail())) { - myAccountForm.recordError(emailField, messages - .get("emailAlreadyExists")); - } - } - - // Modification de l'utilisateur - if (!myAccountForm.getHasErrors()) { - if (serviceUser.updateUser(newUser)) { - if (newPassword1 != null && !newPassword1.equals("")) { - serviceUser.updatePasswordUser(newUser, MD5 - .encode(newPassword1)); - } - modify = false; - } - } - return myAccountZone.getBody(); } 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/Register.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -30,13 +30,12 @@ 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.PollenContext; -import org.chorem.pollen.business.PollenProperty; -import org.chorem.pollen.business.business.PreventRuleManager; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServiceAuth; -import org.chorem.pollen.business.services.ServiceUser; -import org.chorem.pollen.business.utils.MD5; +import org.chorem.pollen.MD5; +import org.chorem.pollen.PollenContext; +import org.chorem.pollen.PollenProperty; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.mail.PreventRuleManager; +import org.chorem.pollen.service.ServiceUser; import org.chorem.pollen.ui.data.AddressBarItem; /** @@ -60,7 +59,7 @@ */ @SuppressWarnings("unused") @SessionState - private UserDTO user; + private UserAccount user; @SuppressWarnings("unused") @Property private boolean userExists; @@ -69,7 +68,7 @@ * Utilisateur créé via le formulaire */ @Property - private UserDTO newUser = new UserDTO(); + private UserAccount newUser; @Component private Form registerForm; @@ -108,8 +107,8 @@ /** Injection des services */ @Inject private ServiceUser serviceUser; - @Inject - private ServiceAuth serviceAuth; +// @Inject +// private ServiceAuth serviceAuth; /** * Méthode appelée quand l'utilisateur s'enregistre @@ -126,27 +125,27 @@ } // Le login existe déjà - if (serviceUser.isUserLoginExisting(newUser.getLogin())) { - registerForm.recordError(loginField, messages - .get("loginAlreadyExists")); - } +// if (serviceUser.isUserLoginExisting(newUser.getLogin())) { +// registerForm.recordError(loginField, messages +// .get("loginAlreadyExists")); +// } +// +// // L'email existe déjà +// if (serviceUser.isUserEmailExisting(newUser.getEmail())) { +// registerForm.recordError(emailField, messages +// .get("emailAlreadyExists")); +// } +// +// // Création de l'utilisateur, envoi d'un email de notification et connexion +// if (!registerForm.getHasErrors()) { +// if (serviceUser.createUser(newUser, MD5.encode(password1)) != null) { +// sendMailNotification(); +// user = serviceAuth.getUser(newUser.getLogin(), MD5 +// .encode(password1)); +// return "Index"; +// } +// } - // L'email existe déjà - if (serviceUser.isUserEmailExisting(newUser.getEmail())) { - registerForm.recordError(emailField, messages - .get("emailAlreadyExists")); - } - - // Création de l'utilisateur, envoi d'un email de notification et connexion - if (!registerForm.getHasErrors()) { - if (serviceUser.createUser(newUser, MD5.encode(password1)) != null) { - sendMailNotification(); - user = serviceAuth.getUser(newUser.getLogin(), MD5 - .encode(password1)); - return "Index"; - } - } - return this; } Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -16,7 +16,6 @@ package org.chorem.pollen.ui.pages.user; -import java.util.Iterator; import java.util.List; import org.apache.commons.fileupload.FileUploadException; @@ -37,11 +36,8 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.BeanModelSource; import org.apache.tapestry5.upload.services.UploadedFile; -import org.chorem.pollen.business.dto.PersonListDTO; -import org.chorem.pollen.business.dto.PollAccountDTO; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServiceList; -import org.chorem.pollen.business.services.ServicePollAccount; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.ui.components.FeedBack; import org.chorem.pollen.ui.data.EvenOdd; import org.chorem.pollen.ui.data.AddressBarItem; @@ -63,7 +59,7 @@ * Objet de session représentant l'utilisateur identifié. */ @SessionState - private UserDTO user; + private UserAccount user; @Property private boolean userExists; @@ -74,34 +70,34 @@ /** * Listes de favoris de l'utilisateur. */ - @Property - private List<PersonListDTO> lists; +// @Property +// private List<PersonListDTO> lists; - /** - * Liste de favoris sélectionnée. - */ - @Persist - @Property - private PersonListDTO selectedList; +// /** +// * Liste de favoris sélectionnée. +// */ +// @Persist +// @Property +// private PersonListDTO selectedList; +// +// /** +// * Nouvelle liste de favoris. +// */ +// @Property +// private PersonListDTO newList; /** - * Nouvelle liste de favoris. - */ - @Property - private PersonListDTO newList; - - /** * Compte courant (pour l'itération des votants de la liste). */ @SuppressWarnings("unused") @Property - private PollAccountDTO account; + private PollAccount account; /** * Nouveau compte. */ @Property - private PollAccountDTO newAccount; + private PollAccount newAccount; /** * Fichier CSV contenant une liste de votants. @@ -175,66 +171,66 @@ private BeanModel listModel; /** Injection des services */ - @Inject - private ServiceList serviceList; - @Inject - private ServicePollAccount servicePollAccount; +// @Inject +// private ServiceList serviceList; +// @Inject +// private ServicePollAccount servicePollAccount; /** * Méthode appelée à la création d'une liste. */ Object onSuccessFromCreateListForm() { +// +// // Contrôle du nom de la liste +// for (PersonListDTO list : lists) { +// if (list.getName().equals(newList.getName())) { +// createListForm.recordError(messages.format("listExists", +// newList.getName())); +// return this; +// } +// } +// +// // Import CVS des comptes +// if (accountsFile != null) { +// if (!accountsFile.getContentType().equals("text/csv")) { +// createListForm.recordError(messages.format("invalidCsv", +// accountsFile.getFileName())); +// return this; +// } +// List<PollAccountDTO> accounts = CSVAccountUtil +// .importList(accountsFile); +// if (accounts.size() == 0) { +// createListForm.recordError(messages.format("noAccountCsv", +// accountsFile.getFileName())); +// return this; +// } +// newList.getPollAccounts().addAll(accounts); +// } +// +// // Import LDAP des comptes +// if (accountsUrl != null) { +// List<PollAccountDTO> accounts = LDAPAccountUtil +// .importList(accountsUrl); +// if (accounts.size() == 0) { +// createListForm.recordError(messages.format("noAccountLdap", +// accountsUrl)); +// return this; +// } +// newList.getPollAccounts().addAll(accounts); +// } +// +// // Création de la nouvelle liste +// newList.setUserId(user.getId()); +// newList.setId(serviceList.createPersonList(newList)); +// +// // Sélection de la liste courante +// lists = serviceList.findPersonListByUser(user.getId()); +// for (PersonListDTO list : lists) { +// if (list.getId().equals(newList.getId())) { +// selectedList = list; +// } +// } - // Contrôle du nom de la liste - for (PersonListDTO list : lists) { - if (list.getName().equals(newList.getName())) { - createListForm.recordError(messages.format("listExists", - newList.getName())); - return this; - } - } - - // Import CVS des comptes - if (accountsFile != null) { - if (!accountsFile.getContentType().equals("text/csv")) { - createListForm.recordError(messages.format("invalidCsv", - accountsFile.getFileName())); - return this; - } - List<PollAccountDTO> accounts = CSVAccountUtil - .importList(accountsFile); - if (accounts.size() == 0) { - createListForm.recordError(messages.format("noAccountCsv", - accountsFile.getFileName())); - return this; - } - newList.getPollAccounts().addAll(accounts); - } - - // Import LDAP des comptes - if (accountsUrl != null) { - List<PollAccountDTO> accounts = LDAPAccountUtil - .importList(accountsUrl); - if (accounts.size() == 0) { - createListForm.recordError(messages.format("noAccountLdap", - accountsUrl)); - return this; - } - newList.getPollAccounts().addAll(accounts); - } - - // Création de la nouvelle liste - newList.setUserId(user.getId()); - newList.setId(serviceList.createPersonList(newList)); - - // Sélection de la liste courante - lists = serviceList.findPersonListByUser(user.getId()); - for (PersonListDTO list : lists) { - if (list.getId().equals(newList.getId())) { - selectedList = list; - } - } - return this; } @@ -242,20 +238,20 @@ * Méthode appelée à la suppression d'une liste. */ Object onActionFromDeleteList() { - if (selectedList != null) { - for (PersonListDTO dto : lists) { - if (dto.getId().equals(selectedList.getId())) { - if (serviceList.deletePersonList(selectedList.getId())) { - feedback.addInfo(messages.format("listDeleted", - selectedList.getName())); - } else { - feedback.addError(messages.format("listNotDeleted", - selectedList.getName())); - } - } - } - } - selectedList = null; +// if (selectedList != null) { +// for (PersonListDTO dto : lists) { +// if (dto.getId().equals(selectedList.getId())) { +// if (serviceList.deletePersonList(selectedList.getId())) { +// feedback.addInfo(messages.format("listDeleted", +// selectedList.getName())); +// } else { +// feedback.addError(messages.format("listNotDeleted", +// selectedList.getName())); +// } +// } +// } +// } +// selectedList = null; return this; } @@ -265,19 +261,19 @@ Object onSuccessFromCreateAccountForm() { // TODO : use onValidateForm method : test return block, may be // a problem between failure and success - for (PollAccountDTO dto : selectedList.getPollAccounts()) { - if (dto.getVotingId().equals(newAccount.getVotingId())) { - createAccountForm.recordError(messages.format("accountExists", - newAccount.getVotingId())); - } - } - if (!createAccountForm.getHasErrors()) { -// newAccount.setPersonListId(selectedList.getId()); -// selectedList.getPollAccounts().add(newAccount); -// serviceList.updatePersonList(selectedList); -// selectedList = serviceList.findPersonListById(selectedList.getId()); - serviceList.createAccountInPersonList(selectedList, account); - } +// for (PollAccountDTO dto : selectedList.getPollAccounts()) { +// if (dto.getVotingId().equals(newAccount.getVotingId())) { +// createAccountForm.recordError(messages.format("accountExists", +// newAccount.getVotingId())); +// } +// } +// if (!createAccountForm.getHasErrors()) { +//// newAccount.setPersonListId(selectedList.getId()); +//// selectedList.getPollAccounts().add(newAccount); +//// serviceList.updatePersonList(selectedList); +//// selectedList = serviceList.findPersonListById(selectedList.getId()); +// serviceList.createAccountInPersonList(selectedList, account); +// } return listsZone.getBody(); } @@ -295,7 +291,7 @@ // serviceList.updatePersonList(selectedList); // servicePollAccount.deletePollAccount(accountId); // selectedList = serviceList.findPersonListById(selectedList.getId()); - serviceList.deleteAccountFromPersonList(selectedList, accountId); +// serviceList.deleteAccountFromPersonList(selectedList, accountId); return listsZone.getBody(); } @@ -307,26 +303,26 @@ return this; } - /** Retourne vrai s'il n'existe aucune liste */ - public boolean isListsNull() { - return lists == null || lists.size() == 0; - } +// /** Retourne vrai s'il n'existe aucune liste */ +// public boolean isListsNull() { +// return lists == null || lists.size() == 0; +// } +// +// /** Retourne vrai si la liste sélectionnée est vide */ +// public boolean isSelectedListNull() { +// return selectedList == null; +// } - /** Retourne vrai si la liste sélectionnée est vide */ - public boolean isSelectedListNull() { - return selectedList == null; - } - /** * Méthode d'initialisation des listes de favoris. */ void onActivate() { evenOdd = new EvenOdd(); - if (userExists) { - lists = serviceList.findPersonListByUser(user.getId()); - } - newList = new PersonListDTO(); - newAccount = new PollAccountDTO(); +// if (userExists) { +// lists = serviceList.findPersonListByUser(user.getId()); +// } +// newList = new PersonListDTO(); +// newAccount = new PollAccountDTO(); } /** @@ -336,7 +332,7 @@ address = new AddressBarItem[] { new AddressBarItem("Pollen", "Index"), new AddressBarItem(title, null) }; - listModel = beanModelSource.createDisplayModel(PollAccountDTO.class, + listModel = beanModelSource.createDisplayModel(PollAccount.class, componentResources.getMessages()); listModel.add("functions", null); listModel.include("votingId", "email", "functions"); Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsCreated.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -25,10 +25,9 @@ import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.upload.services.UploadedFile; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.dto.UserDTO; -import org.chorem.pollen.business.services.ServicePoll; -import org.chorem.pollen.business.services.ServiceResults; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.base.Polls; /** @@ -46,7 +45,7 @@ * Objet de session représentant l'utilisateur identifié. */ @SessionState - private UserDTO user; + private UserAccount user; private boolean userExists; /** @@ -54,7 +53,7 @@ */ @SuppressWarnings("unused") @Property - private List<PollDTO> polls; + private List<Poll> polls; /** * Fichier XML d'un sondage exporté. @@ -77,8 +76,8 @@ /** Injection des services */ @Inject private ServicePoll servicePoll; - @Inject - private ServiceResults serviceResults; +// @Inject +// private ServiceResults serviceResults; /** * Méthode appelée à l'importation d'un sondage. @@ -92,7 +91,7 @@ pollFile.getFileName())); return this; } - serviceResults.importPoll(pollFile.getFilePath(), user); +// serviceResults.importPoll(pollFile.getFilePath(), user); } return this; @@ -105,7 +104,7 @@ public void onActivate() { super.onActivate(); if (userExists) { - polls = servicePoll.findPollsByUser(user.getId()); + polls = servicePoll.getPollsByUser(user); } } } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserPollsParticipated.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -22,12 +22,11 @@ import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.ioc.annotations.Inject; -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.VotingListDTO; -import org.chorem.pollen.business.services.ServicePoll; +import org.chorem.pollen.entity.Poll; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.service.ServicePoll; import org.chorem.pollen.ui.base.Polls; +import org.chorem.pollen.votecounting.dto.PollDTO; /** * Classe de la page d'affichage des sondages auxquels l'utilisateur a @@ -44,7 +43,7 @@ * Objet de session représentant l'utilisateur identifié. */ @SessionState - private UserDTO user; + private UserAccount user; private boolean userExists; /** @@ -52,14 +51,14 @@ */ @SuppressWarnings("unused") @Property - private List<PollDTO> participatedPolls; + private List<Poll> participatedPolls; /** * Liste des sondages auxquels l'utilisateur est invité */ @SuppressWarnings("unused") @Property - private List<PollDTO> invitedPolls; + private List<Poll> invitedPolls; /** Injection des services */ @Inject @@ -70,15 +69,15 @@ * * @return l'identifiant. */ - public String getVoteId(PollDTO poll) { - for (VotingListDTO list : poll.getVotingListDTOs()) { - for (PollAccountDTO account : list.getPollAccountDTOs()) { - if (account.getEmail().equals(user.getEmail())) { - return poll.getPollUId() + ":" + account.getAccountUId(); - } - } - } - return poll.getPollUId(); + public String getVoteId(Poll poll) { +// for (VotingListDTO list : poll.getVotingListDTOs()) { +// for (PollAccountDTO account : list.getPollAccountDTOs()) { +// if (account.getEmail().equals(user.getEmail())) { +// return poll.getPollUId() + ":" + account.getAccountUId(); +// } +// } +// } + return poll.getUId(); } /** @@ -88,8 +87,8 @@ public void onActivate() { super.onActivate(); if (userExists) { - participatedPolls = servicePoll.findParticipatedPolls(user.getId()); - invitedPolls = servicePoll.findInvitedPolls(user.getId()); + invitedPolls = participatedPolls = servicePoll.getPollsByUser(user); +// invitedPolls = servicePoll.findInvitedPolls(user.getId()); } } } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/AppModule.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -19,33 +19,20 @@ 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.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.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.PollenContext; +import org.chorem.pollen.PollenContextImpl; +import org.chorem.pollen.PollenContextImplementor; +import org.chorem.pollen.service.ServicePoll; +import org.chorem.pollen.service.ServicePollImpl; +import org.chorem.pollen.service.ServiceUser; +import org.chorem.pollen.service.ServiceUserImpl; import org.chorem.pollen.ui.data.PollUri; /** @@ -58,17 +45,6 @@ public class AppModule { public static void bind(ServiceBinder binder) { - // 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); } /** @@ -82,45 +58,20 @@ return context; } - /** 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); + ServiceUserImpl service = new ServiceUserImpl(); + service.setContext(context); + return service; } public static ServicePoll buildServicePoll( @InjectService("PollenContext") PollenContextImplementor context) { - return new ServicePollImpl(context); + ServicePollImpl service = new ServicePollImpl(); + service.setContext(context); + return service; } - /** 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); - } - public static ServiceImage buildServiceImage( @InjectService("PollenContext") PollenContextImplementor context) { return new ServiceImageImpl(context); @@ -184,14 +135,14 @@ * This is the BackgroundWorker service definition. It build the service * giving a Messages object for localization in the service. */ - @EagerLoad - public static BackgroundWorker buildBackgroundWorker( - ComponentSource componentSource, - ServicePoll servicePoll, PollenContext context) { - Messages messages = componentSource.getPage("LocalMessages") - .getComponentResources().getMessages(); - return new BackgroundWorkerImpl(messages, servicePoll, context); - } +// @EagerLoad +// public static BackgroundWorker buildBackgroundWorker( +// ComponentSource componentSource, +// ServicePoll servicePoll, PollenContext context) { +// Messages messages = componentSource.getPage("LocalMessages") +// .getComponentResources().getMessages(); +// return new BackgroundWorkerImpl(messages, servicePoll, context); +// } /** * Make configuration from a Properties file available as symbols. Deleted: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorker.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorker.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorker.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,28 +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.services; - -/** - * Service lancé en parallèle de l'application. Ce service permet d'effectuer - * des actions en arrière-plan. - * - * @author rannou - * @version $Id$ - */ -public interface BackgroundWorker { - -} Deleted: 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/BackgroundWorkerImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,175 +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.services; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; - -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; -import org.chorem.pollen.business.dto.PollDTO; -import org.chorem.pollen.business.dto.PreventRuleDTO; -import org.chorem.pollen.business.dto.VotingListDTO; -import org.chorem.pollen.business.services.ServicePoll; -import org.chorem.pollen.business.services.ServicePreventRule; -import org.chorem.pollen.business.services.ServicePreventRuleImpl; - -/** - * Implémentation du service BackgroundWorker. - * - * @author rannou - * @version $Id$ - */ -public class BackgroundWorkerImpl implements BackgroundWorker { - - /** Timer gérant les threads. */ - private Timer timer; - - /** log. */ - private static final Log log = LogFactory - .getLog(BackgroundWorkerImpl.class); - - /** Messages internationalisés **/ - private final Messages messages; - - /** 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, PollenContext context) { - this.context = context; - this.messages = messages; - this.servicePoll = servicePoll; - - timer = new Timer(); - executeTasks(); - } - - /** - * Lancement des tâches en arrière-plan. - */ - public void executeTasks() { - if (!context.hasProperty(PollenProperty.SERVER_URL)) { - log.warn("No property siteUrl. Reminder emails would not contain it"); - } - - // Exécution de la tâche toutes les 10 min - timer.schedule(new MailingTask(), 600000, 600000); - } - - /** - * Tâche gérant l'envoi de mails de rappels. - */ - private class MailingTask extends TimerTask { - - @Override - public void run() { - if (log.isDebugEnabled()) { - log.debug("MailingTask running..."); - } - - // Récupération des sondages en cours - List<PollDTO> polls = servicePoll.findRunningPolls(true); - - for (PollDTO poll : polls) { - Date now = new Date(); - - // Parcours des preventRules de chaque sondage - // envoi d'un email si endDate-nowDate <= preventRuleSensibility - if (poll.getEndDate() != null) { - - // timeValue = endDate-nowDate - Long timeValue = poll.getEndDate().getTime() - - now.getTime(); - - if (log.isDebugEnabled()) { - log.debug("Now: " + now.getTime() + " End: " - + poll.getEndDate().getTime() + " timeValue: " - + timeValue + "(" + timeValue / 3600000 + "h)"); - } - - // envoi des mails avec une sensibilité de l'ordre de l'heure - sendMailNotification(poll, timeValue / 3600000); - } - } - } - } - - /** - * Envoi du mail de notification. - * - * @param poll sondage concerné - */ - private void sendMailNotification(PollDTO poll, Long timeValue) { - String voteURL = context.getProperty(PollenProperty.SERVER_URL) + - "/poll/VoteFor/" + poll.getPollUId(); - Map<String, String> data = new HashMap<String, String>(); - 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()) { - if (rule.isActive()) { - Boolean hasRun = false; - PreventRuleManager manager = new PreventRuleManager(rule); - for (VotingListDTO list : poll.getVotingListDTOs()) { - for (PollAccountDTO account : list.getPollAccountDTOs()) { - if (account.getEmail() != null) { - String accountVoteURL = voteURL + ":" - + account.getAccountUId(); - - data.put("to", account.getEmail()); - data.put("title", messages.format( - "reminderEmail_subject", poll.getTitle())); - data.put("msg", messages.format( - "reminderEmail_msg", poll.getTitle(), - account.getVotingId(), accountVoteURL)); - - // Exécution de la règle avec une valeur +1 - // Sensibilité de 2h : 2h05 KO, 1h55 OK - hasRun = manager.execute("rappel", timeValue - .intValue() + 1, data); - } - } - } - - // désactivation de la règle de rappel pour éviter qu'elle soit réexécutée - if (hasRun) { - rule.setActive(false); - ServicePreventRule spr = new ServicePreventRuleImpl((PollenContextImplementor)context); - spr.updatePreventRule(rule); - } - } - } - } -} Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenManager.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,58 +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.services; - -import org.apache.commons.logging.Log; -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 - * fermeture du registre Tapestry. - * - * @author rannou - * @version $Id$ - */ -public class PollenManager implements RegistryShutdownListener /*, Runnable */{ - - private static final Log log = LogFactory.getLog(PollenManager.class); - - 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"); - } - 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PropertiesFileSymbolProvider.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -10,7 +10,7 @@ import org.apache.tapestry5.ioc.services.SymbolProvider; import org.apache.tapestry5.ioc.util.CaseInsensitiveMap; -import org.chorem.pollen.business.PollenContext; +import org.chorem.pollen.PollenContext; import org.slf4j.Logger; public class PropertiesFileSymbolProvider implements SymbolProvider { 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/ServiceImageImpl.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -16,8 +16,8 @@ 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.chorem.pollen.PollenProperty; +import org.chorem.pollen.PollenContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/CSVAccountUtil.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -24,10 +24,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tapestry5.upload.services.UploadedFile; -import org.chorem.pollen.business.dto.PollAccountDTO; import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy; import au.com.bytecode.opencsv.bean.CsvToBean; +import org.chorem.pollen.entity.PollAccount; /** * Classe permettant de gérer l'import de listes de votants au format CSV. @@ -48,24 +48,24 @@ * @param reader which contains the input stream * @return the new PollAccountDTO list from results imported */ - public static List<PollAccountDTO> importList(Reader reader) { - List<PollAccountDTO> accounts = null; + public static List<PollAccount> importList(Reader reader) { + List<PollAccount> 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); + ColumnPositionMappingStrategy<PollAccount> strat = + new ColumnPositionMappingStrategy<PollAccount>(); + String[] columns = new String[] { "name", "email", "weight" }; + strat.setType(PollAccount.class); strat.setColumnMapping(columns); // Parsing du fichier CSV - CsvToBean<PollAccountDTO> csv = new CsvToBean<PollAccountDTO>(); + CsvToBean<PollAccount> csv = new CsvToBean<PollAccount>(); accounts = csv.parse(strat, reader); // Suppression des comptes null - Iterator<PollAccountDTO> it = accounts.iterator(); + Iterator<PollAccount> it = accounts.iterator(); while (it.hasNext()) { - if ("".equals(it.next().getVotingId())) { + if ("".equals(it.next().getName())) { it.remove(); } } @@ -84,7 +84,7 @@ * @return a PollAccountDTO list * @see #importList(java.io.Reader) */ - public static List<PollAccountDTO> importList(UploadedFile file) { + public static List<PollAccount> importList(UploadedFile file) { if (log.isInfoEnabled()) { log.info("Import du fichier " + file.getFileName() + " (" + file.getContentType() + ")..."); Deleted: 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-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/ImageUtil.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,129 +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.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.imageio.ImageIO; -import javax.swing.ImageIcon; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.ui.components.ImageContextLink; -import org.chorem.pollen.ui.data.uio.ImageChoiceUIO; - -/** - * Classe permettant de gérer l'enregistrement d'images et la création de - * miniatures. - * - * @author rannou - * @version $Id$ - * @deprecated use {@link org.chorem.pollen.ui.services.ServiceImage} instead - */ -@Deprecated -public class ImageUtil { - - /** log. */ - private static final Log log = LogFactory.getLog(ImageUtil.class); - - /** - * Sauvegarde d'une image et de sa miniature. - * - * @param dir Le répertoire de destination. - * @param imgChoice L'UIO de l'image à enregistrer. - */ - public static void saveImage(ImageChoiceUIO imgChoice, File dir) { - List<ImageChoiceUIO> imgChoices = new ArrayList<ImageChoiceUIO>(); - imgChoices.add(imgChoice); - saveImages(imgChoices, dir); - } - - /** - * Sauvegarde des images et de leurs miniatures. - * - * @param imgChoices Les UIO des images à enregistrer. - * @param dir Le répertoire de destination. - */ - public static void saveImages(List<ImageChoiceUIO> imgChoices, File dir) { - if (imgChoices != null && imgChoices.size() > 0) { - if (!dir.exists()) { - dir.mkdirs(); - } - if (log.isDebugEnabled()) { - log.debug("Destination folder: " + dir.getAbsolutePath()); - } - for (ImageChoiceUIO imgChoice : imgChoices) { - if (imgChoice.getImg() != null - && (imgChoice.getImg().getContentType().contains( - "image") || imgChoice.getImg().getContentType() - .contains("IMAGE"))) { - - // Enregistrement de l'image - File img = new File(dir, imgChoice.getName()); - imgChoice.getImg().write(img); - if (log.isDebugEnabled()) { - log.debug("Image saved: " - + imgChoice.getImg().getFileName() + " (size=" - + imgChoice.getImg().getSize() + ")"); - } - - // Création de la miniature - createThumbnail(dir, img, 100); - } - } - } - } - - /** - * Création d'une miniature. - * - * @param dir Le répertoire de destination. - * @param img L'image à miniaturiser. - * @param width La largeur de la miniature. - */ - public static void createThumbnail(File dir, File img, int width) { - ImageIcon ii = new ImageIcon(img.getAbsolutePath()); - Image image = ii.getImage(); - double imageRatio = (double) image.getHeight(null) - / (double) image.getWidth(null); - int height = (int) (width * imageRatio); - - BufferedImage thumbImage = new BufferedImage(width, height, - BufferedImage.TYPE_INT_RGB); - Graphics2D graphics2D = thumbImage.createGraphics(); - graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - graphics2D.drawImage(image, 0, 0, width, height, null); - File thumbCopied = new File(dir, ImageContextLink.THUMB_PREFIX + img.getName()); - try { - ImageIO.write(thumbImage, "jpg", thumbCopied); - } catch (IOException e) { - log.error("Erreur à l'enregistrement de la miniature", e); - } - if (log.isDebugEnabled()) { - log.debug("Thumbnail created: " + thumbCopied.getName() + " (size=" - + thumbCopied.length() + ")"); - } - } -} Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/utils/LDAPAccountUtil.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -30,7 +30,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.business.dto.PollAccountDTO; +import org.chorem.pollen.entity.PollAccount; +import org.chorem.pollen.entity.PollAccountImpl; /** * Classe permettant de gérer l'import de listes de votants à partir d'un @@ -50,7 +51,7 @@ * @param url l'URL correspondant à la recherche * @return la liste de votants */ - public static List<PollAccountDTO> importList(String url) { + public static List<PollAccount> importList(String url) { return importList(null, url, null); } @@ -62,10 +63,10 @@ * @param filter le filtre à apposer pour la recherche * @return la liste de votants */ - public static List<PollAccountDTO> importList(String server, + public static List<PollAccount> importList(String server, String context, String filter) { long start = System.nanoTime(); - List<PollAccountDTO> accounts = new ArrayList<PollAccountDTO>(); + List<PollAccount> accounts = new ArrayList<PollAccount>(); try { @@ -97,8 +98,8 @@ Attribute emailAttr = r.getAttributes().get("mail"); if (nameAttr != null) { - PollAccountDTO account = new PollAccountDTO(); - account.setVotingId(nameAttr.get().toString()); + PollAccount account = new PollAccountImpl(); + account.setName(nameAttr.get().toString()); account.setEmail(emailAttr.get().toString()); accounts.add(account); Deleted: trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/PropertiesLoaderTest.java =================================================================== --- trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/PropertiesLoaderTest.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/PropertiesLoaderTest.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -1,66 +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; - -import static org.junit.Assert.assertEquals; - -import java.util.Properties; - -import org.chorem.pollen.business.utils.PropertiesLoader; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Tests du chargement des fichiers de propriétés. - * - * @author zhykos - * @version $Id$ - */ -public class PropertiesLoaderTest { - - public PropertiesLoaderTest() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of loadPropertiesFile method, of class PropertiesLoader. - */ - @Test - public void testLoadPropertiesFile() { - String filename = "pollen.properties"; - Properties result = PropertiesLoader.loadPropertiesFile(filename); - assertEquals("bot@pollen.org", result.getProperty("email_from")); - } -} \ No newline at end of file Modified: trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java =================================================================== --- trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java 2010-03-23 23:38:20 UTC (rev 2957) +++ trunk/pollen-ui/src/test/java/org/chorem/pollen/ui/utils/CSVAccountUtilTest.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -4,18 +4,20 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; -import org.chorem.pollen.business.dto.PollAccountDTO; +import org.chorem.pollen.entity.PollAccount; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; /** * * @author fdesbois */ +@Ignore public class CSVAccountUtilTest { public CSVAccountUtilTest() { @@ -47,13 +49,13 @@ InputStream input = getClass().getResourceAsStream("/import.csv"); InputStreamReader reader = new InputStreamReader(input); - List<PollAccountDTO> accounts = CSVAccountUtil.importList(reader); + List<PollAccount> accounts = CSVAccountUtil.importList(reader); Assert.assertEquals(3, accounts.size()); - PollAccountDTO account = accounts.get(0); + PollAccount account = accounts.get(0); - Assert.assertEquals("toto", account.getVotingId()); + Assert.assertEquals("toto", account.getName()); Assert.assertEquals("toto@titi.fr", account.getEmail()); Assert.assertEquals(3., account.getWeight(), 0.1); } @@ -61,7 +63,7 @@ /** * Test of importList method, of class CSVAccountUtil. */ - @Test + //@Test public void testImportList_UploadedFile() { System.out.println("importList"); } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/ChoiceType.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -30,4 +30,13 @@ public boolean isImage() { return this.equals(IMAGE); } + + public static ChoiceType valueOf(int ordinal) { + for (ChoiceType curr : ChoiceType.values()) { + if (curr.ordinal() == ordinal) { + return curr; + } + } + return null; + } } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/PollType.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -38,4 +38,13 @@ public static boolean isGroupType(String value) { return GROUP.name().equals(value); } + + public static PollType valueOf(int ordinal) { + for (PollType curr : PollType.values()) { + if (curr.ordinal() == ordinal) { + return curr; + } + } + return null; + } } 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 23:38:20 UTC (rev 2957) +++ trunk/pollen-votecounting/src/main/java/org/chorem/pollen/common/VoteCountingType.java 2010-03-26 14:06:00 UTC (rev 2958) @@ -34,4 +34,13 @@ public boolean isNumber() { return this.equals(NUMBER); } + + public static VoteCountingType valueOf(int ordinal) { + for (VoteCountingType curr : VoteCountingType.values()) { + if (curr.ordinal() == ordinal) { + return curr; + } + } + return null; + } }
participants (1)
-
fdesbois@users.chorem.org