r3316 - in trunk: pollen-persistence/src/main/java/org/chorem/pollen/business/persistence pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user pollen-ui-struts2/src/main/resources/i18n
Author: fdesbois Date: 2012-04-25 11:37:55 +0200 (Wed, 25 Apr 2012) New Revision: 3316 Url: http://chorem.org/repositories/revision/pollen/3316 Log: fixes #164 : check unicity on favorite participant email instead of name Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java =================================================================== --- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-04-25 07:07:56 UTC (rev 3315) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-04-25 09:37:55 UTC (rev 3316) @@ -68,8 +68,8 @@ return result; } - public boolean isPollAccountExist(PersonList personListToUpdate, - PollAccount pollAccount) throws TopiaException { + public boolean isPollAccountExists(PersonList personListToUpdate, + PollAccount pollAccount) throws TopiaException { Preconditions.checkNotNull(personListToUpdate); Preconditions.checkNotNull(pollAccount); @@ -77,25 +77,18 @@ // check there is other poll account in this list with same id TopiaQuery query = createQuery("e"); query.addWhere("e." + PollAccount.PROPERTY_PERSON_LIST, TopiaQuery.Op.EQ, personListToUpdate); - query.addWhere("e." + PollAccount.PROPERTY_VOTING_ID, TopiaQuery.Op.EQ, pollAccount.getVotingId()); - boolean pollAccountExists = existByQuery(query); - return pollAccountExists; - } + query.addWhere("e." + PollAccount.PROPERTY_EMAIL, TopiaQuery.Op.EQ, pollAccount.getEmail()); - public boolean isPollAccountAlreadyExist(PersonList personListToUpdate, - PollAccount pollAccount) throws TopiaException { + String pollAccountId = pollAccount.getTopiaId(); + if (pollAccountId == null) { + // no check necessary, it's a new pollAccount - Preconditions.checkNotNull(personListToUpdate); - Preconditions.checkNotNull(pollAccount); + } else { + query.addWhere("e." + PollAccount.TOPIA_ID, TopiaQuery.Op.NEQ, pollAccountId); + } - // check there is another poll account in this list with same id - TopiaQuery query = createQuery("e"); - query.addWhere("e." + PollAccount.PROPERTY_PERSON_LIST, TopiaQuery.Op.EQ, personListToUpdate); - query.addWhere("e." + PollAccount.PROPERTY_VOTING_ID, TopiaQuery.Op.EQ, pollAccount.getVotingId()); - query.addWhere("e." + PollAccount.TOPIA_ID, TopiaQuery.Op.NEQ, pollAccount.getTopiaId()); - boolean pollAccountExists = existByQuery(query); - return pollAccountExists; - + boolean result = existByQuery(query); + return result; } public PollAccount findByPollVoteUser(Poll poll, Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-04-25 07:07:56 UTC (rev 3315) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/FavoriteService.java 2012-04-25 09:37:55 UTC (rev 3316) @@ -231,10 +231,9 @@ throw new FavoriteListNotFoundException(); } - // check there is other poll account in this list with same id - boolean pollAccountExists = dao.isPollAccountExist(personListToUpdate, pollAccount); + // check there is other poll account in this list with same email + boolean pollAccountExists = dao.isPollAccountExists(personListToUpdate, pollAccount); if (pollAccountExists) { - throw new ParticipantAlreadyFoundInListException(); } @@ -285,9 +284,8 @@ } // check there is another poll account in this list with same id - boolean pollAccountExists = dao.isPollAccountAlreadyExist(personListToUpdate, pollAccount); + boolean pollAccountExists = dao.isPollAccountExists(personListToUpdate, pollAccount); if (pollAccountExists) { - throw new ParticipantAlreadyFoundInListException(); } Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-04-25 07:07:56 UTC (rev 3315) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteList.java 2012-04-25 09:37:55 UTC (rev 3316) @@ -133,7 +133,7 @@ action = null; result = SUCCESS; } catch (ParticipantAlreadyFoundInListException e) { - addFieldError("createPollAccount.votingId", + addFieldError("createPollAccount.email", _("pollen.error.favoriteList.participant.already.found.in.list")); } return result; @@ -161,7 +161,7 @@ action = null; result = SUCCESS; } catch (ParticipantAlreadyFoundInListException e) { - addFieldError("editPollAccount.votingId", + addFieldError("editPollAccount.email", _("pollen.error.favoriteList.participant.already.found.in.list")); } return result; Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-04-25 07:07:56 UTC (rev 3315) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/ManageFavoriteLists.java 2012-04-25 09:37:55 UTC (rev 3316) @@ -196,7 +196,7 @@ // WARNING ? addActionError( _("pollen.error.favoriteList.import.participantExists" - ,importedAccount.getVotingId()) + ,importedAccount.getEmail()) ); } } Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-25 07:07:56 UTC (rev 3315) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-25 09:37:55 UTC (rev 3316) @@ -146,10 +146,10 @@ pollen.error.email.invalid=The email doesn't have the good format pollen.error.email.required=You must provide an email pollen.error.favoriteList.already.used=List name already used -pollen.error.favoriteList.import.participantExists=The name '%1$s' is already used in the list +pollen.error.favoriteList.import.participantExists=The email '%1$s' is already used in the list pollen.error.favoriteList.not.found=Favorite list not found pollen.error.favoriteList.not.owned.by.user=You are not owner of this favorite list -pollen.error.favoriteList.participant.already.found.in.list=Member was same name already in favorite list +pollen.error.favoriteList.participant.already.found.in.list=Member with same email already exists in favorite list pollen.error.favoriteList.participant.not.found.in.list=Member not found in favorite list pollen.error.favoriteListName.required=List name mandatory pollen.error.login.required=You must provide a login Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-25 07:07:56 UTC (rev 3315) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-25 09:37:55 UTC (rev 3316) @@ -148,10 +148,10 @@ pollen.error.email.invalid=Email non valide pollen.error.email.required=Email obligatoire pollen.error.favoriteList.already.used=Nom de liste déjà utilisé -pollen.error.favoriteList.import.participantExists=Le nom '%1$s' est déjà utilisé dans la liste +pollen.error.favoriteList.import.participantExists=L'email '%1$s' est déjà utilisé dans la liste pollen.error.favoriteList.not.found=Liste non trouvée pollen.error.favoriteList.not.owned.by.user=La liste d'utilisateur ne vous appartient pas -pollen.error.favoriteList.participant.already.found.in.list=Nom déjà utilisé dans la liste +pollen.error.favoriteList.participant.already.found.in.list=Email déjà utilisé dans la liste pollen.error.favoriteList.participant.not.found.in.list=Membre non trouvé dans la liste pollen.error.favoriteListName.required=Nom de liste obligatoire pollen.error.login.required=Login obligatoire
participants (1)
-
fdesbois@users.chorem.org