r2890 - in trunk: pollen-business/src/main/java/org/chorem/pollen/business pollen-business/src/main/java/org/chorem/pollen/business/converters pollen-business/src/main/java/org/chorem/pollen/business/dto pollen-business/src/main/java/org/chorem/pollen/business/services pollen-business/src/main/resources/i18n pollen-business/src/test/java/org/chorem/pollen/business/services pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user pollen-
Author: fdesbois Date: 2010-02-26 18:32:17 +0100 (Fri, 26 Feb 2010) New Revision: 2890 Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.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/test/java/org/chorem/pollen/business/services/ServiceListImplTest.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/user/UserLists.java trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml trunk/pollen-ui/src/main/webapp/user/UserLists.tml Log: - Refactor account usage in personList -> createAccountInPersonList and deleteAccountFromPersonList : easier usage in ui module. - other improves Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/PollenProperty.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -43,6 +43,7 @@ } public String getKey() { + PollenProperty.EMAIL_HOST.getValue(); return key; } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataPersonListConverter.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -71,7 +71,7 @@ } if (ePersonList.getPollAccount().size() > 0) { DataPollAccountConverter converter = new DataPollAccountConverter(); - personListDTO.setPollAccountDTOs(converter + personListDTO.setPollAccounts(converter .createPollAccountDTOs(ePersonList.getPollAccount())); } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/dto/PersonListDTO.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -18,6 +18,7 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; /** @@ -35,7 +36,7 @@ private String name = ""; - private List<PollAccountDTO> pollAccountDTOs = new ArrayList<PollAccountDTO>(); + private List<PollAccountDTO> persons = new ArrayList<PollAccountDTO>(); public PersonListDTO() { @@ -76,12 +77,34 @@ this.name = name; } - public List<PollAccountDTO> getPollAccountDTOs() { - return pollAccountDTOs; + public List<PollAccountDTO> getPollAccounts() { + return persons; } - public void setPollAccountDTOs(List<PollAccountDTO> pollAccountDTOs) { - this.pollAccountDTOs = pollAccountDTOs; + public void setPollAccounts(List<PollAccountDTO> persons) { + this.persons = persons; } + public boolean addPollAccount(PollAccountDTO account) { + if (persons == null) { + persons = new ArrayList<PollAccountDTO>(); + } + return persons.add(account); + } + + public boolean removePollAccount(String accountId) { + if (persons == null) { + return false; + } + Iterator<PollAccountDTO> it = persons.iterator(); + while (it.hasNext()) { + PollAccountDTO account = it.next(); + if (accountId.equals(account.getId())) { + it.remove(); + return true; + } + } + return false; + } + } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -20,6 +20,7 @@ import java.util.Map; import org.chorem.pollen.business.dto.PersonListDTO; +import org.chorem.pollen.business.dto.PollAccountDTO; import org.chorem.pollen.business.dto.VotingListDTO; import org.chorem.pollen.business.persistence.VotingList; import org.nuiton.topia.TopiaContext; @@ -126,14 +127,23 @@ TopiaContext transaction); /** - * Mise à jour d'une liste de favoris + * Create an {@code account} in a {@code personList}. * - * @param personlistDTO la liste - * @return true si la liste a été mise à jours + * @param personList where the account will be added + * @param account to create */ - public boolean updatePersonList(PersonListDTO personlistDTO); + void createAccountInPersonList(PersonListDTO personList, + PollAccountDTO account); /** + * Delete an account using its {@code accountId} from a {@code personList}. + * + * @param personList where the account will be removed + * @param accountId topiaId of the account to delete + */ + void deleteAccountFromPersonList(PersonListDTO personList, String accountId); + + /** * Suppression d'une liste de favoris * * @param personListId l'identifiant de la liste Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -22,8 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.business.PollenBusinessException; import org.chorem.pollen.business.PollenContext; +import org.chorem.pollen.business.PollenConverter; import org.chorem.pollen.business.converters.DataPersonListConverter; import org.chorem.pollen.business.converters.DataVotingListConverter; import org.chorem.pollen.business.dto.PersonListDTO; @@ -31,6 +31,8 @@ import org.chorem.pollen.business.dto.VotingListDTO; import org.chorem.pollen.business.persistence.PersonList; import org.chorem.pollen.business.persistence.PersonListDAO; +import org.chorem.pollen.business.persistence.PollAccount; +import org.chorem.pollen.business.persistence.PollAccountDAO; import org.chorem.pollen.business.persistence.PollenModelDAOHelper; import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.business.persistence.UserAccountDAO; @@ -38,6 +40,7 @@ import org.chorem.pollen.business.persistence.VotingListDAO; import org.chorem.pollen.business.utils.ContextUtil; import org.nuiton.topia.TopiaContext; +import static org.nuiton.i18n.I18n._; /** * Implémentation du service de gestion des listes. @@ -59,6 +62,9 @@ public ServiceListImpl() { rootContext = PollenContext.getRootContext(); + + PollenConverter.preparePollAccountConverters(); + PollenConverter.prepareVotingListConverters(); } @Override @@ -327,11 +333,11 @@ // Création des comptes de la liste // FIXME do not call a Service from an other one ServicePollAccount spa = new ServicePollAccountImpl(); - for (PollAccountDTO account : personList.getPollAccountDTOs()) { + for (PollAccountDTO account : personList.getPollAccounts()) { account.setPersonListId(entity.getTopiaId()); } entity.setPollAccount(spa.createPollAccounts(personList - .getPollAccountDTOs(), transaction)); + .getPollAccounts(), transaction)); topiaId = entity.getTopiaId(); @@ -367,11 +373,11 @@ // Création des comptes de la liste // FIXME do not call a Service from an other one ServicePollAccount spa = new ServicePollAccountImpl(); - for (PollAccountDTO account : personList.getPollAccountDTOs()) { + for (PollAccountDTO account : personList.getPollAccounts()) { account.setPersonListId(entity.getTopiaId()); } entity.setPollAccount(spa.createPollAccounts(personList - .getPollAccountDTOs(), transaction)); + .getPollAccounts(), transaction)); personList.setUserId(userId); personListConverter @@ -386,50 +392,78 @@ } @Override - public boolean updatePersonList(PersonListDTO personList) { + public void createAccountInPersonList(PersonListDTO personList, PollAccountDTO account) { TopiaContext transaction = null; try { transaction = rootContext.beginTransaction(); personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction); - PersonList entity = personListDAO.findByTopiaId(personList.getId()); + PersonList eList = personListDAO.findByTopiaId(personList.getId()); - personListConverter.setTransaction(transaction); - personListConverter.populatePersonListEntity(personList, entity); + PollAccountDAO accountDAO = + PollenModelDAOHelper.getPollAccountDAO(transaction); - personListDAO.update(entity); + // Create new pollAccount + String accountUID = PollenContext.createPollenUrlId(); + PollAccount eAccount = accountDAO.create(accountUID); + PollenConverter.convert(account, eAccount); - // mise à jour ou création des comptes - // FIXME do not call a Service from an other one - ServicePollAccount spa = new ServicePollAccountImpl(); - for (PollAccountDTO pollAccountDTO : personList - .getPollAccountDTOs()) { - pollAccountDTO.setPersonListId(entity.getTopiaId()); - boolean updated = spa.updatePollAccount(pollAccountDTO); - if (!updated) { - pollAccountDTO.setId(spa.createPollAccount(pollAccountDTO)); - } + // Add the account into the list + eList.addPollAccount(eAccount); - if (log.isDebugEnabled()) { - log.debug("PollAccount " + pollAccountDTO.getVotingId() - + " (" + pollAccountDTO.getId() + ") updated: " - + updated); - } - } + transaction.commitTransaction(); + // Update change in dtos + account.setId(eAccount.getTopiaId()); + account.setAccountId(eAccount.getAccountId()); + personList.addPollAccount(account); + + } catch (Exception eee) { + PollenContext.doCatch(eee, + _("pollen.error.serviceList.createAccountForPersonList", + personList.getName(), account.getVotingId()), + transaction + ); + } finally { + PollenContext.doFinally(transaction); + } + } + + @Override + public void deleteAccountFromPersonList(PersonListDTO personList, String accountId) { + TopiaContext transaction = null; + try { + transaction = rootContext.beginTransaction(); + + // Find the account + PollAccountDAO accountDAO = + PollenModelDAOHelper.getPollAccountDAO(transaction); + PollAccount eAccount = accountDAO.findByTopiaId(accountId); + + personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction); + + PersonList eList = personListDAO.findByTopiaId(personList.getId()); + + // The remove will delete the comment because no poll will be + // attached to him (delete-orphan) + eList.removePollAccount(eAccount); + + accountDAO.delete(eAccount); + transaction.commitTransaction(); - if (log.isDebugEnabled()) { - log.debug("Entity updated: " + personList.getId()); - } + // Update change in dto + personList.removePollAccount(accountId); - return true; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return false; + } catch (Exception eee) { + PollenContext.doCatch(eee, + _("pollen.error.serviceList.deleteAccountFromPersonList", + accountId, personList.getName(), personList.getId()), + transaction + ); } finally { - ContextUtil.doFinally(transaction); + PollenContext.doFinally(transaction); } } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -42,19 +42,6 @@ public String createPollAccount(PollAccountDTO pollAccount); /** - * Creation d'un compte utilisateur. - * - * @param votingId l'identifiant du votant - * @param email l'email du votant - * @param userId l'identifiant de l'utilisateur - * @return le topiaId du compte créé - * @deprecated useless method : not used in UI - */ - @Deprecated - public PollAccount createPollAccount(String votingId, String email, - String userId); - - /** * Creation des comptes utilisateur. * * @param pollAccounts les comptes à creer Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -90,43 +90,6 @@ } @Override - public PollAccount createPollAccount(String votingId, String email, - String userId) { - TopiaContext transaction = null; - String topiaId; - PollAccount pollAccountEntity = null; - try { - transaction = rootContext.beginTransaction(); - - pollAccountDAO = PollenModelDAOHelper - .getPollAccountDAO(transaction); - - // Identifiant du compte - String id = ContextUtil.createPollenUrlId(); - pollAccountEntity = pollAccountDAO.create(PollAccount.ACCOUNT_ID, id); - - converter.setTransaction(transaction); - converter.populatePollAccountEntity(votingId, email, userId, - pollAccountEntity); - - topiaId = pollAccountEntity.getTopiaId(); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entity created: " + topiaId); - } - - return pollAccountEntity; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override public List<PollAccount> createPollAccounts( List<PollAccountDTO> pollAccounts, TopiaContext transaction) { if (pollAccounts.isEmpty()) { 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-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-en_GB.properties 2010-02-26 17:32:17 UTC (rev 2890) @@ -4,6 +4,8 @@ pollen.error.context.rollback= pollen.error.context.start= pollen.error.context.stop= +pollen.error.serviceList.createAccountForPersonList= +pollen.error.serviceList.deleteAccountFromPersonList= pollen.error.servicePoll.addComment= pollen.error.servicePoll.createPoll= pollen.error.servicePoll.delete= 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-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/main/resources/i18n/pollen-business-fr_FR.properties 2010-02-26 17:32:17 UTC (rev 2890) @@ -4,6 +4,8 @@ pollen.error.context.rollback=Erreur lors de l'annulation de la transaction pollen.error.context.start=Erreur lors du d\u00E9marrage de l'application pollen.error.context.stop=Erreur lors de l'arr\u00EAt de l'application +pollen.error.serviceList.createAccountForPersonList= +pollen.error.serviceList.deleteAccountFromPersonList= pollen.error.servicePoll.addComment=Impossible d'ajouter un nouveau commentaire cr\u00E9\u00E9 par %1$s pour le sondage %2$s (%3$s) pollen.error.servicePoll.createPoll=Impossible d'enregistrer le sondage %1$s cr\u00E9\u00E9 par %2$s pollen.error.servicePoll.deleteComment=Impossible de supprimer le commentaire ayant pour identifiant "%1$s", appartenenant au sondage %2$s (%3$s) Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -16,7 +16,6 @@ package org.chorem.pollen.business.services; -import org.chorem.pollen.business.PollenBusinessException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -24,12 +23,19 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.business.TestData; import org.chorem.pollen.business.TestManager; import org.chorem.pollen.business.dto.PersonListDTO; +import org.chorem.pollen.business.dto.PollAccountDTO; import org.chorem.pollen.business.dto.VotingListDTO; -import org.chorem.pollen.business.utils.ContextUtil; +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.business.persistence.PersonListDAO; +import org.chorem.pollen.business.persistence.PollAccount; +import org.chorem.pollen.business.persistence.PollAccountDAO; +import org.chorem.pollen.business.persistence.PollenModelDAOHelper; import org.junit.After; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -162,19 +168,105 @@ /** * Test of updatePersonList method, of class ServiceListImpl. + * @throws Exception */ @Test - public void testUpdatePersonList() { + public void testCreateAccountInPersonList() throws Exception { + // temp stop, must refactor all tests from this class + TestManager.stop(); + TestManager.start("createAccountInPersonList"); + instance = new ServiceListImpl(); + + /** PREPARE DATA **/ PersonListDTO dto = new PersonListDTO(); - dto.setName("test_UpdatePersonList"); - String personListId = instance.createPersonList(dto); + dto.setName("list"); + final String personListId = instance.createPersonList(dto); dto.setId(personListId); - dto.setName("new name"); - boolean result = instance.updatePersonList(dto); - assertTrue(result); + + final PollAccountDTO account = new PollAccountDTO(); + account.setVotingId("Jack Pot"); + account.setEmail("jackpot@pompedup.fr"); + + /** EXEC METHOD **/ + instance.createAccountInPersonList(dto, account); + Assert.assertNotNull(account.getAccountId()); + Assert.assertNotNull(account.getId()); + Assert.assertEquals(1, dto.getPollAccounts().size()); + + TestData test = new TestData() { + + @Override + protected void test() throws Exception { + PollAccountDAO dao = + PollenModelDAOHelper.getPollAccountDAO(transaction); + + PollAccount eAccount = dao.findByTopiaId(account.getId()); + Assert.assertNotNull(eAccount); + Assert.assertNotNull(eAccount.getPersonList()); + Assert.assertEquals(personListId, + eAccount.getPersonList().getTopiaId()); + } + + }; + + test.execute(); + + // temp stop, must refactor all tests from this class + TestManager.stop(); } + /** + * Test of updatePersonList method, of class ServiceListImpl. + */ + @Test + public void testDeleteAccountFromPersonList() throws Exception { + // temp stop, must refactor all tests from this class + TestManager.stop(); + TestManager.start("deleteAccountFromPersonList"); + instance = new ServiceListImpl(); + + /** PREPARE DATA **/ + PersonListDTO dto = new PersonListDTO(); + dto.setName("list"); + final String personListId = instance.createPersonList(dto); + dto.setId(personListId); + + final PollAccountDTO account = new PollAccountDTO(); + account.setVotingId("Jack Pot"); + account.setEmail("jackpot@pompedup.fr"); + + instance.createAccountInPersonList(dto, account); + + /** EXEC METHOD **/ + instance.deleteAccountFromPersonList(dto, account.getId()); + + TestData test = new TestData() { + + @Override + protected void test() throws Exception { + PollAccountDAO dao = + PollenModelDAOHelper.getPollAccountDAO(transaction); + + PollAccount eAccount = dao.findByTopiaId(account.getId()); + Assert.assertNull(eAccount); + + PersonListDAO listDAO = + PollenModelDAOHelper.getPersonListDAO(transaction); + + PersonList ePersonList = listDAO.findByTopiaId(personListId); + Assert.assertEquals(0, ePersonList.getPollAccount().size()); + } + + }; + + test.execute(); + + // temp stop, must refactor all tests from this class + TestManager.stop(); + } + + /** * Test of deletePersonList method, of class ServiceListImpl. */ @Test Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollCreation.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -25,6 +25,7 @@ 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; @@ -34,7 +35,6 @@ import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Log; -import org.apache.tapestry5.annotations.Mixins; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; @@ -48,7 +48,6 @@ 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.PollenBusinessException; import org.chorem.pollen.business.PollenProperty; import org.chorem.pollen.business.business.PreventRuleManager; import org.chorem.pollen.business.dto.ChoiceDTO; @@ -118,9 +117,6 @@ /** Mixin de selection de liste de favoris */ @SuppressWarnings("unused") - @Component(parameters = { "event=change", - "onCompleteCallback=literal:onCompleteZoneUpdate" }) - @Mixins( { "ck/OnEvent" }) private Select listSelect; @InjectComponent @@ -1008,21 +1004,22 @@ * est créé. Il sera retourné à la fonction JavaScript onCompleteCallback * pour mettre à jour la zone. * + * @param value * @return un JSONObject contenant l'url de l'évènement mettant à jour la * zone. */ public JSONObject onChangeFromListSelect(String value) { - if (!"".equals(value)) { + if (StringUtils.isNotEmpty(value)) { personList = serviceList.findPersonListById(value); // Copie des personnes de la liste de favoris dans la liste de votants - for (PollAccountDTO account : personList.getPollAccountDTOs()) { + for (PollAccountDTO account : personList.getPollAccounts()) { account.setId(""); account.setPersonListId(""); } votingLists.get(currentList).setPollAccountDTOs( - personList.getPollAccountDTOs()); + personList.getPollAccounts()); } return createParamsForCallback(); } 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-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/user/UserLists.java 2010-02-26 17:32:17 UTC (rev 2890) @@ -208,7 +208,7 @@ accountsFile.getFileName())); return this; } - newList.getPollAccountDTOs().addAll(accounts); + newList.getPollAccounts().addAll(accounts); } // Import LDAP des comptes @@ -220,7 +220,7 @@ accountsUrl)); return this; } - newList.getPollAccountDTOs().addAll(accounts); + newList.getPollAccounts().addAll(accounts); } // Création de la nouvelle liste @@ -263,17 +263,20 @@ * Méthode appelée à la création d'un compte. */ Object onSuccessFromCreateAccountForm() { - for (PollAccountDTO dto : selectedList.getPollAccountDTOs()) { + // 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.getPollAccountDTOs().add(newAccount); - serviceList.updatePersonList(selectedList); - selectedList = serviceList.findPersonListById(selectedList.getId()); +// newAccount.setPersonListId(selectedList.getId()); +// selectedList.getPollAccounts().add(newAccount); +// serviceList.updatePersonList(selectedList); +// selectedList = serviceList.findPersonListById(selectedList.getId()); + serviceList.createAccountInPersonList(selectedList, account); } return listsZone.getBody(); } @@ -282,16 +285,17 @@ * Méthode appelée à la suppression d'un compte. */ Object onActionFromDeleteAccount(String accountId) { - Iterator<PollAccountDTO> it = selectedList.getPollAccountDTOs() - .iterator(); - while (it.hasNext()) { - if (accountId.equals(it.next().getId())) { - it.remove(); - } - } - serviceList.updatePersonList(selectedList); - servicePollAccount.deletePollAccount(accountId); - selectedList = serviceList.findPersonListById(selectedList.getId()); +// Iterator<PollAccountDTO> it = selectedList.getPollAccounts() +// .iterator(); +// while (it.hasNext()) { +// if (accountId.equals(it.next().getId())) { +// it.remove(); +// } +// } +// serviceList.updatePersonList(selectedList); +// servicePollAccount.deletePollAccount(accountId); +// selectedList = serviceList.findPersonListById(selectedList.getId()); + serviceList.deleteAccountFromPersonList(selectedList, accountId); return listsZone.getBody(); } Modified: trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-ui/src/main/webapp/poll/PollCreation.tml 2010-02-26 17:32:17 UTC (rev 2890) @@ -171,7 +171,8 @@ <t:if test="personListsExists"> <div> <t:label for="listSelect" />: - <t:select t:id="listSelect" t:model="personLists" t:encoder="personLists" t:value="personList"></t:select> + <t:select t:id="listSelect" t:model="personLists" t:encoder="personLists" t:value="personList" + t:mixins="ck/onEvent" t:event="change" t:onCompleteCallback="literal:onCompleteZoneUpdate"></t:select> <span t:type="ck/Tooltip" title="${message:help}" value="${message:listSelect-help}" effect="appear"> <img src="${asset:context:img/help.png}" alt="${message:help}"/> </span> Modified: trunk/pollen-ui/src/main/webapp/user/UserLists.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-02-26 17:24:00 UTC (rev 2889) +++ trunk/pollen-ui/src/main/webapp/user/UserLists.tml 2010-02-26 17:32:17 UTC (rev 2890) @@ -27,7 +27,7 @@ <!-- Affichage de la liste --> - <t:grid t:source="selectedList.pollAccountDTOs" t:row="account" model="listModel" + <t:grid t:source="selectedList.pollAccounts" t:row="account" model="listModel" t:rowsPerPage="10" t:pagerPosition="bottom" t:rowClass="prop:evenodd.next" t:inPlace="true"> <p:functionsCell> <t:actionlink t:id="deleteAccount" context="account.id" t:zone="listsZone">
participants (1)
-
fdesbois@users.chorem.org