mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
smarter queries for other types
This commit is contained in:
@@ -163,7 +163,6 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
|
|
||||||
public List<FeedEntryStatus> findAll(User user, Date newerThan, int offset,
|
public List<FeedEntryStatus> findAll(User user, Date newerThan, int offset,
|
||||||
int limit, ReadingOrder order, boolean includeContent) {
|
int limit, ReadingOrder order, boolean includeContent) {
|
||||||
log.info("new findAll");
|
|
||||||
|
|
||||||
CriteriaQuery<Tuple> query = builder.createTupleQuery();
|
CriteriaQuery<Tuple> query = builder.createTupleQuery();
|
||||||
Root<FeedEntry> root = query.from(FeedEntry.class);
|
Root<FeedEntry> root = query.from(FeedEntry.class);
|
||||||
@@ -203,6 +202,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
if (status == null) {
|
if (status == null) {
|
||||||
status = new FeedEntryStatus();
|
status = new FeedEntryStatus();
|
||||||
status.setEntry(entry);
|
status.setEntry(entry);
|
||||||
|
status.setRead(true);
|
||||||
status.setSubscription(subscription);
|
status.setSubscription(subscription);
|
||||||
}
|
}
|
||||||
results.add(status);
|
results.add(status);
|
||||||
@@ -247,16 +247,61 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<FeedEntryStatus> findBySubscription(
|
public List<FeedEntryStatus> findBySubscription(
|
||||||
FeedSubscription subscription, boolean unreadOnly,
|
FeedSubscription subscription, Date newerThan, int offset,
|
||||||
ReadingOrder order, boolean includeContent) {
|
int limit, ReadingOrder order, boolean includeContent) {
|
||||||
return findBySubscription(subscription, unreadOnly, null, -1, -1,
|
|
||||||
order, includeContent);
|
CriteriaQuery<FeedEntry> query = builder.createQuery(FeedEntry.class);
|
||||||
|
Root<FeedEntry> root = query.from(FeedEntry.class);
|
||||||
|
|
||||||
|
SetJoin<FeedEntry, Feed> feedJoin = root.join(FeedEntry_.feeds);
|
||||||
|
SetJoin<Feed, FeedSubscription> subJoin = feedJoin
|
||||||
|
.join(Feed_.subscriptions);
|
||||||
|
|
||||||
|
List<Predicate> predicates = Lists.newArrayList();
|
||||||
|
|
||||||
|
predicates.add(builder.equal(subJoin.get(FeedSubscription_.id),
|
||||||
|
subscription.getId()));
|
||||||
|
|
||||||
|
if (newerThan != null) {
|
||||||
|
predicates.add(builder.greaterThanOrEqualTo(
|
||||||
|
root.get(FeedEntry_.inserted), newerThan));
|
||||||
|
}
|
||||||
|
|
||||||
|
query.where(predicates.toArray(new Predicate[0]));
|
||||||
|
orderBy(query, root, order);
|
||||||
|
|
||||||
|
TypedQuery<FeedEntry> q = em.createQuery(query);
|
||||||
|
limit(q, offset, limit);
|
||||||
|
setTimeout(q);
|
||||||
|
|
||||||
|
List<FeedEntry> list = q.getResultList();
|
||||||
|
List<FeedEntryStatus> results = Lists.newArrayList();
|
||||||
|
for (FeedEntry entry : list) {
|
||||||
|
FeedEntryStatus status = findByEntry(entry, subscription);
|
||||||
|
if (status == null) {
|
||||||
|
status = new FeedEntryStatus();
|
||||||
|
status.setEntry(entry);
|
||||||
|
status.setSubscription(subscription);
|
||||||
|
status.setRead(true);
|
||||||
|
}
|
||||||
|
results.add(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lazyLoadContent(includeContent, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FeedEntryStatus> findBySubscription(
|
public List<FeedEntryStatus> findUnreadBySubscription(
|
||||||
FeedSubscription subscription, boolean unreadOnly, Date newerThan,
|
FeedSubscription subscription, ReadingOrder order,
|
||||||
int offset, int limit, ReadingOrder order, boolean includeContent) {
|
boolean includeContent) {
|
||||||
|
return findUnreadBySubscription(subscription, null, -1, -1, order,
|
||||||
|
includeContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FeedEntryStatus> findUnreadBySubscription(
|
||||||
|
FeedSubscription subscription, Date newerThan, int offset,
|
||||||
|
int limit, ReadingOrder order, boolean includeContent) {
|
||||||
|
|
||||||
|
log.info("findUnreadBySubscription");
|
||||||
CriteriaQuery<FeedEntryStatus> query = builder.createQuery(getType());
|
CriteriaQuery<FeedEntryStatus> query = builder.createQuery(getType());
|
||||||
Root<FeedEntryStatus> root = query.from(getType());
|
Root<FeedEntryStatus> root = query.from(getType());
|
||||||
|
|
||||||
@@ -267,9 +312,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
|
|
||||||
predicates.add(builder.equal(root.get(FeedEntryStatus_.subscription),
|
predicates.add(builder.equal(root.get(FeedEntryStatus_.subscription),
|
||||||
subscription));
|
subscription));
|
||||||
if (unreadOnly) {
|
predicates.add(builder.isFalse(root.get(FeedEntryStatus_.read)));
|
||||||
predicates.add(builder.isFalse(root.get(FeedEntryStatus_.read)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newerThan != null) {
|
if (newerThan != null) {
|
||||||
predicates.add(builder.greaterThanOrEqualTo(
|
predicates.add(builder.greaterThanOrEqualTo(
|
||||||
@@ -287,16 +330,73 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<FeedEntryStatus> findByCategories(
|
public List<FeedEntryStatus> findByCategories(
|
||||||
List<FeedCategory> categories, User user, boolean unreadOnly,
|
List<FeedCategory> categories, Date newerThan, int offset,
|
||||||
ReadingOrder order, boolean includeContent) {
|
int limit, ReadingOrder order, boolean includeContent) {
|
||||||
return findByCategories(categories, user, unreadOnly, null, -1, -1,
|
|
||||||
order, includeContent);
|
CriteriaQuery<Tuple> query = builder.createTupleQuery();
|
||||||
|
Root<FeedEntry> root = query.from(FeedEntry.class);
|
||||||
|
|
||||||
|
SetJoin<FeedEntry, Feed> feedJoin = root.join(FeedEntry_.feeds);
|
||||||
|
SetJoin<Feed, FeedSubscription> subJoin = feedJoin
|
||||||
|
.join(Feed_.subscriptions);
|
||||||
|
|
||||||
|
Selection<FeedEntry> entryAlias = root.alias("entry");
|
||||||
|
Selection<FeedSubscription> subAlias = subJoin.alias("subscription");
|
||||||
|
query.multiselect(entryAlias, subAlias);
|
||||||
|
|
||||||
|
List<Predicate> predicates = Lists.newArrayList();
|
||||||
|
|
||||||
|
if (categories.size() == 1) {
|
||||||
|
predicates.add(builder.equal(subJoin
|
||||||
|
.get(FeedSubscription_.category), categories.iterator()
|
||||||
|
.next()));
|
||||||
|
} else {
|
||||||
|
predicates.add(subJoin.get(FeedSubscription_.category).in(
|
||||||
|
categories));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newerThan != null) {
|
||||||
|
predicates.add(builder.greaterThanOrEqualTo(
|
||||||
|
root.get(FeedEntry_.inserted), newerThan));
|
||||||
|
}
|
||||||
|
|
||||||
|
query.where(predicates.toArray(new Predicate[0]));
|
||||||
|
orderBy(query, root, order);
|
||||||
|
|
||||||
|
TypedQuery<Tuple> q = em.createQuery(query);
|
||||||
|
limit(q, offset, limit);
|
||||||
|
setTimeout(q);
|
||||||
|
|
||||||
|
List<Tuple> list = q.getResultList();
|
||||||
|
List<FeedEntryStatus> results = Lists.newArrayList();
|
||||||
|
for (Tuple tuple : list) {
|
||||||
|
FeedEntry entry = tuple.get(entryAlias);
|
||||||
|
FeedSubscription subscription = tuple.get(subAlias);
|
||||||
|
|
||||||
|
FeedEntryStatus status = findByEntry(entry, subscription);
|
||||||
|
if (status == null) {
|
||||||
|
status = new FeedEntryStatus();
|
||||||
|
status.setEntry(entry);
|
||||||
|
status.setSubscription(subscription);
|
||||||
|
status.setRead(true);
|
||||||
|
}
|
||||||
|
results.add(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lazyLoadContent(includeContent, results);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FeedEntryStatus> findByCategories(
|
public List<FeedEntryStatus> findUnreadByCategories(
|
||||||
List<FeedCategory> categories, User user, boolean unreadOnly,
|
List<FeedCategory> categories, ReadingOrder order,
|
||||||
Date newerThan, int offset, int limit, ReadingOrder order,
|
|
||||||
boolean includeContent) {
|
boolean includeContent) {
|
||||||
|
return findUnreadByCategories(categories, null, -1, -1, order,
|
||||||
|
includeContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FeedEntryStatus> findUnreadByCategories(
|
||||||
|
List<FeedCategory> categories, Date newerThan, int offset,
|
||||||
|
int limit, ReadingOrder order, boolean includeContent) {
|
||||||
|
|
||||||
CriteriaQuery<FeedEntryStatus> query = builder.createQuery(getType());
|
CriteriaQuery<FeedEntryStatus> query = builder.createQuery(getType());
|
||||||
Root<FeedEntryStatus> root = query.from(getType());
|
Root<FeedEntryStatus> root = query.from(getType());
|
||||||
@@ -308,9 +408,6 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
Join<FeedEntryStatus, FeedSubscription> subJoin = root
|
Join<FeedEntryStatus, FeedSubscription> subJoin = root
|
||||||
.join(FeedEntryStatus_.subscription);
|
.join(FeedEntryStatus_.subscription);
|
||||||
|
|
||||||
predicates
|
|
||||||
.add(builder.equal(subJoin.get(FeedSubscription_.user), user));
|
|
||||||
|
|
||||||
if (categories.size() == 1) {
|
if (categories.size() == 1) {
|
||||||
predicates.add(builder.equal(subJoin
|
predicates.add(builder.equal(subJoin
|
||||||
.get(FeedSubscription_.category), categories.iterator()
|
.get(FeedSubscription_.category), categories.iterator()
|
||||||
@@ -320,9 +417,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
categories));
|
categories));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unreadOnly) {
|
predicates.add(builder.isFalse(root.get(FeedEntryStatus_.read)));
|
||||||
predicates.add(builder.isFalse(root.get(FeedEntryStatus_.read)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newerThan != null) {
|
if (newerThan != null) {
|
||||||
predicates.add(builder.greaterThanOrEqualTo(
|
predicates.add(builder.greaterThanOrEqualTo(
|
||||||
@@ -384,41 +479,46 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
|
|
||||||
public void markSubscriptionEntries(FeedSubscription subscription,
|
public void markSubscriptionEntries(FeedSubscription subscription,
|
||||||
Date olderThan) {
|
Date olderThan) {
|
||||||
List<FeedEntryStatus> statuses = findBySubscription(subscription, true,
|
List<FeedEntryStatus> statuses = findUnreadBySubscription(subscription,
|
||||||
null, false);
|
null, false);
|
||||||
saveOrUpdate(markList(statuses, olderThan));
|
markList(statuses, olderThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markCategoryEntries(User user, List<FeedCategory> categories,
|
public void markCategoryEntries(User user, List<FeedCategory> categories,
|
||||||
Date olderThan) {
|
Date olderThan) {
|
||||||
List<FeedEntryStatus> statuses = findByCategories(categories, user,
|
List<FeedEntryStatus> statuses = findUnreadByCategories(categories,
|
||||||
true, null, false);
|
null, false);
|
||||||
saveOrUpdate(markList(statuses, olderThan));
|
markList(statuses, olderThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markStarredEntries(User user, Date olderThan) {
|
public void markStarredEntries(User user, Date olderThan) {
|
||||||
List<FeedEntryStatus> statuses = findStarred(user, null, false);
|
List<FeedEntryStatus> statuses = findStarred(user, null, false);
|
||||||
saveOrUpdate(markList(statuses, olderThan));
|
markList(statuses, olderThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAllEntries(User user, Date olderThan) {
|
public void markAllEntries(User user, Date olderThan) {
|
||||||
List<FeedEntryStatus> statuses = findAllUnread(user, null, false);
|
List<FeedEntryStatus> statuses = findAllUnread(user, null, false);
|
||||||
saveOrUpdate(markList(statuses, olderThan));
|
markList(statuses, olderThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<FeedEntryStatus> markList(List<FeedEntryStatus> statuses,
|
private void markList(List<FeedEntryStatus> statuses, Date olderThan) {
|
||||||
Date olderThan) {
|
|
||||||
List<FeedEntryStatus> list = Lists.newArrayList();
|
List<FeedEntryStatus> list = Lists.newArrayList();
|
||||||
for (FeedEntryStatus status : statuses) {
|
for (FeedEntryStatus status : statuses) {
|
||||||
if (!status.isRead()) {
|
if (!status.isRead()) {
|
||||||
Date inserted = status.getEntry().getInserted();
|
Date inserted = status.getEntry().getInserted();
|
||||||
if (olderThan == null || inserted == null
|
if (olderThan == null || inserted == null
|
||||||
|| olderThan.after(inserted)) {
|
|| olderThan.after(inserted)) {
|
||||||
status.setRead(true);
|
if (status.isStarred()) {
|
||||||
list.add(status);
|
status.setRead(true);
|
||||||
|
list.add(status);
|
||||||
|
} else {
|
||||||
|
delete(status);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
saveOrUpdate(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import javax.ejb.Stateless;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||||
|
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||||
|
import com.commafeed.backend.model.FeedEntry;
|
||||||
import com.commafeed.backend.model.FeedEntryStatus;
|
import com.commafeed.backend.model.FeedEntryStatus;
|
||||||
|
import com.commafeed.backend.model.FeedSubscription;
|
||||||
import com.commafeed.backend.model.User;
|
import com.commafeed.backend.model.User;
|
||||||
|
|
||||||
@Stateless
|
@Stateless
|
||||||
@@ -13,18 +16,74 @@ public class FeedEntryService {
|
|||||||
@Inject
|
@Inject
|
||||||
FeedEntryStatusDAO feedEntryStatusDAO;
|
FeedEntryStatusDAO feedEntryStatusDAO;
|
||||||
|
|
||||||
public void markEntry(User user, Long entryId, boolean read) {
|
@Inject
|
||||||
FeedEntryStatus status = feedEntryStatusDAO.findById(user, entryId);
|
FeedSubscriptionDAO feedSubscriptionDAO;
|
||||||
if (status != null) {
|
|
||||||
status.setRead(read);
|
public void markEntry(User user, Long entryId, Long subscriptionId,
|
||||||
|
boolean read) {
|
||||||
|
FeedSubscription sub = feedSubscriptionDAO.findById(user,
|
||||||
|
subscriptionId);
|
||||||
|
if (sub == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FeedEntry entry = new FeedEntry();
|
||||||
|
entry.setId(entryId);
|
||||||
|
|
||||||
|
FeedEntryStatus status = feedEntryStatusDAO.findByEntry(entry, sub);
|
||||||
|
|
||||||
|
if (read) {
|
||||||
|
if (status != null) {
|
||||||
|
if (status.isStarred()) {
|
||||||
|
status.setRead(true);
|
||||||
|
feedEntryStatusDAO.saveOrUpdate(status);
|
||||||
|
} else {
|
||||||
|
feedEntryStatusDAO.delete(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (status == null) {
|
||||||
|
status = new FeedEntryStatus();
|
||||||
|
status.setEntry(entry);
|
||||||
|
status.setSubscription(sub);
|
||||||
|
}
|
||||||
|
status.setRead(false);
|
||||||
feedEntryStatusDAO.saveOrUpdate(status);
|
feedEntryStatusDAO.saveOrUpdate(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void starEntry(User user, Long entryId, boolean starred) {
|
public void starEntry(User user, Long entryId, Long subscriptionId,
|
||||||
FeedEntryStatus status = feedEntryStatusDAO.findById(user, entryId);
|
boolean starred) {
|
||||||
if (status != null) {
|
|
||||||
status.setStarred(starred);
|
FeedSubscription sub = feedSubscriptionDAO.findById(user,
|
||||||
|
subscriptionId);
|
||||||
|
if (sub == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FeedEntry entry = new FeedEntry();
|
||||||
|
entry.setId(entryId);
|
||||||
|
|
||||||
|
FeedEntryStatus status = feedEntryStatusDAO.findByEntry(entry, sub);
|
||||||
|
|
||||||
|
if (!starred) {
|
||||||
|
if (status != null) {
|
||||||
|
if (!status.isRead()) {
|
||||||
|
status.setStarred(false);
|
||||||
|
feedEntryStatusDAO.saveOrUpdate(status);
|
||||||
|
} else {
|
||||||
|
feedEntryStatusDAO.delete(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (status == null) {
|
||||||
|
status = new FeedEntryStatus();
|
||||||
|
status.setEntry(entry);
|
||||||
|
status.setSubscription(sub);
|
||||||
|
status.setRead(true);
|
||||||
|
}
|
||||||
|
status.setStarred(true);
|
||||||
feedEntryStatusDAO.saveOrUpdate(status);
|
feedEntryStatusDAO.saveOrUpdate(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
import com.commafeed.backend.feeds.FeedUtils;
|
import com.commafeed.backend.feeds.FeedUtils;
|
||||||
import com.commafeed.backend.model.FeedEntry;
|
import com.commafeed.backend.model.FeedEntry;
|
||||||
import com.commafeed.backend.model.FeedEntryStatus;
|
import com.commafeed.backend.model.FeedEntryStatus;
|
||||||
|
import com.commafeed.backend.model.FeedSubscription;
|
||||||
import com.sun.syndication.feed.synd.SyndContentImpl;
|
import com.sun.syndication.feed.synd.SyndContentImpl;
|
||||||
import com.sun.syndication.feed.synd.SyndEntry;
|
import com.sun.syndication.feed.synd.SyndEntry;
|
||||||
import com.sun.syndication.feed.synd.SyndEntryImpl;
|
import com.sun.syndication.feed.synd.SyndEntryImpl;
|
||||||
@@ -27,28 +28,28 @@ public class Entry implements Serializable {
|
|||||||
Entry entry = new Entry();
|
Entry entry = new Entry();
|
||||||
|
|
||||||
FeedEntry feedEntry = status.getEntry();
|
FeedEntry feedEntry = status.getEntry();
|
||||||
entry.setId(String.valueOf(status.getId()));
|
FeedSubscription sub = status.getSubscription();
|
||||||
|
|
||||||
|
entry.setRead(status.isRead());
|
||||||
|
entry.setStarred(status.isStarred());
|
||||||
|
|
||||||
|
entry.setId(String.valueOf(feedEntry.getId()));
|
||||||
entry.setGuid(feedEntry.getGuid());
|
entry.setGuid(feedEntry.getGuid());
|
||||||
entry.setTitle(feedEntry.getContent().getTitle());
|
entry.setTitle(feedEntry.getContent().getTitle());
|
||||||
entry.setContent(feedEntry.getContent().getContent());
|
entry.setContent(feedEntry.getContent().getContent());
|
||||||
entry.setRtl(FeedUtils.isRTL(feedEntry));
|
entry.setRtl(FeedUtils.isRTL(feedEntry));
|
||||||
entry.setAuthor(feedEntry.getAuthor());
|
entry.setAuthor(feedEntry.getAuthor());
|
||||||
entry.setEnclosureUrl(status.getEntry().getContent().getEnclosureUrl());
|
entry.setEnclosureUrl(feedEntry.getContent().getEnclosureUrl());
|
||||||
entry.setEnclosureType(status.getEntry().getContent()
|
entry.setEnclosureType(feedEntry.getContent().getEnclosureType());
|
||||||
.getEnclosureType());
|
|
||||||
entry.setDate(feedEntry.getUpdated());
|
entry.setDate(feedEntry.getUpdated());
|
||||||
entry.setInsertedDate(feedEntry.getInserted());
|
entry.setInsertedDate(feedEntry.getInserted());
|
||||||
entry.setUrl(feedEntry.getUrl());
|
entry.setUrl(feedEntry.getUrl());
|
||||||
|
|
||||||
entry.setRead(status.isRead());
|
entry.setFeedName(sub.getTitle());
|
||||||
entry.setStarred(status.isStarred());
|
entry.setFeedId(String.valueOf(sub.getId()));
|
||||||
|
entry.setFeedUrl(sub.getFeed().getUrl());
|
||||||
entry.setFeedName(status.getSubscription().getTitle());
|
entry.setFeedLink(sub.getFeed().getLink());
|
||||||
entry.setFeedId(String.valueOf(status.getSubscription().getId()));
|
entry.setIconUrl(FeedUtils.getFaviconUrl(sub, publicUrl));
|
||||||
entry.setFeedUrl(status.getSubscription().getFeed().getUrl());
|
|
||||||
entry.setFeedLink(status.getSubscription().getFeed().getLink());
|
|
||||||
entry.setIconUrl(FeedUtils.getFaviconUrl(status.getSubscription(),
|
|
||||||
publicUrl));
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,12 @@ import com.wordnik.swagger.annotations.ApiProperty;
|
|||||||
@ApiClass("Mark Request")
|
@ApiClass("Mark Request")
|
||||||
public class MarkRequest implements Serializable {
|
public class MarkRequest implements Serializable {
|
||||||
|
|
||||||
@ApiProperty(value = "id", required = true)
|
@ApiProperty(value = "entry id, category id, 'all' or 'starred'", required = true)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiProperty(value = "feed id, only required when marking an entry")
|
||||||
|
private Long feedId;
|
||||||
|
|
||||||
@ApiProperty(value = "mark as read or unread")
|
@ApiProperty(value = "mark as read or unread")
|
||||||
private boolean read;
|
private boolean read;
|
||||||
|
|
||||||
@@ -48,4 +51,12 @@ public class MarkRequest implements Serializable {
|
|||||||
this.olderThan = olderThan;
|
this.olderThan = olderThan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getFeedId() {
|
||||||
|
return feedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeedId(Long feedId) {
|
||||||
|
this.feedId = feedId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public class StarRequest implements Serializable {
|
|||||||
@ApiProperty(value = "id", required = true)
|
@ApiProperty(value = "id", required = true)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiProperty(value = "feed id", required = true)
|
||||||
|
private Long feedId;
|
||||||
|
|
||||||
@ApiProperty(value = "starred or not")
|
@ApiProperty(value = "starred or not")
|
||||||
private boolean starred;
|
private boolean starred;
|
||||||
|
|
||||||
@@ -37,4 +40,12 @@ public class StarRequest implements Serializable {
|
|||||||
this.starred = starred;
|
this.starred = starred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getFeedId() {
|
||||||
|
return feedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeedId(Long feedId) {
|
||||||
|
this.feedId = feedId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ public class NextUnreadRedirectPage extends WebPage {
|
|||||||
if (category != null) {
|
if (category != null) {
|
||||||
List<FeedCategory> children = feedCategoryDAO
|
List<FeedCategory> children = feedCategoryDAO
|
||||||
.findAllChildrenCategories(user, category);
|
.findAllChildrenCategories(user, category);
|
||||||
statuses = feedEntryStatusDAO.findByCategories(children, user,
|
statuses = feedEntryStatusDAO.findUnreadByCategories(children,
|
||||||
true, null, 0, 1, ReadingOrder.desc, false);
|
null, 0, 1, ReadingOrder.desc, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,11 +114,17 @@ public class CategoryREST extends AbstractResourceREST {
|
|||||||
if (feedCategory != null) {
|
if (feedCategory != null) {
|
||||||
List<FeedCategory> childrenCategories = feedCategoryDAO
|
List<FeedCategory> childrenCategories = feedCategoryDAO
|
||||||
.findAllChildrenCategories(getUser(), feedCategory);
|
.findAllChildrenCategories(getUser(), feedCategory);
|
||||||
List<FeedEntryStatus> unreadEntries = feedEntryStatusDAO
|
List<FeedEntryStatus> list = null;
|
||||||
.findByCategories(childrenCategories, getUser(),
|
if (unreadOnly) {
|
||||||
unreadOnly, newerThanDate, offset, limit + 1,
|
list = feedEntryStatusDAO.findUnreadByCategories(
|
||||||
order, true);
|
childrenCategories, newerThanDate, offset,
|
||||||
for (FeedEntryStatus status : unreadEntries) {
|
limit + 1, order, true);
|
||||||
|
} else {
|
||||||
|
list = feedEntryStatusDAO.findByCategories(
|
||||||
|
childrenCategories, newerThanDate, offset,
|
||||||
|
limit + 1, order, true);
|
||||||
|
}
|
||||||
|
for (FeedEntryStatus status : list) {
|
||||||
entries.getEntries().add(
|
entries.getEntries().add(
|
||||||
Entry.build(status, applicationSettingsService
|
Entry.build(status, applicationSettingsService
|
||||||
.get().getPublicUrl()));
|
.get().getPublicUrl()));
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ public class EntryREST extends AbstractResourceREST {
|
|||||||
@ApiParam(value = "Mark Request", required = true) MarkRequest req) {
|
@ApiParam(value = "Mark Request", required = true) MarkRequest req) {
|
||||||
Preconditions.checkNotNull(req);
|
Preconditions.checkNotNull(req);
|
||||||
Preconditions.checkNotNull(req.getId());
|
Preconditions.checkNotNull(req.getId());
|
||||||
|
Preconditions.checkNotNull(req.getFeedId());
|
||||||
|
|
||||||
feedEntryService.markEntry(getUser(), Long.valueOf(req.getId()),
|
feedEntryService.markEntry(getUser(), Long.valueOf(req.getId()),
|
||||||
req.isRead());
|
req.getFeedId(), req.isRead());
|
||||||
|
|
||||||
return Response.ok(Status.OK).build();
|
return Response.ok(Status.OK).build();
|
||||||
}
|
}
|
||||||
@@ -48,9 +49,10 @@ public class EntryREST extends AbstractResourceREST {
|
|||||||
@ApiParam(value = "Star Request", required = true) StarRequest req) {
|
@ApiParam(value = "Star Request", required = true) StarRequest req) {
|
||||||
Preconditions.checkNotNull(req);
|
Preconditions.checkNotNull(req);
|
||||||
Preconditions.checkNotNull(req.getId());
|
Preconditions.checkNotNull(req.getId());
|
||||||
|
Preconditions.checkNotNull(req.getFeedId());
|
||||||
|
|
||||||
feedEntryService.starEntry(getUser(), Long.valueOf(req.getId()),
|
feedEntryService.starEntry(getUser(), Long.valueOf(req.getId()),
|
||||||
req.isStarred());
|
req.getFeedId(), req.isStarred());
|
||||||
|
|
||||||
return Response.ok(Status.OK).build();
|
return Response.ok(Status.OK).build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,10 +100,17 @@ public class FeedREST extends AbstractResourceREST {
|
|||||||
entries.setMessage(subscription.getFeed().getMessage());
|
entries.setMessage(subscription.getFeed().getMessage());
|
||||||
entries.setErrorCount(subscription.getFeed().getErrorCount());
|
entries.setErrorCount(subscription.getFeed().getErrorCount());
|
||||||
|
|
||||||
List<FeedEntryStatus> unreadEntries = feedEntryStatusDAO
|
List<FeedEntryStatus> list = null;
|
||||||
.findBySubscription(subscription, unreadOnly,
|
if (unreadOnly) {
|
||||||
newerThanDate, offset, limit + 1, order, true);
|
list = feedEntryStatusDAO.findUnreadBySubscription(
|
||||||
for (FeedEntryStatus status : unreadEntries) {
|
subscription, newerThanDate, offset, limit + 1, order,
|
||||||
|
true);
|
||||||
|
} else {
|
||||||
|
list = feedEntryStatusDAO.findBySubscription(subscription,
|
||||||
|
newerThanDate, offset, limit + 1, order, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (FeedEntryStatus status : list) {
|
||||||
entries.getEntries().add(
|
entries.getEntries().add(
|
||||||
Entry.build(status, applicationSettingsService.get()
|
Entry.build(status, applicationSettingsService.get()
|
||||||
.getPublicUrl()));
|
.getPublicUrl()));
|
||||||
@@ -202,16 +209,20 @@ public class FeedREST extends AbstractResourceREST {
|
|||||||
@POST
|
@POST
|
||||||
@ApiOperation(value = "Queue a feed for refresh", notes = "Manually add a feed to the refresh queue")
|
@ApiOperation(value = "Queue a feed for refresh", notes = "Manually add a feed to the refresh queue")
|
||||||
public Response queueForRefresh(@ApiParam(value = "Feed id") IDRequest req) {
|
public Response queueForRefresh(@ApiParam(value = "Feed id") IDRequest req) {
|
||||||
Preconditions.checkNotNull(req);
|
// TODO evaluate if this is needed
|
||||||
Preconditions.checkNotNull(req.getId());
|
|
||||||
|
// Preconditions.checkNotNull(req);
|
||||||
|
// Preconditions.checkNotNull(req.getId());
|
||||||
|
//
|
||||||
|
// FeedSubscription sub = feedSubscriptionDAO.findById(getUser(),
|
||||||
|
// req.getId());
|
||||||
|
// if (sub != null) {
|
||||||
|
// taskGiver.add(sub.getFeed());
|
||||||
|
// return Response.ok(Status.OK).build();
|
||||||
|
// }
|
||||||
|
// return Response.ok(Status.NOT_FOUND).build();
|
||||||
|
|
||||||
FeedSubscription sub = feedSubscriptionDAO.findById(getUser(),
|
return Response.ok("Disabled for now").build();
|
||||||
req.getId());
|
|
||||||
if (sub != null) {
|
|
||||||
taskGiver.add(sub.getFeed());
|
|
||||||
return Response.ok(Status.OK).build();
|
|
||||||
}
|
|
||||||
return Response.ok(Status.NOT_FOUND).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("/mark")
|
@Path("/mark")
|
||||||
|
|||||||
@@ -731,6 +731,7 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer
|
|||||||
});
|
});
|
||||||
EntryService.mark({
|
EntryService.mark({
|
||||||
id : entry.id,
|
id : entry.id,
|
||||||
|
feedId : entry.feedId,
|
||||||
read : read
|
read : read
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -759,6 +760,7 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer
|
|||||||
entry.starred = star;
|
entry.starred = star;
|
||||||
EntryService.star({
|
EntryService.star({
|
||||||
id : entry.id,
|
id : entry.id,
|
||||||
|
feedId : entry.feedId,
|
||||||
starred : star
|
starred : star
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user