small refactoring

This commit is contained in:
Athou
2013-08-12 10:03:34 +02:00
parent cf185c3877
commit 51ac16a9e1

View File

@@ -222,24 +222,26 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
} }
} }
List<FeedEntryStatus> statusPlaceholders = set.asList(); List<FeedEntryStatus> placeholders = set.asList();
int size = statusPlaceholders.size(); int size = placeholders.size();
if (size < offset) { if (size < offset) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
placeholders = placeholders.subList(Math.max(offset, 0), size);
statusPlaceholders = statusPlaceholders.subList(Math.max(offset, 0), size); List<FeedEntryStatus> statuses = null;
if (onlyIds) {
if (!onlyIds) { statuses = placeholders;
List<FeedEntryStatus> statuses = Lists.newArrayList(); } else {
for (FeedEntryStatus status : statusPlaceholders) { statuses = Lists.newArrayList();
Long statusId = status.getId(); for (FeedEntryStatus placeholder : placeholders) {
FeedEntry entry = em.find(FeedEntry.class, status.getEntry().getId()); Long statusId = placeholder.getId();
statuses.add(handleStatus(statusId == null ? null : findById(statusId), status.getSubscription(), entry)); FeedEntry entry = em.find(FeedEntry.class, placeholder.getEntry().getId());
statuses.add(handleStatus(statusId == null ? null : findById(statusId), placeholder.getSubscription(), entry));
} }
statusPlaceholders = lazyLoadContent(includeContent, statuses); statuses = lazyLoadContent(includeContent, statuses);
} }
return statusPlaceholders; return statuses;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")