Package org.rssowl.core.persist.reference

Examples of org.rssowl.core.persist.reference.FeedReference


   * @throws Exception
   */
  @Test
  public void testLoadBookMarksActivation() throws Exception {
    IFeed feed = fFactory.createFeed(null, new URI("http://www.myfeed.com"));
    FeedReference feedRef = new FeedReference(DynamicDAO.save(feed).getId());
    long feedId = feedRef.getId();
    IFolder root1 = fFactory.createFolder(null, null, "Root 1");
    final String folderName = root1.getName();
    fFactory.createBookMark(null, root1, new FeedLinkReference(feed.getLink()), "Bookmark 1");
    feedRef = null;
    feed = null;
View Full Code Here


          /* Create URL */
          URI newFeedLink = new URI(uriAsString.trim());
          fReloadRequired = true;

          /* Try to load this Feed from the DB (might be existing already) */
          FeedReference feedRef = daoService.getFeedDAO().loadReference(newFeedLink);

          /* This is a new Feed, so create it! */
          if (feedRef == null) {
            IFeed feed = Owl.getModelFactory().createFeed(null, newFeedLink);
            feed = DynamicDAO.save(feed);
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      final int removedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          removedCounter[0] += events.size();
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, fDateFormat.format(System.currentTimeMillis()));
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());

      /* Delete News (set to Hidden) */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.HIDDEN, true, false);
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      /* Reload unchanged Feed */
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      /* Second Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link_other.de", null, fDateFormat.format(System.currentTimeMillis()));
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.link.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.HIDDEN, newsItem.getState());
        else if ("http://www.link_other.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Really Delete News */
      news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.link.de".equals(newsItem.getLink().toString()))
          fNewsDao.setState(new ArrayList<INews>(Arrays.asList(newsItem)), INews.State.DELETED, true, false);
      }

      news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.link.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.DELETED, newsItem.getState());
        else if ("http://www.link_other.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Reload unchanged Feed */
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());

      /* Test Event Counter */
      assertEquals(2, addedCounter[0]);
      assertEquals(2, updatedCounter[0]);
      assertEquals(1, removedCounter[0]);
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World", "bpasero", null, "mp3");
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());
      assertEquals("Hello World", feedRef.resolve().getNews().get(0).getDescription());
      assertEquals("bpasero", feedRef.resolve().getNews().get(0).getAuthor().getName());

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);
      assertEquals(1, updatedCounter[0]);

      /* Second Reload - changed Description */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World Changed", "bpasero", null, "mp3");
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());
      assertEquals("Hello World Changed", feedRef.resolve().getNews().get(0).getDescription());
      assertEquals(2, updatedCounter[0]);

      /* Set to Unread and Reload */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());

      /* This Reload - added Enclosure */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World Changed", "bpasero", "http://www.download.de", "mp3");
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feed.getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());
      assertEquals(1, feedRef.resolve().getNews().get(0).getAttachments().size());
      assertEquals("http://www.download.de", feedRef.resolve().getNews().get(0).getAttachments().get(0).getLink().toString());
      assertEquals(3, updatedCounter[0]);

      /* This Reload - Changed Author */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null, "Hello World Changed", "ijuma", "http://www.download.de", "mp3");
      oldNewsListener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());
          int attachmentsSize = events.iterator().next().getOldNews().getAttachments().size();
          assertEquals(1, attachmentsSize);
        }
      };
      DynamicDAO.addEntityListener(INews.class, oldNewsListener);
      fController.reload(bookmark, null, new NullProgressMonitor());
      DynamicDAO.removeEntityListener(INews.class, oldNewsListener);
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());
      assertEquals("ijuma", feedRef.resolve().getNews().get(0).getAuthor().getName());
      assertEquals(3, updatedCounter[0]);

      /* Test Event Counter */
      assertEquals(1, addedCounter[0]);
      assertEquals(3, updatedCounter[0]);
