Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.NewsCounterItem


        /* No Change - continue */
        if (oldStateUnread == currentStateUnread && oldStateNew == currentStateNew && oldStateSticky == newStateSticky)
          continue;

        NewsCounterItem counterItem = fNewsCounter.get(currentNews.getFeedLinkAsText());

        /* News became read */
        if (oldStateUnread && !currentStateUnread)
          counterItem.decrementUnreadCounter();

        /* News became unread */
        else if (!oldStateUnread && currentStateUnread)
          counterItem.incrementUnreadCounter();

        /* News no longer New */
        if (oldStateNew && !currentStateNew)
          counterItem.decrementNewCounter();

        /* News became New */
        else if (!oldStateNew && currentStateNew)
          counterItem.incrementNewCounter();

        /* News became unsticky */
        if (oldStateSticky && !newStateSticky)
          counterItem.decrementStickyCounter();

        /* News became sticky */
        else if (!oldStateSticky && newStateSticky)
          counterItem.incrementStickyCounter();

        updatedCounterItems.put(currentNews.getFeedLinkAsText(), counterItem);
      }
      for (NewsCounterItem counterItem : updatedCounterItems.values())
        fDb.store(counterItem);
View Full Code Here


        INews news = newsEvent.getEntity();

        if (news.getParentId() != 0)
          continue;

        NewsCounterItem counterItem = fNewsCounter.get(news.getFeedLinkAsText());

        /* Update Counter */
        if (news.getState() == INews.State.NEW)
          counterItem.decrementNewCounter();
        if (isUnread(news.getState()))
          counterItem.decrementUnreadCounter();
        if (news.isFlagged() && (!EnumSet.of(INews.State.DELETED, INews.State.HIDDEN).contains(news.getState())))
          counterItem.decrementStickyCounter();

        updatedCounterItems.put(news.getFeedLinkAsText(), counterItem);
      }
      for (NewsCounterItem counterItem : updatedCounterItems.values())
        fDb.store(counterItem);
View Full Code Here

  private static void addNewsCounterItem(NewsCounter newsCounter, Feed feed) {
    Map<State, Integer> stateToCountMap = feed.getNewsCount();
    int unreadCount = getCount(stateToCountMap, EnumSet.of(State.NEW, State.UNREAD, State.UPDATED));
    Integer newCount = stateToCountMap.get(INews.State.NEW);
    newsCounter.put(feed.getLink().toString(), new NewsCounterItem(newCount, unreadCount, feed.getStickyCount()));
  }
View Full Code Here

          continue;

        if (news.getState() == INews.State.DELETED) //Could be DELETED from filters
          continue;

        NewsCounterItem newsCounterItem = fNewsCounter.get(news.getFeedLinkAsText());

        /* Create Counter if not yet done */
        if (newsCounterItem == null) {
          newsCounterItem = new NewsCounterItem();
          fNewsCounter.put(news.getFeedLinkAsText(), newsCounterItem);
          newsCounterUpdated = true;
        }

        /* Update Counter */
        if (news.getState() == INews.State.NEW)
          newsCounterItem.incrementNewCounter();
        if (isUnread(news.getState()))
          newsCounterItem.incrementUnreadCounter();
        if (news.isFlagged())
          newsCounterItem.incrementStickyCounter();

        if (!newsCounterUpdated)
          updatedCounterItems.put(news.getFeedLinkAsText(), newsCounterItem);
      }

View Full Code Here

        /* No Change - continue */
        if (oldStateUnread == currentStateUnread && oldStateNew == currentStateNew && oldStateSticky == newStateSticky)
          continue;

        NewsCounterItem counterItem = fNewsCounter.get(currentNews.getFeedLinkAsText());

        /* News became read */
        if (oldStateUnread && !currentStateUnread)
          counterItem.decrementUnreadCounter();

        /* News became unread */
        else if (!oldStateUnread && currentStateUnread)
          counterItem.incrementUnreadCounter();

        /* News no longer New */
        if (oldStateNew && !currentStateNew)
          counterItem.decrementNewCounter();

        /* News became New */
        else if (!oldStateNew && currentStateNew)
          counterItem.incrementNewCounter();

        /* News became unsticky */
        if (oldStateSticky && !newStateSticky)
          counterItem.decrementStickyCounter();

        /* News became sticky */
        else if (!oldStateSticky && newStateSticky)
          counterItem.incrementStickyCounter();

        updatedCounterItems.put(currentNews.getFeedLinkAsText(), counterItem);
      }

      for (NewsCounterItem counterItem : updatedCounterItems.values())
