r2934 - in branches/pollen-1.2.3-1.2.x: pollen-business/src/main/java/org/chorem/pollen/business/converters pollen-business/src/main/java/org/chorem/pollen/business/dto pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll
Author: fdesbois Date: 2010-03-12 18:18:11 +0100 (Fri, 12 Mar 2010) New Revision: 2934 Log: Ano #143 : Remove call to findByPollAccountId and push more parameters in VoteDTO to avoid multiple db call Modified: branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java branches/pollen-1.2.3-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java Modified: branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java =================================================================== --- branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java 2010-03-12 14:31:05 UTC (rev 2933) +++ branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/converters/DataVoteConverter.java 2010-03-12 17:18:11 UTC (rev 2934) @@ -29,6 +29,7 @@ import org.chorem.pollen.business.persistence.PollAccountDAO; import org.chorem.pollen.business.persistence.PollDAO; import org.chorem.pollen.business.persistence.PollenModelDAOHelper; +import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.business.persistence.Vote; import org.chorem.pollen.business.persistence.VoteDAO; import org.chorem.pollen.business.persistence.VoteToChoice; @@ -96,6 +97,11 @@ } if (eVote.getPollAccount() != null) { voteDTO.setPollAccountId(eVote.getPollAccount().getTopiaId()); + voteDTO.setName(eVote.getPollAccount().getVotingId()); + UserAccount user = eVote.getPollAccount().getUserAccount(); + if (user != null) { + voteDTO.setUserId(user.getTopiaId()); + } } if (eVote.getVotingList() != null) { voteDTO.setVotingListId(eVote.getVotingList().getTopiaId()); Modified: branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java =================================================================== --- branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java 2010-03-12 14:31:05 UTC (rev 2933) +++ branches/pollen-1.2.3-1.2.x/pollen-business/src/main/java/org/chorem/pollen/business/dto/VoteDTO.java 2010-03-12 17:18:11 UTC (rev 2934) @@ -39,6 +39,12 @@ private String pollAccountId = ""; + /** QUICK FIX to have pollAccount votingId **/ + private String name; + + /** QUICK FIX to have pollAccount userId **/ + private String userId; + private String pollId = ""; private String votingListId = ""; @@ -66,6 +72,22 @@ this.id = id; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + public double getWeight() { return weight; } Modified: branches/pollen-1.2.3-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java =================================================================== --- branches/pollen-1.2.3-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-12 14:31:05 UTC (rev 2933) +++ branches/pollen-1.2.3-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-12 17:18:11 UTC (rev 2934) @@ -553,28 +553,37 @@ // parcours des votes pour trouver celui correspondant au votingId // et contrôle du droit de modification + + if (log.isDebugEnabled()) { + log.debug("Nb votes : " + getVotes().size()); + log.debug("Nb votes in poll : " + poll.getNbVotes()); + } + + // FIXME !!!!!! SEEMS TO BE INDEFINITE while (i < getVotes().size() && !modifAllowed) { // account : compte associé au vote courant - String id = getVotes().get(i).getPollAccountId(); - PollAccountDTO account = servicePollAccount.findPollAccountById(id); + //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 (account.getVotingId().equals(votingId)) { + if (curr.getName().equals(votingId)) { if (logger.isDebugEnabled()) { - logger.debug("vote account: " + account.getId()); + 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(account.getId())) { + && 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(account.getUserId()); + modifAllowed = user.getId().equals(curr.getUserId()); } } @@ -803,11 +812,12 @@ } /** Retourne l'identifiant du votant du vote courant */ + // FIXME !!!!!! DON'T DO A QUERY FOR THAT public String getCurrentVotingId() { - String id = vote.getPollAccountId(); - String votingId = servicePollAccount.findPollAccountById(id) - .getVotingId(); - return votingId; +// String id = vote.getPollAccountId(); +// String votingId = servicePollAccount.findPollAccountById(id) +// .getVotingId(); + return vote.getName(); } /** Validation du champs de saisie du choix (texte). */
participants (1)
-
fdesbois@users.chorem.org