View Full Code Here

    /* Save some Feeds first */
    final List<FeedReference> feedRefs = new ArrayList<FeedReference>();
    final List<IFeed> feeds = interpretFeedsHelper();
    final int limit = feeds.size() / 2;
    for (int i = 0; i < limit; i++)
      feedRefs.add(new FeedReference(DynamicDAO.save(feeds.get(i)).getId()));

    /* Tasks to resolve Feeds */
    for (int i = 0; i < limit; i++) {
      final int a = i;

View Full Code Here

  private List<FeedReference> saveFeedsHelper() throws PersistenceException {
    List<IFeed> feeds = interpretFeedsHelper();
    List<FeedReference> feedRefs = new ArrayList<FeedReference>();
    for (IFeed feed : feeds)
      feedRefs.add(new FeedReference(DynamicDAO.save(feed).getId()));

    return feedRefs;
  }
View Full Code Here

    IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    FeedReference feedRef = new FeedReference(feed.getId());

    IBookMark bookmark = createBookMark(feed);
    IPreferenceScope preferences = Owl.getPreferenceService().getEntityScope(bookmark);
    preferences.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 0);
    preferences.putBoolean(DefaultPreferences.DEL_NEWS_BY_COUNT_STATE, true);

    /* First Reload */
    InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null);
    fController.reload(bookmark, null, new NullProgressMonitor());
    assertEquals(1, feedRef.resolve().getNews().size());
    assertEquals(1, getUnreadCount(feed));
    assertEquals(1, getNewCount(feed));

    /* Set to UNREAD */
    fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);
    assertEquals(0, getNewCount(feed));

    /* Second Reload */
    fController.reload(bookmark, null, new NullProgressMonitor());
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));

    /* Third Reload */
    InMemoryProtocolHandler.FEED = generateEmptyFeed();
    fController.reload(bookmark, null, new NullProgressMonitor());
    assertEquals(0, feedRef.resolve().getNews().size());
  }
View Full Code Here

    /* Duplicate News with: Title */
    {
      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      InMemoryProtocolHandler.FEED = generateFeedWithDuplicateNews("News Title", null, null, null, "Description", null, null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      DynamicDAO.delete(feedRef.resolve());
    }

    /* Duplicate News with: Title, Link */
    {
      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      InMemoryProtocolHandler.FEED = generateFeedWithDuplicateNews("News Title", "http://www.link.com", null, null, "Description", null, null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      DynamicDAO.delete(feedRef.resolve());
    }

    /* Duplicate News with: Title, Guid */
    {
      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      InMemoryProtocolHandler.FEED = generateFeedWithDuplicateNews("News Title", null, "http://www.link.com", null, "Description", null, null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      DynamicDAO.delete(feedRef.resolve());
    }

    /* Duplicate News with: Title, Link, Guid */
    {
      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      InMemoryProtocolHandler.FEED = generateFeedWithDuplicateNews("News Title", "http://www.link.com", "http://www.guid.com", null, "Description", null, null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      DynamicDAO.delete(feedRef.resolve());
    }
  }
View Full Code Here

      fPage.focusInput(true);
      return false;
    }

    /* Check if a Feed with the URL already exists */
    FeedReference feedRef = DynamicDAO.getDAO(IFeedDAO.class).loadReference(uriObj);

    /* Create a new Feed then */
    if (feedRef == null) {
      IFeed feed = factory.createFeed(null, uriObj);
      feed = DynamicDAO.getDAO(IFeedDAO.class).save(feed);
View Full Code Here

      final URI news2Link = new URI("http://www.news2.com/index.html");
      final URI news3Link = new URI("http://www.news3.com/index.html");
      news1.setLink(news1Link);
      news2.setLink(news2Link);
      news3.setLink(news3Link);
      FeedReference feedRef = new FeedReference(DynamicDAO.save(feed).getId());

      assertEquals(3, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().size());

      /* Mark 2 News as Deleted and save News */
      news1 = DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(0);
      news1.setState(INews.State.DELETED);
      news2 = DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(1);
      news2.setState(INews.State.DELETED);
      news3 = DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(2);
      news3.setState(INews.State.READ);

      final boolean newsUpdatedEvents[] = new boolean[2];

      newsListener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            INews news = event.getEntity();
            if (news.getLink().equals(news1Link))
              newsUpdatedEvents[0] = true;
            else if (news.getLink().equals(news2Link))
              newsUpdatedEvents[1] = true;
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, newsListener);

      NewsReference newsReference1 = new NewsReference(DynamicDAO.save(news1).getId());
      NewsReference newsReference2 = new NewsReference(DynamicDAO.save(news2).getId());
      NewsReference newsReference3 = new NewsReference(DynamicDAO.save(news3).getId());

      assertEquals(INews.State.DELETED, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(0).getState());
      assertEquals(INews.State.DELETED, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(1).getState());
      assertEquals(INews.State.READ, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(2).getState());

      /* Check Deleted News now being Deleted from DB */
      IFeed emptyFeed = fFactory.createFeed(null, new URI("http://www.feed.com"));
      IFeed savedFeed = feedRef.resolve();
      MergeResult mergeResult = savedFeed.mergeAndCleanUp(emptyFeed);
      TestUtils.saveFeed(mergeResult);

      feed = null;
      news1 = null;
      news2 = null;
      news3 = null;
      System.gc();

      /* Asserts follow */
      assertEquals(1, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().size());
      assertNull(DynamicDAO.load(INews.class, newsReference1.getId()));
      assertNull(DynamicDAO.load(INews.class, newsReference2.getId()));
      assertNotNull(DynamicDAO.load(INews.class, newsReference3.getId()));

      for (int i = 0; i < newsUpdatedEvents.length; i++)
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.reference.FeedReference

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.