Package org.rssowl.core.model.reference

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


      IApplicationLayer applicationLayer = NewsModel.getDefault().getPersistenceLayer().getApplicationLayer();
      URL url = createURL(link);
      if (url != null) {

        /* Check if a Feed with the URL already exists */
        FeedReference feedRef = applicationLayer.loadFeedReference(url);

        /* Create a new Feed then */
        if (feedRef == null) {
          IFeed feed = Interpreter.getDefault().getTypesFactory().createFeed(url);
          feed.setHomepage(homepage != null ? createURI(homepage) : null);
          feed.setDescription(description);
          feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);
          feedRef = new FeedReference(feed.getId());
        }

        /* Create the BookMark */
        type = Interpreter.getDefault().getTypesFactory().createBookMark((IFolder) parent, url, feedRef, title != null ? title : link);
      }
View Full Code Here


      feed.setProperty("String", "Foo");
      feed.setProperty("Integer", 1);
      feed.setProperty("Boolean", true);
      feed.setProperty("Double", 2.2D);
      feed.setProperty("Float", 3.3F);
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());
      feed = feedRef.resolve();
      assertEquals("Foo", feed.getProperty("String"));
      assertEquals(1, feed.getProperty("Integer"));
      assertEquals(true, feed.getProperty("Boolean"));
      assertEquals(2.2D, feed.getProperty("Double"));
      assertEquals(3.3F, feed.getProperty("Float"));

      /* Add Properties to a BookMark */
      IBookMark bookMark = fFactory.createBookMark(null, folderRef.resolve(),
          feed.getLink(), feedRef, "BookMark");
      bookMark.setProperty("String", "Foo");
      bookMark.setProperty("Integer", 1);
      bookMark.setProperty("Boolean", true);
      bookMark.setProperty("Double", 2.2D);
      bookMark.setProperty("Float", 3.3F);
      BookMarkReference bookMarkRef = new BookMarkReference(fDao.saveBookMark(bookMark).getId());
      bookMark = bookMarkRef.resolve();
      assertEquals("Foo", bookMark.getProperty("String"));
      assertEquals(1, bookMark.getProperty("Integer"));
      assertEquals(true, bookMark.getProperty("Boolean"));
      assertEquals(2.2D, bookMark.getProperty("Double"));
      assertEquals(3.3F, bookMark.getProperty("Float"));

      /* Add Properties to a News */
      INews news = fFactory.createNews(null, feedRef.resolve(), new Date());
      news.setProperty("String", "Foo");
      news.setProperty("Integer", 1);
      news.setProperty("Boolean", true);
      news.setProperty("Double", 2.2D);
      news.setProperty("Float", 3.3F);
View Full Code Here

        }
      };
      NewsModel.getDefault().addNewsListener(feedListener);

      feed = NewsModel.getDefault().getPersistenceLayer().getModelDAO().saveFeed(feed);
      NewsModel.getDefault().getPersistenceLayer().getModelDAO().deleteFeed(new FeedReference(feed.getId()));

      if (addedEvent[0])
        fail("Unexpected newsAdded Event for Feed with 0 News");
      if (deletedEvent[0])
        fail("Unexpected newsDeleted Event for Feed with 0 News");
View Full Code Here

    fModel.getTypesFactory().createNews(null, feed, new Date());
    fModel.getTypesFactory().createNews(null, feed, new Date());
    fModel.getTypesFactory().createNews(null, feed, new Date());

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

    NewsReference news1 = new NewsReference(feedRef.resolve().getNews().get(0).getId());
    NewsReference news2 = new NewsReference(feedRef.resolve().getNews().get(1).getId());
    NewsReference news3 = new NewsReference(feedRef.resolve().getNews().get(2).getId());

    List<NewsReference> news = new ArrayList<NewsReference>();
    news.add(news1);
    news.add(news2);
