2013-04-18 12:50:44 +02:00
|
|
|
package com.commafeed.backend.services;
|
|
|
|
|
|
|
|
|
|
import javax.ejb.Stateless;
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
2013-07-19 12:02:20 +02:00
|
|
|
import com.commafeed.backend.dao.FeedEntryDAO;
|
2013-04-18 12:50:44 +02:00
|
|
|
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
2013-06-20 18:45:58 +02:00
|
|
|
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
|
|
|
|
import com.commafeed.backend.model.FeedEntry;
|
2013-04-18 12:50:44 +02:00
|
|
|
import com.commafeed.backend.model.FeedEntryStatus;
|
2013-06-20 18:45:58 +02:00
|
|
|
import com.commafeed.backend.model.FeedSubscription;
|
2013-04-18 12:50:44 +02:00
|
|
|
import com.commafeed.backend.model.User;
|
|
|
|
|
|
|
|
|
|
@Stateless
|
|
|
|
|
public class FeedEntryService {
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
FeedEntryStatusDAO feedEntryStatusDAO;
|
|
|
|
|
|
2013-06-20 18:45:58 +02:00
|
|
|
@Inject
|
|
|
|
|
FeedSubscriptionDAO feedSubscriptionDAO;
|
2013-07-22 16:31:29 +02:00
|
|
|
|
|
|
|
|
@Inject
|
2013-07-19 12:02:20 +02:00
|
|
|
FeedEntryDAO feedEntryDAO;
|
2013-06-20 18:45:58 +02:00
|
|
|
|
|
|
|
|
public void markEntry(User user, Long entryId, Long subscriptionId,
|
|
|
|
|
boolean read) {
|
|
|
|
|
FeedSubscription sub = feedSubscriptionDAO.findById(user,
|
|
|
|
|
subscriptionId);
|
|
|
|
|
if (sub == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-19 12:02:20 +02:00
|
|
|
FeedEntry entry = feedEntryDAO.findById(entryId);
|
|
|
|
|
if (entry == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-06-20 18:45:58 +02:00
|
|
|
|
2013-07-19 11:17:19 +02:00
|
|
|
FeedEntryStatus status = feedEntryStatusDAO.getStatus(sub, entry);
|
2013-07-24 12:13:06 +02:00
|
|
|
if (status.isMarkable()) {
|
|
|
|
|
status.setRead(read);
|
|
|
|
|
feedEntryStatusDAO.saveOrUpdate(status);
|
|
|
|
|
}
|
2013-04-18 12:50:44 +02:00
|
|
|
}
|
2013-04-29 22:37:26 +02:00
|
|
|
|
2013-06-20 18:45:58 +02:00
|
|
|
public void starEntry(User user, Long entryId, Long subscriptionId,
|
|
|
|
|
boolean starred) {
|
|
|
|
|
|
|
|
|
|
FeedSubscription sub = feedSubscriptionDAO.findById(user,
|
|
|
|
|
subscriptionId);
|
|
|
|
|
if (sub == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-19 12:02:20 +02:00
|
|
|
FeedEntry entry = feedEntryDAO.findById(entryId);
|
|
|
|
|
if (entry == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-06-20 18:45:58 +02:00
|
|
|
|
2013-07-19 11:17:19 +02:00
|
|
|
FeedEntryStatus status = feedEntryStatusDAO.getStatus(sub, entry);
|
2013-07-24 15:39:20 +02:00
|
|
|
status.setStarred(starred);
|
|
|
|
|
feedEntryStatusDAO.saveOrUpdate(status);
|
2013-04-29 22:37:26 +02:00
|
|
|
}
|
2013-04-18 12:50:44 +02:00
|
|
|
}
|