Author: fdesbois Date: 2010-02-26 19:01:14 +0100 (Fri, 26 Feb 2010) New Revision: 2892 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/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/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java Log: delete useless methods (used nowhere) 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:37:14 UTC (rev 2891) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceList.java 2010-02-26 18:01:14 UTC (rev 2892) @@ -45,19 +45,6 @@ public String createVotingList(VotingListDTO votingList); /** - * Création des groupes de votant du sondage - * - * @param votingLists les dtos listes - * @param pollId l'identifiant du sondage - * @param transaction la transaction du sondage - * @return les groupes créés - * @deprecated useless method : used nowhere - */ - @Deprecated - public List<VotingList> createVotingLists(List<VotingListDTO> votingLists, - String pollId, TopiaContext transaction); - - /** * Mise à jour d'une liste de votant * * @param votingList la liste @@ -66,46 +53,6 @@ public boolean updateVotingList(VotingListDTO votingList); /** - * Suppression d'une liste de votant - * - * @param votingListId l'identifiant de la liste - * @return true si la liste a été mise à jours - * @deprecated useless method : used only in tests - */ - @Deprecated - public boolean deleteVotingList(String votingListId); - - /** - * Recherche d'une liste par son identifiant - * - * @param votingListId l'identifiant de la liste - * @return la liste - * @deprecated useless method : used only in tests - */ - @Deprecated - public VotingListDTO findVotingListById(String votingListId); - - /** - * Recherche d une liste de votant à partir du nom - * - * @param name le nom de la liste - * @return les listes - * @deprecated useless method : used only in tests - */ - @Deprecated - public List<VotingListDTO> findVotingListByName(String name); - - /** - * Recherche des listes à partir d'un filtre - * - * @param properties filtre sur les champs de la table VotingList - * @return les listes de votants - * @deprecated useless method : used only in tests - */ - @Deprecated - public List<VotingListDTO> selectVotingList(Map<String, Object> properties); - - /** * Création d'une liste de favoris * * @param personList la liste @@ -114,19 +61,6 @@ public String createPersonList(PersonListDTO personList); /** - * Création d'une liste de favoris pour un user - * - * @param lists les dtos personList - * @param userId l'identifiant de l'utilisateur - * @param transaction la transaction du sondage - * @return true si toutes les listes ont été créés - * @deprecated useless method : used nowhere - */ - @Deprecated - public boolean createPersonLists(List<PersonListDTO> lists, String userId, - TopiaContext transaction); - - /** * Create an {@code account} in a {@code personList}. * * @param personList where the account will be added @@ -168,30 +102,10 @@ public PersonListDTO findPersonListById(String personListId); /** - * Recherche des listes de favoris à partir du nom - * - * @param name le nom de la liste - * @return les listes - * @deprecated useless method : used only in tests - */ - @Deprecated - public List<PersonListDTO> findPersonListByName(String name); - - /** * Recherche des listes de favoris d'un utilisateur. * * @param userId Le créateur de la liste * @return les listes */ public List<PersonListDTO> findPersonListByUser(String userId); - - /** - * Recherche des listes à partir d'un filtre - * - * @param properties filtre sur les champs de la table personList - * @return les listes de votants - * @deprecated useless method : used only in tests - */ - @Deprecated - public List<PersonListDTO> selectPersonList(Map<String, Object> properties); } Modified: trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java =================================================================== --- trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 17:37:14 UTC (rev 2891) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServiceListImpl.java 2010-02-26 18:01:14 UTC (rev 2892) @@ -114,49 +114,6 @@ } @Override - public List<VotingList> createVotingLists(List<VotingListDTO> votingLists, - String pollId, TopiaContext transaction) { - if (votingLists.isEmpty() || pollId.length() == 0) { - return null; - } - - List<VotingList> result = null; - try { - votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction); - - votingListConverter.setTransaction(transaction); - - result = new ArrayList<VotingList>(); - for (VotingListDTO votingList : votingLists) { - VotingList votingListEntity = votingListDAO.create(); - votingList.setPollId(pollId); - votingListConverter.populateVotingListEntity(votingList, - votingListEntity); - - // Création des pollAccount de la liste si nécessaire - // FIXME do not call a Service from an other one - ServicePollAccount spa = new ServicePollAccountImpl(); - //spa.createPollAccounts(votingList.getPollAccountDTOs(), trans); - for (PollAccountDTO account : votingList.getPollAccountDTOs()) { - if (spa.findPollAccountById(account.getId()) == null) { - account.setId(spa.createPollAccount(account)); - } - } - - // Création des PersonToList - votingListConverter.populatePersonVotingList(votingList, - votingListEntity); - result.add(votingListEntity); - } - - return result; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } - } - - @Override public boolean updateVotingList(VotingListDTO votingList) { TopiaContext transaction = null; try { @@ -186,138 +143,6 @@ } @Override - public boolean deleteVotingList(String votingListId) { - TopiaContext transaction = null; - try { - transaction = rootContext.beginTransaction(); - - votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction); - - VotingList entity = votingListDAO.findByTopiaId(votingListId); - - votingListDAO.delete(entity); - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entity deleted: " + votingListId); - } - - return true; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return false; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override - public VotingListDTO findVotingListById(String votingListId) { - TopiaContext transaction = null; - VotingListDTO result = null; - try { - transaction = rootContext.beginTransaction(); - - votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction); - - VotingList votingListEntity = votingListDAO - .findByTopiaId(votingListId); - - if (votingListEntity != null) { - votingListConverter.setTransaction(transaction); - result = votingListConverter - .createVotingListDTO(votingListEntity); - } - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entity found: " - + ((result == null) ? "null" : result.getId())); - } - - return result; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override - public List<VotingListDTO> findVotingListByName(String name) { - TopiaContext transaction = null; - List<VotingListDTO> results = null; - List<VotingList> votingListEntities = null; - try { - transaction = rootContext.beginTransaction(); - - votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction); - - votingListEntities = votingListDAO.findAllByName(name); - - votingListConverter.setTransaction(transaction); - results = votingListConverter - .createVotingListDTOs(votingListEntities); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entities found: " - + ((results == null) ? "null" : results.size())); - } - - return results; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override - public List<VotingListDTO> selectVotingList(Map<String, Object> properties) { - TopiaContext transaction = null; - List<VotingListDTO> results = null; - List<VotingList> votingListEntities = null; - try { - transaction = rootContext.beginTransaction(); - - votingListDAO = PollenModelDAOHelper.getVotingListDAO(transaction); - - if (properties == null) { - votingListEntities = votingListDAO.findAll(); - if (log.isWarnEnabled()) { - log - .warn("Attention : toutes les listes ont été sélectionnés !"); - } - } else { - votingListEntities = votingListDAO - .findAllByProperties(properties); - } - votingListConverter.setTransaction(transaction); - results = votingListConverter - .createVotingListDTOs(votingListEntities); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entities found: " - + ((results == null) ? "null" : results.size())); - } - - return results; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override public String createPersonList(PersonListDTO personList) { TopiaContext transaction = null; String topiaId = ""; @@ -357,41 +182,6 @@ } @Override - public boolean createPersonLists(List<PersonListDTO> personLists, - String userId, TopiaContext transaction) { - if (personLists.isEmpty() || userId.length() == 0) { - return false; - } - - try { - personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction); - - personListConverter.setTransaction(transaction); - for (PersonListDTO personList : personLists) { - PersonList entity = personListDAO.create(); - - // 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.getPollAccounts()) { - account.setPersonListId(entity.getTopiaId()); - } - entity.setPollAccount(spa.createPollAccounts(personList - .getPollAccounts(), transaction)); - - personList.setUserId(userId); - personListConverter - .populatePersonListEntity(personList, entity); - } - - return true; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return false; - } - } - - @Override public void createAccountInPersonList(PersonListDTO personList, PollAccountDTO account) { TopiaContext transaction = null; try { @@ -564,38 +354,6 @@ } @Override - public List<PersonListDTO> findPersonListByName(String name) { - TopiaContext transaction = null; - List<PersonListDTO> results = null; - List<PersonList> personListEntities = null; - try { - transaction = rootContext.beginTransaction(); - - personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction); - - personListEntities = personListDAO.findAllByName(name); - - personListConverter.setTransaction(transaction); - results = personListConverter - .createPersonListDTOs(personListEntities); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entities found: " - + ((results == null) ? "null" : results.size())); - } - - return results; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override public List<PersonListDTO> findPersonListByUser(String userId) { TopiaContext transaction = null; List<PersonListDTO> results = null; @@ -629,44 +387,4 @@ ContextUtil.doFinally(transaction); } } - - @Override - public List<PersonListDTO> selectPersonList(Map<String, Object> properties) { - TopiaContext transaction = null; - List<PersonListDTO> results = null; - List<PersonList> personListEntities = null; - try { - transaction = rootContext.beginTransaction(); - - personListDAO = PollenModelDAOHelper.getPersonListDAO(transaction); - - if (properties == null) { - personListEntities = personListDAO.findAll(); - if (log.isWarnEnabled()) { - log - .warn("Attention : toutes les listes ont été sélectionnés !"); - } - } else { - personListEntities = personListDAO - .findAllByProperties(properties); - } - personListConverter.setTransaction(transaction); - results = personListConverter - .createPersonListDTOs(personListEntities); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entities found: " - + ((results == null) ? "null" : results.size())); - } - - return results; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } } \ No newline at end of file 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:37:14 UTC (rev 2891) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccount.java 2010-02-26 18:01:14 UTC (rev 2892) @@ -84,25 +84,4 @@ * @return un compte */ public PollAccountDTO findPollAccountByAccountId(String pollAccountId); - - /** - * Récupération des comptes d'un utilisateur. - * - * @param userId l'identifiant de l'utilisateur - * @return la liste des comptes de l'utilisateur - * @deprecated useless method : used nowhere - */ - @Deprecated - public List<PollAccountDTO> findPollAccountsByUser(String userId); - - /** - * Recherche des comptes à partir d'un filtre. - * - * @param properties filtre sur les champs de la table pollAccount - * @return les comptes - * @deprecated useless method : used nowhere - */ - @Deprecated - public List<PollAccountDTO> selectPollAccounts( - Map<String, Object> properties); } 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:37:14 UTC (rev 2891) +++ trunk/pollen-business/src/main/java/org/chorem/pollen/business/services/ServicePollAccountImpl.java 2010-02-26 18:01:14 UTC (rev 2892) @@ -250,79 +250,4 @@ ContextUtil.doFinally(transaction); } } - - @Override - public List<PollAccountDTO> findPollAccountsByUser(String userId) { - TopiaContext transaction = null; - List<PollAccountDTO> results = null; - List<PollAccount> pollAccountEntities = null; - UserAccountDAO userDAO = null; - try { - transaction = rootContext.beginTransaction(); - - userDAO = PollenModelDAOHelper.getUserAccountDAO(transaction); - UserAccount user = userDAO.findByTopiaId(userId); - - pollAccountEntities = new ArrayList<PollAccount>(); - pollAccountEntities.addAll(user.getPollAccount()); - - converter.setTransaction(transaction); - results = converter.createPollAccountDTOs(pollAccountEntities); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entities found: " - + ((results == null) ? "null" : results.size())); - } - - return results; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } - - @Override - public List<PollAccountDTO> selectPollAccounts( - Map<String, Object> properties) { - TopiaContext transaction = null; - List<PollAccountDTO> results = null; - List<PollAccount> pollAccountEntities = null; - try { - transaction = rootContext.beginTransaction(); - - pollAccountDAO = PollenModelDAOHelper - .getPollAccountDAO(transaction); - - if (properties == null) { - pollAccountEntities = pollAccountDAO.findAll(); - if (log.isWarnEnabled()) { - log - .warn("Attention : tous les comptes ont été sélectionnés !"); - } - } else { - pollAccountEntities = pollAccountDAO - .findAllByProperties(properties); - } - converter.setTransaction(transaction); - results = converter.createPollAccountDTOs(pollAccountEntities); - - transaction.commitTransaction(); - - if (log.isDebugEnabled()) { - log.debug("Entities found: " - + ((results == null) ? "null" : results.size())); - } - - return results; - } catch (Exception e) { - ContextUtil.doCatch(e, transaction); - return null; - } finally { - ContextUtil.doFinally(transaction); - } - } } \ No newline at end of file Modified: trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java =================================================================== --- trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 17:37:14 UTC (rev 2891) +++ trunk/pollen-business/src/test/java/org/chorem/pollen/business/services/ServiceListImplTest.java 2010-02-26 18:01:14 UTC (rev 2892) @@ -105,57 +105,6 @@ } /** - * Test of deleteVotingList method, of class ServiceListImpl. - */ - @Test - public void testDeleteVotingList() { - VotingListDTO dto = new VotingListDTO(); - dto.setName("Test_DeleteVotingList"); - String votingListId = instance.createVotingList(dto); - dto.setId(votingListId); - boolean result = instance.deleteVotingList(votingListId); - assertTrue(result); - } - - /** - * Test of findVotingListById method, of class ServiceListImpl. - */ - @Test - public void testFindVotingListById() { - VotingListDTO dto = new VotingListDTO(); - dto.setName("test_findVotingListById"); - String votingListId = instance.createVotingList(dto); - VotingListDTO result = instance.findVotingListById(votingListId); - String resultId = result.getId(); - assertEquals(votingListId, resultId); - } - - /** - * Test of findVotingListByName method, of class ServiceListImpl. - */ - @Test - public void testFindVotingListByName() { - VotingListDTO dto = new VotingListDTO(); - dto.setName("Test_findVotingListByName"); - String votingListId = instance.createVotingList(dto); - List<VotingListDTO> result = instance - .findVotingListByName("Test_findVotingListByName"); - assertEquals(result.size(), 1); - } - - /** - * Test of selectVotingList method, of class ServiceListImpl. - */ - @Test - public void testSelectVotingList() { - VotingListDTO dto = new VotingListDTO(); - dto.setName("test_selectVotingList"); - String votingListId = instance.createVotingList(dto); - List<VotingListDTO> result = instance.selectVotingList(null); - assertTrue(result.size() > 0); - } - - /** * Test of createPersonList method, of class ServiceListImpl. */ @Test @@ -291,29 +240,4 @@ String resultId = result.getId(); assertEquals(personListId, resultId); } - - /** - * Test of findPersonListByName method, of class ServiceListImpl. - */ - @Test - public void testFindPersonListByName() { - PersonListDTO dto = new PersonListDTO(); - dto.setName("test_findPersonListByName"); - String personListId = instance.createPersonList(dto); - List<PersonListDTO> result = instance - .findPersonListByName("test_findPersonListByName"); - assertEquals(result.size(), 1); - } - - /** - * Test of selectPersonlist method, of class ServiceListImpl. - */ - @Test - public void testSelectPersonlist() { - PersonListDTO dto = new PersonListDTO(); - dto.setName("test_selectPersonList"); - String personListId = instance.createPersonList(dto); - List<PersonListDTO> result = instance.selectPersonList(null); - assertTrue(result.size() > 0); - } } \ No newline at end of file