View Full Code Here

        INews news = newsEvent.getEntity();

        if (news.getParentId() != 0) //News is stored inside a Bin
          continue;

        NewsCounterItem counterItem = fNewsCounter.get(news.getFeedLinkAsText());

        /* Update Counter */
        if (news.getState() == INews.State.NEW)
          counterItem.decrementNewCounter();
        if (isUnread(news.getState()))
          counterItem.decrementUnreadCounter();
        if (news.isFlagged() && (!EnumSet.of(INews.State.DELETED, INews.State.HIDDEN).contains(news.getState())))
          counterItem.decrementStickyCounter();

        updatedCounterItems.put(news.getFeedLinkAsText(), counterItem);
      }

      for (NewsCounterItem counterItem : updatedCounterItems.values())
View Full Code Here

    return newsCounter;
  }

  private NewsCounterItem doCount(IFeed feed) {
    NewsCounterItem counterItem = new NewsCounterItem();

    List<INews> newsList = feed.getVisibleNews();
    for (INews news : newsList) {
      if (EnumSet.of(INews.State.NEW, INews.State.UNREAD, INews.State.UPDATED).contains(news.getState()))
        counterItem.incrementUnreadCounter();

      if (INews.State.NEW.equals(news.getState()))
        counterItem.incrementNewCounter();

      if (news.isFlagged())
        counterItem.incrementStickyCounter();
    }

    return counterItem;
  }
View Full Code Here

    INewsBin bin = fFactory.createNewsBin(null, root, "Bin");
    input.add(bin);

    NewsCounter count = new NewsCounter();
    NewsCounterItem item = new NewsCounterItem(1, 0, 0);
    count.put(feed1.getLink().toString(), item);
    ((BookMark) bookmark1).setNewsCounter(count);

    count = new NewsCounter();
    item = new NewsCounterItem(0, 1, 0);
    count.put(feed2.getLink().toString(), item);
    ((BookMark) bookmark2).setNewsCounter(count);

    count = new NewsCounter();
    item = new NewsCounterItem(0, 0, 1);
    count.put(feed3.getLink().toString(), item);
    ((BookMark) bookmark3).setNewsCounter(count);

    INews news = fFactory.createNews(null, fFactory.createFeed(null, new URI("feed4")), new Date());
    news.setState(INews.State.NEW);
View Full Code Here

    DynamicDAO.save(anotherFeed);

    bm = fFactory.createBookMark(null, folder, new FeedLinkReference(URI.create("http://www.rssowl.org")), "Other BookMark");
    NewsCounter counter = DynamicDAO.getDAO(INewsCounterDAO.class).load();
    NewsCounterItem item = new NewsCounterItem(1, 2, 3);
    counter.put(bm.getFeedLinkReference().getLinkAsText(), item);
    DynamicDAO.save(counter);
    ((BookMark) bm).setNewsCounter(counter);

    ISearchMark sm = fFactory.createSearchMark(null, folder, "SM");
View Full Code Here

      NewsCounter otherNewsCounter = defragmentedDb.query(NewsCounter.class).get(0);
      defragmentedDb.activate(otherNewsCounter, Integer.MAX_VALUE);
      assertNotNull(newsCounter);
      assertNotNull(otherNewsCounter);

      NewsCounterItem item = otherNewsCounter.get("http://www.rssowl.org");
      assertEquals(1, item.getNewCounter());
      assertEquals(2, item.getUnreadCounter());
      assertEquals(3, item.getStickyCounter());
    } finally {
      db.close();
      defragmentedDb.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.NewsCounterItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.