Package org.rssowl.core.model.events

Examples of org.rssowl.core.model.events.NewsEvent


    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(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());
      }
    };
    fModel.addNewsListener(newsListener);
    try {
      feed = fDao.saveFeed(feed);
    } finally {
      fModel.removeNewsListener(newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(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());
      }
    };
    fModel.addNewsListener(newsListener);
    feed.getNews().get(0).setState(State.UPDATED);
    try {
View Full Code Here


    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(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());
      }
    };
    fModel.addNewsListener(newsListener);
    try {
      savedNews = fDao.saveNews(savedNews);
    } finally {
      fModel.removeNewsListener(newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(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());
      }
    };
    fModel.addNewsListener(newsListener);
    savedNews.setState(State.UPDATED);
    try {
View Full Code Here

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(true, event.getEntity().equalsId(savedNews));
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
      }
    };
    fModel.addNewsListener(newsListener);
    try {
      newsList = fAppLayer.saveNews(newsList);
    } finally {
      fModel.removeNewsListener(newsListener);
    }
    newsListener = new NewsAdapter() {
      @Override
      public void newsUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(savedNews.getId().longValue(), event.getEntity().getId());
        assertEquals(State.UNREAD, event.getOldNews().getState());
        assertEquals(State.UPDATED, event.getEntity().getState());
      }
    };
    fModel.addNewsListener(newsListener);
    newsList.get(0).setState(State.UPDATED);
    try {
View Full Code Here

    NewsListener newsListener = null;
    try {
      newsListener = new NewsAdapter() {
        @Override
        public void newsAdded(Set<NewsEvent> events) {
          NewsEvent event = events.iterator().next();
          try {
            NewsAddedCalled[0] = true;
            initialFeed[0] = (Feed) initialNews.getFeedReference().resolve();
            initialAuthor[0] = (Person) initialNews.getAuthor();
            initialSource[0] = (Source) initialNews.getSource();
            initialGuid[0] = (Guid) initialNews.getGuid();
            News dbNews = (News) event.getEntity();
            initialAuthor[0].setId(dbNews.getAuthor().getId());
            initialAuthor[0].isIdentical(dbNews.getAuthor());
            initialNews.setId(dbNews.getId());
            assertTrue(initialNews.isIdentical(dbNews));
            dbNews.setDescription("The description has been changed in the news");
            dbNews.setState(State.UNREAD);
            updatedNews[0] = dbNews;
            fModelDAO.saveNews(dbNews);
          } catch (PersistenceException e) {
            fail(e.getMessage());
          }
        }

        @Override
        public void newsUpdated(Set<NewsEvent> events) {
          NewsEvent event = events.iterator().next();
          NewsUpdatedCalled[0] = true;
          News dbNews = (News) event.getEntity();
          assertTrue(updatedNews[0].isIdentical(dbNews));
        }
      };
      NewsModel.getDefault().addNewsListener(newsListener);
      fModelDAO.saveNews(initialNews);
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, ModelUtils.isNewStateChange(events));
    events.add(event4);
    assertEquals(false, ModelUtils.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, ModelUtils.isReadStateChange(events));
    events.add(event4);
    assertEquals(true, ModelUtils.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, ModelUtils.isNewOrReadStateChange(events));
      events.add(event4);
      assertEquals(true, ModelUtils.isNewOrReadStateChange(events));
      events.add(event5);
      assertEquals(true, ModelUtils.isNewOrReadStateChange(events));
      events.add(event6);
      assertEquals(true, ModelUtils.isNewOrReadStateChange(events));
      events.add(event2);
      assertEquals(true, ModelUtils.isNewOrReadStateChange(events));
      events.add(event3);
      assertEquals(true, ModelUtils.isNewOrReadStateChange(events));

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

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

    {
      IFeed feed = fFactory.createFeed(Long.valueOf(0L), new URL("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, ModelUtils.isNewOrReadStateChange(events));
      events.add(event4);
      assertEquals(true, ModelUtils.isNewOrReadStateChange(events));
View Full Code Here

      List<INews> changedNews = new ArrayList<INews>(newsList.size());

      for (INews news : newsList) {
        INews oldNews = fDb.ext().peekPersisted(news, 2, true);
        if (oldNews == null || !checkIfNewsIsIdentical || !news.isIdentical(oldNews)) {
          ModelEvent eventTemplate = new NewsEvent(oldNews, news, true);
          DBHelper.putEventTemplate(eventTemplate);
          changedNews.add(news);
        }
      }
View Full Code Here

  public IFeed saveFeed(IFeed feed, List<INews> newsToRemove) {
    fWriteLock.lock();
    try {
      DBHelper.saveFeed(fDb, feed);
      for (INews newsItem : newsToRemove) {
        ModelEvent eventTemplate = new NewsEvent(null, newsItem, true);
        DBHelper.putEventTemplate(eventTemplate);
        fDb.delete(newsItem);
      }
      fDb.commit();
    } catch (Db4oException e) {
View Full Code Here

      INews oldNews = db.ext().peekPersisted(news, 2, true);
      if (oldNews == null) {
        changedNews.add(news);
      }
      else if (!news.isIdentical(oldNews)) {
        ModelEvent newsEventTemplate = new NewsEvent(oldNews, news, false);
        DBHelper.putEventTemplate(newsEventTemplate);
        changedNews.add(news);
      }
    }
    for (INews news : changedNews) {
View Full Code Here

TOP

Related Classes of org.rssowl.core.model.events.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.