r3688 - trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence
Author: tchemit Date: 2012-09-05 19:49:33 +0200 (Wed, 05 Sep 2012) New Revision: 3688 Url: http://chorem.org/repositories/revision/pollen/3688 Log: refs #804: Can not acces no more to poll where I was admin and voter (for the moment warn when finding more than one voter for a poll...) Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 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-09-05 17:48:19 UTC (rev 3687) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-09-05 17:49:33 UTC (rev 3688) @@ -24,7 +24,10 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaFilterPagerUtil; @@ -32,6 +35,9 @@ public class PollAccountDAOImpl<E extends PollAccount> extends PollAccountDAOAbstract<E> { + /** Logger. */ + private static final Log log = LogFactory.getLog(PollAccountDAOImpl.class); + /** * Get a restricted poll account for a given poll (by his {@link Poll#getPollId()}) * using the {@link PollAccount#getAccountId()} of the pollAccount @@ -143,7 +149,21 @@ hql += "e.userAccount = :user"; } - E result = findByQuery(hql, params.toArray()); + List<E> allVoter = findAllByQuery(hql, params.toArray()); + E result = null; + if (CollectionUtils.isNotEmpty(allVoter)) { + if (allVoter.size() > 1) { + if (log.isWarnEnabled()) { + log.warn("Multiple voter found for poll " + pollId); + for (E e : allVoter) { + if (log.isWarnEnabled()) { + log.warn("accountId: " + e.getAccountId()); + } + } + } + } + result = allVoter.get(0); + } return result; } @@ -156,12 +176,6 @@ int records = favoriteList.sizePollAccount(); pager.setRecords(records); -// TopiaQuery query = createQuery("e"); -// TopiaFilterPagerUtil.addPagerToQuery(query, pager); -// query.addWhere("e." + PollAccount.PROPERTY_PERSON_LIST, TopiaQuery.Op.EQ, favoriteList); -// -// List<E> result = findAllByQuery(query); - String hql = "FROM PollAccountImpl e WHERE e.personList = :owner"; List<E> result = findAllByQueryAndPager(hql, pager, "owner", favoriteList); @@ -174,21 +188,6 @@ Preconditions.checkNotNull(personListToUpdate); Preconditions.checkNotNull(pollAccount); -// // 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_EMAIL, TopiaQuery.Op.EQ, pollAccount.getEmail()); -// -// String pollAccountId = pollAccount.getTopiaId(); -// if (pollAccountId == null) { -// // no check necessary, it's a new pollAccount -// -// } else { -// query.addWhere("e." + PollAccount.TOPIA_ID, TopiaQuery.Op.NEQ, pollAccountId); -// } -// -// boolean result = existByQuery(query); - String hql = "FROM PollAccountImpl e WHERE " + "e.personList = :person AND " + "e.email = :email";
participants (1)
-
tchemit@users.chorem.org