Package org.rssowl.core.persist.event

Examples of org.rssowl.core.persist.event.NewsEvent


   * in the Author of the News, <code>FALSE</code> otherwise.
   */
  public static boolean isAuthorChange(Set< ? extends ModelEvent> events) {
    for (ModelEvent modelEvent : events) {
      if (modelEvent instanceof NewsEvent) {
        NewsEvent event = (NewsEvent) modelEvent;

        IPerson oldAuthor = event.getOldNews() != null ? event.getOldNews().getAuthor() : null;
        IPerson newAuthor = event.getEntity().getAuthor();

        if (newAuthor != null && !newAuthor.equals(oldAuthor))
          return true;
        else if (oldAuthor != null && !oldAuthor.equals(newAuthor))
          return true;
View Full Code Here


   * in the Category of the News, <code>FALSE</code> otherwise.
   */
  public static boolean isCategoryChange(Set< ? extends ModelEvent> events) {
    for (ModelEvent modelEvent : events) {
      if (modelEvent instanceof NewsEvent) {
        NewsEvent event = (NewsEvent) modelEvent;

        List<ICategory> oldCategories = event.getOldNews() != null ? event.getOldNews().getCategories() : null;
        List<ICategory> newCategories = event.getEntity().getCategories();

        if (!newCategories.equals(oldCategories))
          return true;
      }
    }
View Full Code Here

   * in the Label of the News, <code>FALSE</code> otherwise.
   */
  public static boolean isLabelChange(Set< ? extends ModelEvent> events) {
    for (ModelEvent modelEvent : events) {
      if (modelEvent instanceof NewsEvent) {
        NewsEvent event = (NewsEvent) modelEvent;

        ILabel oldLabel = event.getOldNews() != null ? event.getOldNews().getLabel() : null;
        ILabel newLabel = event.getEntity().getLabel();

        if (newLabel != null && !newLabel.equals(oldLabel))
          return true;
        else if (oldLabel != null && !oldLabel.equals(newLabel))
          return true;
View Full Code Here

    return modelEvent;
  }

  private ModelEvent createNewsEvent(INews news, ModelEvent template, boolean root) {
    ModelEvent modelEvent;
    NewsEvent newsTemplate = (NewsEvent) template;
    INews oldNews = newsTemplate == null ? null : newsTemplate.getOldNews();

    modelEvent = new NewsEvent(oldNews, news, root);
    return modelEvent;
  }
View Full Code Here

    //TODO Not sure about this, but let's do it for now to help us track a bug
    //in NewsService where never having a newsUpdated with a null oldNews is
    //helpful
    INews news = entity.getNews();
    INews oldNews = fDb.ext().peekPersisted(news, 2, true);
    NewsEvent newsEvent = new NewsEvent(oldNews, news, false);
    DBHelper.putEventTemplate(newsEvent);
    super.doDelete(entity);
  }
View Full Code Here

    unreadNews2.setState(INews.State.UNREAD);

    INews hiddenNews2 = fFactory.createNews(7L, feed, new Date());
    hiddenNews2.setState(INews.State.HIDDEN);

    NewsEvent event1 = new NewsEvent(newNews, newNews, true);
    NewsEvent event2 = new NewsEvent(newNews, unreadNews, true);
    NewsEvent event3 = new NewsEvent(newNews, readNews, true);
    NewsEvent event4 = new NewsEvent(unreadNews, readNews2, true);
    NewsEvent event5 = new NewsEvent(unreadNews, unreadNews2, true);
    NewsEvent event6 = new NewsEvent(hiddenNews, hiddenNews, true);
    NewsEvent event7 = new NewsEvent(newNews, hiddenNews2, true);
    NewsEvent event8 = new NewsEvent(newNews, deletedNews, true);

    events.add(event1);
    assertEquals(false, CoreUtils.isNewStateChange(events));
    events.add(event4);
    assertEquals(false, CoreUtils.isNewStateChange(events));
View Full Code Here

    unreadNews2.setState(INews.State.UNREAD);

    INews hiddenNews2 = fFactory.createNews(7L, feed, new Date());
    hiddenNews2.setState(INews.State.HIDDEN);

    NewsEvent event1 = new NewsEvent(newNews, newNews, true);
    NewsEvent event2 = new NewsEvent(deletedNews, unreadNews, true);
    NewsEvent event3 = new NewsEvent(hiddenNews, updatedNews, true);
    NewsEvent event4 = new NewsEvent(unreadNews, readNews, true);
    NewsEvent event5 = new NewsEvent(unreadNews, unreadNews2, true);
    NewsEvent event6 = new NewsEvent(hiddenNews, hiddenNews, true);
    NewsEvent event7 = new NewsEvent(newNews, hiddenNews2, true);
    NewsEvent event8 = new NewsEvent(newNews, deletedNews, true);

    events.add(event1);
    assertEquals(false, CoreUtils.isReadStateChange(events));
    events.add(event4);
    assertEquals(true, CoreUtils.isReadStateChange(events));
View Full Code Here

      unreadNews2.setState(INews.State.UNREAD);

      INews hiddenNews2 = fFactory.createNews(7L, feed, new Date());
      hiddenNews2.setState(INews.State.HIDDEN);

      NewsEvent event1 = new NewsEvent(newNews, newNews, true);
      NewsEvent event2 = new NewsEvent(newNews, unreadNews, true);
      NewsEvent event3 = new NewsEvent(newNews, readNews, true);
      NewsEvent event4 = new NewsEvent(unreadNews, readNews2, true);
      NewsEvent event5 = new NewsEvent(unreadNews, unreadNews2, true);
      NewsEvent event6 = new NewsEvent(hiddenNews, hiddenNews, true);
      NewsEvent event7 = new NewsEvent(newNews, hiddenNews2, true);
      NewsEvent event8 = new NewsEvent(newNews, deletedNews, true);

      events.add(event1);
      assertEquals(false, CoreUtils.isNewOrReadStateChange(events));
      events.add(event4);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));
      events.add(event5);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));
      events.add(event6);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));
      events.add(event2);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));
      events.add(event3);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));

      events.clear();
      events.add(event7);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));

      events.clear();
      events.add(event8);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));
    }

    {
      IFeed feed = fFactory.createFeed(Long.valueOf(0L), new URI("http://www.rssowl.org"));

      Set<ModelEvent> events = new HashSet<ModelEvent>();

      INews newNews = fFactory.createNews(0L, feed, new Date());
      newNews.setState(INews.State.NEW);

      INews unreadNews = fFactory.createNews(1L, feed, new Date());
      unreadNews.setState(INews.State.UNREAD);

      INews readNews = fFactory.createNews(2L, feed, new Date());
      readNews.setState(INews.State.READ);

      INews hiddenNews = fFactory.createNews(3L, feed, new Date());
      hiddenNews.setState(INews.State.HIDDEN);

      INews deletedNews = fFactory.createNews(4L, feed, new Date());
      deletedNews.setState(INews.State.DELETED);

      INews updatedNews = fFactory.createNews(5L, feed, new Date());
      updatedNews.setState(INews.State.UPDATED);

      INews unreadNews2 = fFactory.createNews(6L, feed, new Date());
      unreadNews2.setState(INews.State.UNREAD);

      INews hiddenNews2 = fFactory.createNews(7L, feed, new Date());
      hiddenNews2.setState(INews.State.HIDDEN);

      NewsEvent event1 = new NewsEvent(newNews, newNews, true);
      NewsEvent event2 = new NewsEvent(deletedNews, unreadNews, true);
      NewsEvent event3 = new NewsEvent(hiddenNews, updatedNews, true);
      NewsEvent event4 = new NewsEvent(unreadNews, readNews, true);
      NewsEvent event5 = new NewsEvent(unreadNews, unreadNews2, true);
      NewsEvent event6 = new NewsEvent(hiddenNews, hiddenNews, true);
      NewsEvent event7 = new NewsEvent(newNews, hiddenNews2, true);
      NewsEvent event8 = new NewsEvent(newNews, deletedNews, true);

      events.add(event1);
      assertEquals(false, CoreUtils.isNewOrReadStateChange(events));
      events.add(event4);
      assertEquals(true, CoreUtils.isNewOrReadStateChange(events));
View Full Code Here

    feed.addNews(news1);
    feed.addNews(news2);
    feed.addNews(news3);

    NewsEvent event1 = new NewsEvent(news1, news2, true);
    assertEquals(false, CoreUtils.isDateChange(new HashSet<ModelEvent>(Arrays.asList(new ModelEvent[] { event1 }))));

    event1 = new NewsEvent(news1, news3, true);
    assertEquals(true, CoreUtils.isDateChange(new HashSet<ModelEvent>(Arrays.asList(new ModelEvent[] { event1 }))));
  }
View Full Code Here

    feed.addNews(news1);
    feed.addNews(news2);
    feed.addNews(news3);
    feed.addNews(news4);

    NewsEvent event1 = new NewsEvent(news1, news2, true);
    assertEquals(false, CoreUtils.isAuthorChange(new HashSet<ModelEvent>(Arrays.asList(new ModelEvent[] { event1 }))));

    event1 = new NewsEvent(news1, news3, true);
    assertEquals(true, CoreUtils.isAuthorChange(new HashSet<ModelEvent>(Arrays.asList(new ModelEvent[] { event1 }))));

    event1 = new NewsEvent(news1, news4, true);
    assertEquals(true, CoreUtils.isAuthorChange(new HashSet<ModelEvent>(Arrays.asList(new ModelEvent[] { event1 }))));

    event1 = new NewsEvent(news4, news1, true);
    assertEquals(true, CoreUtils.isAuthorChange(new HashSet<ModelEvent>(Arrays.asList(new ModelEvent[] { event1 }))));
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.event.NewsEvent

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.