Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.NewsCounterItem


   * @param feedLinkRef The reference to the link of the Feed.
   * @return the number of unread News for the Feed having the given Id.
   */
  public int getUnreadCount(FeedLinkReference feedLinkRef) {
    synchronized (this) {
      NewsCounterItem counter = getFromCounter(feedLinkRef);

      /* Feed has no news */
      if (counter == null)
        return 0;

      return counter.getUnreadCounter();
    }
  }
View Full Code Here


   * @param feedLinkRef The reference to the link of the Feed.
   * @return the number of unread News for the Feed having the given link.
   */
  public int getNewCount(FeedLinkReference feedLinkRef) {
    synchronized (this) {
      NewsCounterItem counter = getFromCounter(feedLinkRef);

      /* Feed has no news */
      if (counter == null)
        return 0;

      return counter.getNewCounter();
    }
  }
View Full Code Here

   * @param feedLinkRef The reference to the link of the Feed.
   * @return the number of sticky News for the Feed having the given Id.
   */
  public int getStickyCount(FeedLinkReference feedLinkRef) {
    synchronized (this) {
      NewsCounterItem counter = getFromCounter(feedLinkRef);

      /* Feed has no news */
      if (counter == null)
        return 0;

      return counter.getStickyCounter();
    }
  }
View Full Code Here

  private NewsCounterItem getFromCounter(FeedLinkReference feedRef) {
    return fCounter.get(feedRef.getLink());
  }

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

    List<INews> newsList = feed.getVisibleNews();
    for (INews news : newsList) {
      if (ModelUtils.isUnread(news.getState()))
        counterItem.incrementUnreadCounter();
      if (INews.State.NEW.equals(news.getState()))
        counterItem.incrementNewCounter();
      if (news.isFlagged())
        counterItem.incrementStickyCounter();
    }

    return counterItem;
  }
View Full Code Here

    for (NewsEvent event : events) {
      INews news = event.getEntity();
      FeedLinkReference feedRef = news.getFeedReference();

      synchronized (this) {
        NewsCounterItem counter = getFromCounter(feedRef);

        /* Create Counter if not yet done */
        if (counter == null) {
          counter = new NewsCounterItem();
          putInCounter(feedRef, counter);
        }

        /* Update Counter */
        if (news.getState() == INews.State.NEW)
          counter.incrementNewCounter();
        if (ModelUtils.isUnread(news.getState()))
          counter.incrementUnreadCounter();
        if (news.isFlagged())
          counter.incrementStickyCounter();
      }
    }
  }
View Full Code Here

  private void onNewsDeleted(Set<NewsEvent> events) {
    for (NewsEvent event : events) {
      INews news = event.getEntity();

      synchronized (this) {
        NewsCounterItem counter = getFromCounter(news.getFeedReference());
        if (counter != null) {

          /* Update Counter */
          if (news.getState() == INews.State.NEW)
            counter.decrementNewCounter();
          if (ModelUtils.isUnread(news.getState()))
            counter.decrementUnreadCounter();
          if (news.isFlagged())
            counter.decrementStickyCounter();
        }
      }
    }
  }
View Full Code Here

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

      synchronized (this) {
        NewsCounterItem counter = getFromCounter(feedRef);

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

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

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

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

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

        /* News became sticky */
        else if (!oldStateSticky && newStateSticky)
          counter.incrementStickyCounter();
      }
    }
  }
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());
  }
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

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.