View Full Code Here

   */
  @SuppressWarnings("nls")
  @Test
  public void testLoadNewsStates() throws Exception {
    IFeed feed = fModel.getTypesFactory().createFeed(null, new URL("http://www.feed.com"));
    FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

    for (int i = 0; i < 5; i++) {
      INews news = fModel.getTypesFactory().createNews(null, feed, new Date());
      fDao.saveNews(news);
      news.setState(INews.State.NEW);
      fDao.saveNews(news);
    }

    for (int i = 0; i < 4; i++) {
      INews news = fModel.getTypesFactory().createNews(null, feed, new Date());
      fDao.saveNews(news);
      news.setState(INews.State.UPDATED);
      fDao.saveNews(news);
    }

    for (int i = 0; i < 3; i++) {
      INews news = fModel.getTypesFactory().createNews(null, feed, new Date());
      fDao.saveNews(news);
      news.setState(INews.State.UNREAD);
      fDao.saveNews(news);
    }

    for (int i = 0; i < 2; i++) {
      INews news = fModel.getTypesFactory().createNews(null, feed, new Date());
      fDao.saveNews(news);
      news.setState(INews.State.READ);
      fDao.saveNews(news);
    }

    for (int i = 0; i < 1; i++) {
      INews news = fModel.getTypesFactory().createNews(null, feed, new Date());
      fDao.saveNews(news);
      news.setState(INews.State.HIDDEN);
      fDao.saveNews(news);
    }

    int newCount = 0, updatedCount = 0, unreadCount = 0, readCount = 0, hiddenCount = 0;

    List<State> states = new ArrayList<State>();

    feed = feedRef.resolve();
    List<INews> news = feed.getNews();

    for (INews newsitem : news) {
      states.add(newsitem.getState());
    }
View Full Code Here

    /* Merge BookMarks */
    {
      IFolder folder = fDao.saveFolder(fFactory.createFolder(null, null, "Root"));
      IFeed feed = fDao.saveFeed(fFactory.createFeed(null, new URL("http://www.link.de")));
      IBookMark bookmark = fDao.saveBookMark(fFactory.createBookMark(null, folder,
          feed.getLink(), new FeedReference(feed.getId()), "BookMark"));

      /* Create BookMark to merge into existing BookMark */
      IBookMark updatedBookMark1 = fFactory.createBookMark(bookmark.getId(), folder,
          feed.getLink(), new FeedReference(feed.getId()), "BookMark *updated*");

      IBookMark updatedBookMark2 = fFactory.createBookMark(bookmark.getId(), folder,
          feed.getLink(), new FeedReference(feed.getId()), "BookMark *updated*");
      updatedBookMark2.setCreationDate(new Date(System.currentTimeMillis() + 1000));
      updatedBookMark2.setErrorLoading(true);
      updatedBookMark2.setLastVisitDate(new Date(System.currentTimeMillis()));
      updatedBookMark2.setPopularity(100);
      updatedBookMark2.setProperty("Foo", "Bar");

      IFeed feed2 = fDao.saveFeed(fFactory.createFeed(null, new URL("http://www.link2.de")));
      IBookMark updatedBookMark3 = fFactory.createBookMark(bookmark.getId(), folder,
          feed2.getLink(), new FeedReference(feed2.getId()), "BookMark *updated*");

      /* Merge and Test */
      bookmark.merge(updatedBookMark1);
      assertTrue(((BookMark) bookmark).isIdentical(updatedBookMark1));

View Full Code Here

      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, root, feed.getLink(), feedRef, "BookMark");
      root = fDao.saveFolder(root);
      mark = (IBookMark) root.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteFolder(new FolderReference(root.getId()));

      assertNull("Expected this Entity to be NULL", new FolderReference(root.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Root Folder, Folder, BookMark, Feed, News (Folder Deleted) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFolder folder = fFactory.createFolder(null, root, "Folder");
      folder = fDao.saveFolder(folder);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed2.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, folder, feed.getLink(),
          feedRef, "BookMark");
      folder = fDao.saveFolder(folder);
      mark = (IBookMark) folder.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteFolder(new FolderReference(folder.getId()));

      assertNull("Expected this Entity to be NULL", new FolderReference(folder.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Root Folder, Folder, BookMark, Feed, News (Folder Deleted #2) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFolder folder = fFactory.createFolder(null, root, "Folder");
      folder = fDao.saveFolder(folder);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed3.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, folder, feed.getLink(),
          feedRef, "BookMark");
      folder = fDao.saveFolder(folder);
      mark = (IBookMark) folder.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      /* Delete by calling delete */
      fDao.deleteFolder(new FolderReference(folder.getId()));

      final long rootFolderId = root.getId();
      FolderListener folderListener = new FolderAdapter() {
        @Override
        public void folderUpdated(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            if (event.getEntity().getId() == rootFolderId)
              assertTrue(event.isRoot());
            else
              assertFalse(event.isRoot());
          }
        }
      };
      NewsModel.getDefault().addFolderListener(folderListener);
      try {
        fDao.saveFolder(root);
      } finally {
        NewsModel.getDefault().removeFolderListener(folderListener);
      }

      assertNull("Expected this Entity to be NULL", new FolderReference(folder.getId()).resolve());
      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Folder, BookMark, Feed, News (BookMark Deleted) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed4.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, root, feed.getLink(), feedRef, "BookMark");
      root = fDao.saveFolder(root);
      mark = (IBookMark) root.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteBookMark(new BookMarkReference(mark.getId()));

      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Folder, BookMark, Feed, News (BookMark Deleted #2) */
    {
      IFolder root = fFactory.createFolder(null, null, "Root");
      root = fDao.saveFolder(root);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed5.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      IBookMark mark = fFactory.createBookMark(null, root, feed.getLink(), feedRef, "BookMark");
      root = fDao.saveFolder(root);
      mark = (IBookMark) root.getMarks().get(0);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      /* Delete by calling delete */
      fDao.deleteBookMark(new BookMarkReference(mark.getId()));

      assertNull("Expected this Entity to be NULL", new BookMarkReference(mark.getId()).resolve());
      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }

    /* Feed, News (Feed Deleted) */
    {
      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed6.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      NewsReference newsRef = new NewsReference(feedRef.resolve().getNews().get(0).getId());

      fDao.deleteFeed(feedRef);

      assertNull("Expected this Entity to be NULL", feedRef.resolve());
      assertNull("Expected this Entity to be NULL", newsRef.resolve());
    }
  }
View Full Code Here

      root = fDao.saveFolder(root);
      folder2 = root.getFolders().get(1);

      IFeed feed = fFactory.createFeed(null, new URL("http://www.feed.com"));
      fFactory.createNews(null, feed, new Date());
      FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

      fFactory.createBookMark(null, folder1, feed.getLink(), feedRef, "BookMark");
      folder1 = fDao.saveFolder(folder1);

      assertEquals(1, new FeedReference(feed.getId()).resolve().getNews().size());

      folderListener= new FolderAdapter() {
        @Override
        public void folderUpdated(Set<FolderEvent> events) {
          for (FolderEvent folderEvent : events) {
View Full Code Here

    BookMarkListener bookMarkListener = null;
    SearchMarkListener searchMarkListener = null;
    try {
      /* Add */
      final IFolder oldParent = fFactory.createFolder(null, null, "Old parent");
      FeedReference feedRef = new FeedReference(Long.MAX_VALUE);
      final IBookMark bookMark = fFactory.createBookMark(null, oldParent,
          new URL("http://www.link.com"), feedRef, "bookmark");
      final ISearchMark searchMark = fFactory.createSearchMark(null, oldParent, "searchmark");
      fDao.saveFolder(oldParent);

View Full Code Here

   * @throws Exception
   */
  @Test
  public void testLoadBookMarks() throws Exception {
    IFeed feed = fFactory.createFeed(null, new URL("http://www.myfeed.com"));
    FeedReference feedRef = new FeedReference(fDao.saveFeed(feed).getId());

    List<IBookMark> emptyBookmarks = fAppLayer.loadBookMarks(feed);
    assertEquals(0, emptyBookmarks.size());

    IFolder root1 = fFactory.createFolder(null, null, "Root 1");
    FolderReference root1Ref = new FolderReference(fDao.saveFolder(root1).getId());

    IFolder childOfRoot1 = fFactory.createFolder(null, root1Ref.resolve(), "Child of Root 1");
    FolderReference childOfRoot1Ref = new FolderReference(fDao.saveFolder(childOfRoot1).getId());

    IBookMark bookmark1 = fFactory.createBookMark(null, root1Ref.resolve(),
        feed.getLink(), feedRef, "Bookmark 1");
    IBookMark bookmark2 = fFactory.createBookMark(null, root1Ref.resolve(),
        feed.getLink(), feedRef, "Bookmark 2");
    IBookMark bookmark3 = fFactory.createBookMark(null, childOfRoot1Ref.resolve(),
        feed.getLink(), feedRef, "Bookmark 3");

    BookMarkReference bookmarkRef1 = new BookMarkReference(fDao.saveBookMark(bookmark1).getId());
    BookMarkReference bookmarkRef2 = new BookMarkReference(fDao.saveBookMark(bookmark2).getId());
    BookMarkReference bookmarkRef3 = new BookMarkReference(fDao.saveBookMark(bookmark3).getId());

    List<IBookMark> filledBookmarks = fAppLayer.loadBookMarks(feedRef.resolve());
    assertEquals(3, filledBookmarks.size());
    for (IBookMark mark : filledBookmarks) {
      if (bookmarkRef1.resolve().equals(mark))
        assertEquals(bookmark1.getName(), mark.getName());
      else if (bookmarkRef2.resolve().equals(mark))
View Full Code Here

TOP

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