2013-03-22 20:51:22 +01:00
|
|
|
package com.commafeed.backend.dao;
|
|
|
|
|
|
2013-07-19 11:17:19 +02:00
|
|
|
import java.util.Comparator;
|
2013-04-09 11:10:26 +02:00
|
|
|
import java.util.Date;
|
2013-03-30 11:37:57 +01:00
|
|
|
import java.util.List;
|
2013-04-08 13:06:53 +02:00
|
|
|
import java.util.Map;
|
2013-03-30 11:37:57 +01:00
|
|
|
|
2013-03-22 20:51:22 +01:00
|
|
|
import javax.ejb.Stateless;
|
2013-06-27 23:30:16 +02:00
|
|
|
import javax.inject.Inject;
|
2013-04-08 13:06:53 +02:00
|
|
|
import javax.persistence.Query;
|
|
|
|
|
import javax.persistence.TypedQuery;
|
2013-04-10 10:14:27 +02:00
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
2013-04-10 10:28:48 +02:00
|
|
|
import javax.persistence.criteria.Path;
|
2013-04-10 10:14:27 +02:00
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
import javax.persistence.criteria.Root;
|
2013-03-22 20:51:22 +01:00
|
|
|
|
2013-08-07 15:26:43 +02:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2013-07-19 22:25:43 +02:00
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
2013-07-22 16:31:29 +02:00
|
|
|
import org.hibernate.Criteria;
|
|
|
|
|
import org.hibernate.criterion.Disjunction;
|
2013-07-23 15:27:56 +02:00
|
|
|
import org.hibernate.criterion.MatchMode;
|
2013-07-22 16:31:29 +02:00
|
|
|
import org.hibernate.criterion.Order;
|
|
|
|
|
import org.hibernate.criterion.ProjectionList;
|
|
|
|
|
import org.hibernate.criterion.Projections;
|
|
|
|
|
import org.hibernate.criterion.Restrictions;
|
|
|
|
|
import org.hibernate.sql.JoinType;
|
|
|
|
|
import org.hibernate.transform.Transformers;
|
2013-04-08 13:06:53 +02:00
|
|
|
|
2013-07-19 11:17:19 +02:00
|
|
|
import com.commafeed.backend.FixedSizeSortedSet;
|
2013-05-15 16:01:14 +02:00
|
|
|
import com.commafeed.backend.model.FeedEntry;
|
2013-04-11 10:27:20 +02:00
|
|
|
import com.commafeed.backend.model.FeedEntryContent_;
|
2013-03-23 16:17:19 +01:00
|
|
|
import com.commafeed.backend.model.FeedEntryStatus;
|
2013-04-10 10:14:27 +02:00
|
|
|
import com.commafeed.backend.model.FeedEntryStatus_;
|
|
|
|
|
import com.commafeed.backend.model.FeedEntry_;
|
2013-05-15 16:01:14 +02:00
|
|
|
import com.commafeed.backend.model.FeedSubscription;
|
2013-07-02 18:07:08 +02:00
|
|
|
import com.commafeed.backend.model.Models;
|
2013-03-23 17:17:27 +01:00
|
|
|
import com.commafeed.backend.model.User;
|
2013-04-10 10:28:48 +02:00
|
|
|
import com.commafeed.backend.model.UserSettings.ReadingOrder;
|
2013-06-27 23:30:16 +02:00
|
|
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
2013-08-08 17:00:35 +02:00
|
|
|
import com.commafeed.frontend.model.UnreadCount;
|
2013-06-20 16:49:18 +02:00
|
|
|
import com.google.common.collect.Iterables;
|
2013-06-21 09:38:49 +02:00
|
|
|
import com.google.common.collect.Lists;
|
2013-03-22 20:51:22 +01:00
|
|
|
|
|
|
|
|
@Stateless
|
2013-04-11 20:49:08 +02:00
|
|
|
public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
2013-03-22 20:51:22 +01:00
|
|
|
|
2013-07-23 16:19:19 +02:00
|
|
|
private static final String ALIAS_STATUS = "status";
|
|
|
|
|
private static final String ALIAS_ENTRY = "entry";
|
|
|
|
|
|
|
|
|
|
private static final Comparator<FeedEntryStatus> STATUS_COMPARATOR_DESC = new Comparator<FeedEntryStatus>() {
|
2013-07-19 11:17:19 +02:00
|
|
|
@Override
|
2013-07-23 16:19:19 +02:00
|
|
|
public int compare(FeedEntryStatus o1, FeedEntryStatus o2) {
|
2013-07-25 09:17:33 +02:00
|
|
|
return ObjectUtils.compare(o2.getEntryUpdated(), o1.getEntryUpdated());
|
2013-07-19 11:17:19 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-23 16:19:19 +02:00
|
|
|
private static final Comparator<FeedEntryStatus> STATUS_COMPARATOR_ASC = new Comparator<FeedEntryStatus>() {
|
2013-07-19 11:17:19 +02:00
|
|
|
@Override
|
2013-07-23 16:19:19 +02:00
|
|
|
public int compare(FeedEntryStatus o1, FeedEntryStatus o2) {
|
2013-07-25 09:17:33 +02:00
|
|
|
return ObjectUtils.compare(o1.getEntryUpdated(), o2.getEntryUpdated());
|
2013-07-19 11:17:19 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2013-06-27 23:30:16 +02:00
|
|
|
@Inject
|
|
|
|
|
ApplicationSettingsService applicationSettingsService;
|
|
|
|
|
|
2013-07-19 11:17:19 +02:00
|
|
|
public FeedEntryStatus getStatus(FeedSubscription sub, FeedEntry entry) {
|
2013-06-20 16:49:18 +02:00
|
|
|
|
|
|
|
|
CriteriaQuery<FeedEntryStatus> query = builder.createQuery(getType());
|
|
|
|
|
Root<FeedEntryStatus> root = query.from(getType());
|
|
|
|
|
|
|
|
|
|
Predicate p1 = builder.equal(root.get(FeedEntryStatus_.entry), entry);
|
2013-07-25 09:17:33 +02:00
|
|
|
Predicate p2 = builder.equal(root.get(FeedEntryStatus_.subscription), sub);
|
2013-06-20 16:49:18 +02:00
|
|
|
|
|
|
|
|
query.where(p1, p2);
|
|
|
|
|
|
|
|
|
|
List<FeedEntryStatus> statuses = em.createQuery(query).getResultList();
|
2013-07-19 11:17:19 +02:00
|
|
|
FeedEntryStatus status = Iterables.getFirst(statuses, null);
|
2013-07-23 16:19:19 +02:00
|
|
|
|
|
|
|
|
return handleStatus(status, sub, entry);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
private FeedEntryStatus handleStatus(FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
|
2013-07-19 11:17:19 +02:00
|
|
|
if (status == null) {
|
2013-07-27 13:01:28 +02:00
|
|
|
Date unreadThreshold = applicationSettingsService.getUnreadThreshold();
|
2013-07-25 09:17:33 +02:00
|
|
|
boolean read = unreadThreshold == null ? false : entry.getUpdated().before(unreadThreshold);
|
2013-07-19 11:17:19 +02:00
|
|
|
status = new FeedEntryStatus(sub.getUser(), sub, entry);
|
2013-07-23 15:27:56 +02:00
|
|
|
status.setRead(read);
|
|
|
|
|
status.setMarkable(!read);
|
|
|
|
|
} else {
|
|
|
|
|
status.setMarkable(true);
|
2013-06-21 09:38:49 +02:00
|
|
|
}
|
2013-07-19 11:17:19 +02:00
|
|
|
return status;
|
2013-05-22 17:12:01 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
public List<FeedEntryStatus> findStarred(User user, Date newerThan, int offset, int limit, ReadingOrder order, boolean includeContent) {
|
2013-04-29 22:37:26 +02:00
|
|
|
|
|
|
|
|
CriteriaQuery<FeedEntryStatus> query = builder.createQuery(getType());
|
|
|
|
|
Root<FeedEntryStatus> root = query.from(getType());
|
|
|
|
|
|
|
|
|
|
List<Predicate> predicates = Lists.newArrayList();
|
2013-05-15 16:01:14 +02:00
|
|
|
|
2013-07-19 11:17:19 +02:00
|
|
|
predicates.add(builder.equal(root.get(FeedEntryStatus_.user), user));
|
2013-04-29 22:40:49 +02:00
|
|
|
predicates.add(builder.equal(root.get(FeedEntryStatus_.starred), true));
|
|
|
|
|
query.where(predicates.toArray(new Predicate[0]));
|
2013-04-29 22:37:26 +02:00
|
|
|
|
2013-06-08 14:09:46 +02:00
|
|
|
if (newerThan != null) {
|
2013-07-25 09:17:33 +02:00
|
|
|
predicates.add(builder.greaterThanOrEqualTo(root.get(FeedEntryStatus_.entryInserted), newerThan));
|
2013-06-08 14:09:46 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-14 05:48:47 +02:00
|
|
|
orderStatusesBy(query, root, order);
|
2013-04-29 22:37:26 +02:00
|
|
|
|
|
|
|
|
TypedQuery<FeedEntryStatus> q = em.createQuery(query);
|
|
|
|
|
limit(q, offset, limit);
|
2013-06-12 04:58:19 +02:00
|
|
|
setTimeout(q);
|
2013-07-24 15:39:20 +02:00
|
|
|
List<FeedEntryStatus> statuses = q.getResultList();
|
|
|
|
|
for (FeedEntryStatus status : statuses) {
|
2013-07-25 09:17:33 +02:00
|
|
|
status = handleStatus(status, status.getSubscription(), status.getEntry());
|
2013-07-24 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
return lazyLoadContent(includeContent, statuses);
|
2013-04-29 22:37:26 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
private Criteria buildSearchCriteria(FeedSubscription sub, boolean unreadOnly, String keywords, Date newerThan, int offset, int limit,
|
2013-08-09 12:53:21 +02:00
|
|
|
ReadingOrder order, Date last) {
|
2013-07-25 09:17:33 +02:00
|
|
|
Criteria criteria = getSession().createCriteria(FeedEntry.class, ALIAS_ENTRY);
|
2013-07-22 16:31:29 +02:00
|
|
|
|
2013-07-24 15:39:20 +02:00
|
|
|
criteria.add(Restrictions.eq(FeedEntry_.feed.getName(), sub.getFeed()));
|
2013-07-22 16:31:29 +02:00
|
|
|
|
|
|
|
|
if (keywords != null) {
|
2013-07-25 09:17:33 +02:00
|
|
|
Criteria contentJoin = criteria.createCriteria(FeedEntry_.content.getName(), "content", JoinType.INNER_JOIN);
|
2013-07-22 16:31:29 +02:00
|
|
|
|
2013-08-07 15:26:43 +02:00
|
|
|
for (String keyword : StringUtils.split(keywords)) {
|
2013-07-23 15:27:56 +02:00
|
|
|
Disjunction or = Restrictions.disjunction();
|
2013-07-25 09:17:33 +02:00
|
|
|
or.add(Restrictions.ilike(FeedEntryContent_.content.getName(), keyword, MatchMode.ANYWHERE));
|
|
|
|
|
or.add(Restrictions.ilike(FeedEntryContent_.title.getName(), keyword, MatchMode.ANYWHERE));
|
2013-07-23 15:27:56 +02:00
|
|
|
contentJoin.add(or);
|
|
|
|
|
}
|
2013-07-22 16:31:29 +02:00
|
|
|
}
|
2013-07-25 09:17:33 +02:00
|
|
|
Criteria statusJoin = criteria.createCriteria(FeedEntry_.statuses.getName(), ALIAS_STATUS, JoinType.LEFT_OUTER_JOIN,
|
2013-07-23 16:45:13 +02:00
|
|
|
Restrictions.eq(FeedEntryStatus_.subscription.getName(), sub));
|
2013-07-22 16:31:29 +02:00
|
|
|
|
|
|
|
|
if (unreadOnly) {
|
|
|
|
|
|
|
|
|
|
Disjunction or = Restrictions.disjunction();
|
2013-07-23 15:27:56 +02:00
|
|
|
or.add(Restrictions.isNull(FeedEntryStatus_.read.getName()));
|
2013-07-22 16:31:29 +02:00
|
|
|
or.add(Restrictions.eq(FeedEntryStatus_.read.getName(), false));
|
|
|
|
|
statusJoin.add(or);
|
2013-07-23 15:27:56 +02:00
|
|
|
|
2013-07-27 13:01:28 +02:00
|
|
|
Date unreadThreshold = applicationSettingsService.getUnreadThreshold();
|
2013-07-23 15:27:56 +02:00
|
|
|
if (unreadThreshold != null) {
|
2013-07-25 09:17:33 +02:00
|
|
|
criteria.add(Restrictions.ge(FeedEntry_.updated.getName(), unreadThreshold));
|
2013-07-23 15:27:56 +02:00
|
|
|
}
|
2013-07-22 16:31:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-24 15:39:20 +02:00
|
|
|
if (newerThan != null) {
|
2013-07-25 09:17:33 +02:00
|
|
|
criteria.add(Restrictions.ge(FeedEntry_.inserted.getName(), newerThan));
|
2013-07-24 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-22 16:31:29 +02:00
|
|
|
if (last != null) {
|
|
|
|
|
if (order == ReadingOrder.desc) {
|
2013-07-24 15:39:20 +02:00
|
|
|
criteria.add(Restrictions.gt(FeedEntry_.updated.getName(), last));
|
2013-07-22 16:31:29 +02:00
|
|
|
} else {
|
2013-07-24 15:39:20 +02:00
|
|
|
criteria.add(Restrictions.lt(FeedEntry_.updated.getName(), last));
|
2013-07-22 16:31:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (order != null) {
|
|
|
|
|
Order o = null;
|
|
|
|
|
if (order == ReadingOrder.asc) {
|
2013-07-24 15:39:20 +02:00
|
|
|
o = Order.asc(FeedEntry_.updated.getName());
|
2013-07-22 16:31:29 +02:00
|
|
|
} else {
|
2013-07-24 15:39:20 +02:00
|
|
|
o = Order.desc(FeedEntry_.updated.getName());
|
2013-07-22 16:31:29 +02:00
|
|
|
}
|
2013-07-24 15:39:20 +02:00
|
|
|
criteria.addOrder(o);
|
2013-07-22 16:31:29 +02:00
|
|
|
}
|
|
|
|
|
if (offset > -1) {
|
|
|
|
|
criteria.setFirstResult(offset);
|
|
|
|
|
}
|
|
|
|
|
if (limit > -1) {
|
|
|
|
|
criteria.setMaxResults(limit);
|
|
|
|
|
}
|
|
|
|
|
int timeout = applicationSettingsService.get().getQueryTimeout();
|
|
|
|
|
if (timeout > 0) {
|
2013-07-30 14:38:50 +02:00
|
|
|
// hibernate timeout is in seconds, jpa timeout is in millis
|
|
|
|
|
criteria.setTimeout(timeout / 1000);
|
2013-07-22 16:31:29 +02:00
|
|
|
}
|
|
|
|
|
return criteria;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
2013-08-09 12:53:21 +02:00
|
|
|
public List<FeedEntryStatus> findBySubscriptions(List<FeedSubscription> subs, boolean unreadOnly, String keywords, Date newerThan,
|
|
|
|
|
int offset, int limit, ReadingOrder order, boolean includeContent, boolean onlyIds) {
|
2013-07-19 11:17:19 +02:00
|
|
|
int capacity = offset + limit;
|
2013-07-25 09:17:33 +02:00
|
|
|
Comparator<FeedEntryStatus> comparator = order == ReadingOrder.desc ? STATUS_COMPARATOR_DESC : STATUS_COMPARATOR_ASC;
|
|
|
|
|
FixedSizeSortedSet<FeedEntryStatus> set = new FixedSizeSortedSet<FeedEntryStatus>(capacity, comparator);
|
2013-08-09 12:53:21 +02:00
|
|
|
for (FeedSubscription sub : subs) {
|
2013-07-25 09:17:33 +02:00
|
|
|
Date last = (order != null && set.isFull()) ? set.last().getEntryUpdated() : null;
|
2013-08-09 12:53:21 +02:00
|
|
|
Criteria criteria = buildSearchCriteria(sub, unreadOnly, keywords, newerThan, -1, capacity, order, last);
|
2013-08-06 12:39:12 +02:00
|
|
|
ProjectionList projection = Projections.projectionList();
|
|
|
|
|
projection.add(Projections.property("id"), "id");
|
|
|
|
|
projection.add(Projections.property("updated"), "updated");
|
2013-08-12 10:01:24 +02:00
|
|
|
projection.add(Projections.property(ALIAS_STATUS + ".id"), "status_id");
|
2013-08-06 12:39:12 +02:00
|
|
|
criteria.setProjection(projection);
|
|
|
|
|
criteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
2013-07-23 16:19:19 +02:00
|
|
|
List<Map<String, Object>> list = criteria.list();
|
|
|
|
|
for (Map<String, Object> map : list) {
|
2013-08-06 12:39:12 +02:00
|
|
|
Long id = (Long) map.get("id");
|
|
|
|
|
Date updated = (Date) map.get("updated");
|
2013-08-12 10:01:24 +02:00
|
|
|
Long statusId = (Long) map.get("status_id");
|
2013-07-23 16:19:19 +02:00
|
|
|
|
2013-08-06 12:39:12 +02:00
|
|
|
FeedEntry entry = new FeedEntry();
|
|
|
|
|
entry.setId(id);
|
|
|
|
|
entry.setUpdated(updated);
|
2013-07-23 16:19:19 +02:00
|
|
|
|
2013-08-06 12:39:12 +02:00
|
|
|
FeedEntryStatus status = new FeedEntryStatus();
|
2013-08-12 10:01:24 +02:00
|
|
|
status.setId(statusId);
|
2013-08-06 12:39:12 +02:00
|
|
|
status.setEntryUpdated(updated);
|
2013-07-23 16:19:19 +02:00
|
|
|
status.setEntry(entry);
|
2013-08-06 12:39:12 +02:00
|
|
|
status.setSubscription(sub);
|
|
|
|
|
|
2013-07-23 16:19:19 +02:00
|
|
|
set.add(status);
|
2013-07-19 11:17:19 +02:00
|
|
|
}
|
2013-06-20 18:45:58 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 10:03:34 +02:00
|
|
|
List<FeedEntryStatus> placeholders = set.asList();
|
|
|
|
|
int size = placeholders.size();
|
2013-07-19 11:17:19 +02:00
|
|
|
if (size < offset) {
|
|
|
|
|
return Lists.newArrayList();
|
2013-06-20 18:45:58 +02:00
|
|
|
}
|
2013-08-12 10:03:34 +02:00
|
|
|
placeholders = placeholders.subList(Math.max(offset, 0), size);
|
2013-06-20 18:45:58 +02:00
|
|
|
|
2013-08-12 10:03:34 +02:00
|
|
|
List<FeedEntryStatus> statuses = null;
|
|
|
|
|
if (onlyIds) {
|
|
|
|
|
statuses = placeholders;
|
|
|
|
|
} else {
|
|
|
|
|
statuses = Lists.newArrayList();
|
|
|
|
|
for (FeedEntryStatus placeholder : placeholders) {
|
|
|
|
|
Long statusId = placeholder.getId();
|
|
|
|
|
FeedEntry entry = em.find(FeedEntry.class, placeholder.getEntry().getId());
|
|
|
|
|
statuses.add(handleStatus(statusId == null ? null : findById(statusId), placeholder.getSubscription(), entry));
|
2013-08-09 12:53:21 +02:00
|
|
|
}
|
2013-08-12 10:03:34 +02:00
|
|
|
statuses = lazyLoadContent(includeContent, statuses);
|
2013-08-06 12:39:12 +02:00
|
|
|
}
|
2013-08-12 10:03:34 +02:00
|
|
|
return statuses;
|
2013-06-20 18:45:58 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-22 16:31:29 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2013-08-08 17:00:35 +02:00
|
|
|
public UnreadCount getUnreadCount(FeedSubscription subscription) {
|
|
|
|
|
UnreadCount uc = null;
|
2013-08-09 12:53:21 +02:00
|
|
|
Criteria criteria = buildSearchCriteria(subscription, true, null, null, -1, -1, null, null);
|
2013-07-22 16:31:29 +02:00
|
|
|
ProjectionList projection = Projections.projectionList();
|
|
|
|
|
projection.add(Projections.rowCount(), "count");
|
2013-08-08 17:00:35 +02:00
|
|
|
projection.add(Projections.max(FeedEntry_.updated.getName()), "updated");
|
2013-07-22 16:31:29 +02:00
|
|
|
criteria.setProjection(projection);
|
|
|
|
|
criteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
2013-08-08 17:00:35 +02:00
|
|
|
List<Map<String, Object>> list = criteria.list();
|
|
|
|
|
for (Map<String, Object> row : list) {
|
|
|
|
|
Long count = (Long) row.get("count");
|
|
|
|
|
Date updated = (Date) row.get("updated");
|
|
|
|
|
uc = new UnreadCount(subscription.getId(), count, updated);
|
2013-07-19 12:18:10 +02:00
|
|
|
}
|
2013-08-08 17:00:35 +02:00
|
|
|
return uc;
|
2013-07-19 12:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
private List<FeedEntryStatus> lazyLoadContent(boolean includeContent, List<FeedEntryStatus> results) {
|
2013-05-17 11:25:50 +02:00
|
|
|
if (includeContent) {
|
|
|
|
|
for (FeedEntryStatus status : results) {
|
2013-07-02 18:07:08 +02:00
|
|
|
Models.initialize(status.getSubscription().getFeed());
|
|
|
|
|
Models.initialize(status.getEntry().getContent());
|
2013-05-17 11:25:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return results;
|
2013-04-10 10:28:48 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
private void orderStatusesBy(CriteriaQuery<?> query, Path<FeedEntryStatus> statusJoin, ReadingOrder order) {
|
2013-07-14 05:48:47 +02:00
|
|
|
orderBy(query, statusJoin.get(FeedEntryStatus_.entryUpdated), order);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
private void orderBy(CriteriaQuery<?> query, Path<Date> date, ReadingOrder order) {
|
2013-06-18 13:48:07 +02:00
|
|
|
if (order != null) {
|
|
|
|
|
if (order == ReadingOrder.asc) {
|
2013-07-14 05:48:47 +02:00
|
|
|
query.orderBy(builder.asc(date));
|
2013-06-18 13:48:07 +02:00
|
|
|
} else {
|
2013-07-14 05:48:47 +02:00
|
|
|
query.orderBy(builder.desc(date));
|
2013-06-18 13:48:07 +02:00
|
|
|
}
|
2013-04-10 10:28:48 +02:00
|
|
|
}
|
2013-04-08 13:06:53 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 21:15:32 +02:00
|
|
|
protected void setTimeout(Query query) {
|
|
|
|
|
setTimeout(query, applicationSettingsService.get().getQueryTimeout());
|
2013-06-12 04:58:19 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-17 12:55:27 +02:00
|
|
|
public int deleteOldStatuses(Date olderThan, int limit) {
|
2013-07-25 11:02:49 +02:00
|
|
|
Query query = em.createNamedQuery("Statuses.deleteOld");
|
|
|
|
|
query.setParameter("date", olderThan);
|
2013-09-17 12:55:27 +02:00
|
|
|
query.setMaxResults(limit);
|
2013-07-25 11:02:49 +02:00
|
|
|
return query.executeUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 20:51:22 +01:00
|
|
|
}
|