mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
display feeds without category when the root category is selected
This commit is contained in:
@@ -44,6 +44,7 @@ public class StartupBean {
|
||||
|
||||
if (userService.getCount() == 0) {
|
||||
log.info("Populating database with default values");
|
||||
|
||||
User user = new User();
|
||||
byte[] salt = encryptionService.generateSalt();
|
||||
user.setName("admin");
|
||||
@@ -52,13 +53,21 @@ public class StartupBean {
|
||||
salt));
|
||||
userService.save(user);
|
||||
|
||||
User testUser = new User();
|
||||
byte[] saltTest = encryptionService.generateSalt();
|
||||
testUser.setName("test");
|
||||
testUser.setSalt(saltTest);
|
||||
testUser.setPassword(encryptionService.getEncryptedPassword("test",
|
||||
saltTest));
|
||||
userService.save(testUser);
|
||||
|
||||
Feed dilbert = new Feed(
|
||||
"http://feed.dilbert.com/dilbert/daily_strip");
|
||||
feedService.save(dilbert);
|
||||
|
||||
Feed engadget = new Feed("http://www.engadget.com/rss.xml");
|
||||
feedService.save(engadget);
|
||||
|
||||
|
||||
Feed frandroid = new Feed("http://feeds.feedburner.com/frandroid");
|
||||
feedService.save(frandroid);
|
||||
|
||||
@@ -92,7 +101,7 @@ public class StartupBean {
|
||||
sub2.setTitle("Engadget");
|
||||
sub2.setUser(user);
|
||||
feedSubscriptionService.save(sub2);
|
||||
|
||||
|
||||
FeedSubscription sub3 = new FeedSubscription();
|
||||
sub3.setFeed(frandroid);
|
||||
sub3.setTitle("Frandroid");
|
||||
|
||||
@@ -65,6 +65,30 @@ public class FeedEntryService extends GenericDAO<FeedEntry, Long> {
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public List<FeedEntryWithStatus> getEntries(User user, boolean unreadOnly) {
|
||||
return getEntries(user, unreadOnly, -1, -1);
|
||||
}
|
||||
|
||||
public List<FeedEntryWithStatus> getEntries(User user, boolean unreadOnly,
|
||||
int offset, int limit) {
|
||||
String queryName = null;
|
||||
if (unreadOnly) {
|
||||
queryName = "Entry.unread";
|
||||
} else {
|
||||
queryName = "Entry.all";
|
||||
}
|
||||
Query query = em.createNamedQuery(queryName);
|
||||
query.setParameter("userId", user.getId());
|
||||
query.setParameter("user", user);
|
||||
if (offset > -1) {
|
||||
query.setFirstResult(offset);
|
||||
}
|
||||
if (limit > -1) {
|
||||
query.setMaxResults(limit);
|
||||
}
|
||||
return buildList(query.getResultList());
|
||||
}
|
||||
|
||||
public List<FeedEntryWithStatus> getEntries(Feed feed, User user,
|
||||
boolean unreadOnly) {
|
||||
return getEntries(feed, user, unreadOnly, -1, -1);
|
||||
@@ -91,13 +115,13 @@ public class FeedEntryService extends GenericDAO<FeedEntry, Long> {
|
||||
return buildList(query.getResultList());
|
||||
}
|
||||
|
||||
public List<FeedEntryWithStatus> getEntries(List<FeedCategory> categories, User user,
|
||||
boolean unreadOnly) {
|
||||
public List<FeedEntryWithStatus> getEntries(List<FeedCategory> categories,
|
||||
User user, boolean unreadOnly) {
|
||||
return getEntries(categories, user, unreadOnly, -1, -1);
|
||||
}
|
||||
|
||||
public List<FeedEntryWithStatus> getEntries(List<FeedCategory> categories, User user,
|
||||
boolean unreadOnly, int offset, int limit) {
|
||||
public List<FeedEntryWithStatus> getEntries(List<FeedCategory> categories,
|
||||
User user, boolean unreadOnly, int offset, int limit) {
|
||||
String queryName = null;
|
||||
if (unreadOnly) {
|
||||
queryName = "Entry.unreadByCategories";
|
||||
@@ -116,11 +140,11 @@ public class FeedEntryService extends GenericDAO<FeedEntry, Long> {
|
||||
}
|
||||
return buildList(query.getResultList());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List<FeedEntryWithStatus> buildList(List list){
|
||||
private List<FeedEntryWithStatus> buildList(List list) {
|
||||
List<FeedEntryWithStatus> result = Lists.newArrayList();
|
||||
for (Object object :list) {
|
||||
for (Object object : list) {
|
||||
Object[] array = (Object[]) object;
|
||||
FeedEntry entry = (FeedEntry) array[0];
|
||||
FeedEntryStatus status = (FeedEntryStatus) array[1];
|
||||
|
||||
Reference in New Issue
Block a user