Package org.rssowl.core.persist.event

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


    feed.addNews(news4);
    feed.addNews(news5);
    feed.addNews(news6);
    feed.addNews(news7);

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

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

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

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

    event1 = new NewsEvent(news5, news6, true);
    assertEquals(true, CoreUtils.isCategoryChange(new HashSet<NewsEvent>(Arrays.asList(new NewsEvent[] { event1 }))));

    event1 = new NewsEvent(news6, news5, true);
    assertEquals(true, CoreUtils.isCategoryChange(new HashSet<NewsEvent>(Arrays.asList(new NewsEvent[] { event1 }))));

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

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


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

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

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

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

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

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

    NewsEvent event = new NewsEvent(news1, news2, true);
    assertEquals(true, CoreUtils.isLabelChange(new HashSet<NewsEvent>(Arrays.asList(new NewsEvent[] { event }))));

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

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

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

    return modelEvent;
  }

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

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

  }

  public static final void saveUpdatedNews(ObjectContainer db, INews news) {
    INews oldNews = peekPersistedNews(db, news);
    if (oldNews != null) {
      ModelEvent newsEventTemplate = new NewsEvent(oldNews, news, false, true);
      DBHelper.putEventTemplate(newsEventTemplate);
    }

    db.ext().set(news, 2);
  }
View Full Code Here

  }

  public static final void saveAndCascadeNews(ObjectContainer db, INews news, boolean root) {
    INews oldNews = peekPersistedNews(db, news);
    if (oldNews != null || root) {
      ModelEvent event = new NewsEvent(oldNews, news, root);
      putEventTemplate(event);
    }

    saveEntities(db, news.getCategories());
    saveEntity(db, news.getAuthor());
View Full Code Here

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(true, event.getEntity().equals(savedNews));
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    try {
      feed = DynamicDAO.save(feed);
    } finally {
      DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNews.getId(), event.getEntity().getId());
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UPDATED, event.getEntity().getState());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    feed.getNews().get(0).setState(State.UPDATED);
    try {
View Full Code Here

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNewsId, event.getEntity().getId());
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    try {
      savedNews = DynamicDAO.save(savedNews);
    } finally {
      DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNewsId, event.getEntity().getId());
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UPDATED, event.getEntity().getState());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    savedNews.setState(State.UPDATED);
    try {
View Full Code Here

    INewsDAO newsDao = DynamicDAO.getDAO(INewsDAO.class);
    for (int i = 0, c = descriptionUpdatedIds.size(); i < c; ++i) {
      long newsId = descriptionUpdatedIds.get(i);
      INews news = newsDao.load(newsId);
      INews oldNews = DBHelper.peekPersistedNews(fDb, news);
      EventsMap.getInstance().putUpdateEvent(new NewsEvent(oldNews, news, false));
    }
  }
View Full Code Here

    NewsListener newsListener = null;
    try {
      newsListener = new NewsAdapter() {
        @Override
        public void entitiesAdded(Set<NewsEvent> events) {
          NewsEvent event = events.iterator().next();
          NewsAddedCalled[0] = true;
          initialFeed[0] = (Feed) initialNews.getFeedReference().resolve();
          initialAuthor[0] = (Person) initialNews.getAuthor();
          initialSource[0] = (Source) initialNews.getSource();
          initialGuid[0] = (Guid) initialNews.getGuid();
          final News dbNews = (News) event.getEntity();
          initialAuthor[0].setId(dbNews.getAuthor().getId());
          initialAuthor[0].isIdentical(dbNews.getAuthor());
          //FIXME Find a way to verify this without changing the id from the
          //event handler
//          initialNews.setId(dbNews.getId());
//          assertTrue(initialNews.isIdentical(dbNews));
        }

        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          NewsEvent event = events.iterator().next();
          NewsUpdatedCalled[0] = true;
          News dbNews = (News) event.getEntity();
          assertTrue(updatedNews[0].isIdentical(dbNews));
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);
      INews news = DynamicDAO.save(initialNews);
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.