Package org.rssowl.core.persist.dao

Examples of org.rssowl.core.persist.dao.IBookMarkDAO


  @Test
  public void testLoadAllBookMarks() throws Exception {
    IFeed feed = fFactory.createFeed(null, new URI("http://www.myfeed.com"));
    DynamicDAO.save(feed);

    IBookMarkDAO markDAO = DynamicDAO.getDAO(IBookMarkDAO.class);
    Collection<IBookMark> emptyBookmarks = markDAO.loadAll();
    assertEquals(0, emptyBookmarks.size());

    IFolder root1 = fFactory.createFolder(null, null, "Root 1");
    root1 = DynamicDAO.save(root1);

    IFolder childOfRoot1 = fFactory.createFolder(null, root1, "Child of Root 1");
    childOfRoot1 = DynamicDAO.save(childOfRoot1);

    IBookMark bookmark1 = fFactory.createBookMark(null, root1, new FeedLinkReference(feed.getLink()), "Bookmark 1");
    IBookMark bookmark2 = fFactory.createBookMark(null, root1, new FeedLinkReference(feed.getLink()), "Bookmark 2");
    IBookMark bookmark3 = fFactory.createBookMark(null, childOfRoot1, new FeedLinkReference(feed.getLink()), "Bookmark 3");

    BookMarkReference bookmarkRef1 = new BookMarkReference(DynamicDAO.save(bookmark1).getId());
    BookMarkReference bookmarkRef2 = new BookMarkReference(DynamicDAO.save(bookmark2).getId());
    BookMarkReference bookmarkRef3 = new BookMarkReference(DynamicDAO.save(bookmark3).getId());

    Collection<IBookMark> filledBookmarks = DynamicDAO.loadAll(IBookMark.class);
    assertEquals(3, filledBookmarks.size());

    filledBookmarks = markDAO.loadAll();
    assertEquals(3, filledBookmarks.size());

    for (IBookMark mark : filledBookmarks) {
      if (bookmarkRef1.resolve().equals(mark))
        assertEquals(bookmark1.getName(), mark.getName());
View Full Code Here


    feed = null;
    DynamicDAO.save(root1);
    root1 = null;
    System.gc();

    IBookMarkDAO markDAO = DynamicDAO.getDAO(IBookMarkDAO.class);
    Collection<IBookMark> marks = markDAO.loadAll();
    assertEquals(1, marks.size());
    assertEquals(folderName, marks.iterator().next().getParent().getName());
    marks = null;
    System.gc();

    marks = markDAO.loadAll();
    assertEquals(1, marks.size());
  }
View Full Code Here

    return maskEmpty(new ArrayList<EntityGroup>(Arrays.asList(new EntityGroup[] { gSticky, gNotSticky })));
  }

  private Collection<EntityGroup> createFeedGroups(Collection<INews> input) {
    Map<Long, EntityGroup> groupCache = new HashMap<Long, EntityGroup>();
    IBookMarkDAO bookmarkDao = DynamicDAO.getDAO(IBookMarkDAO.class);
    Map<FeedLinkReference, IBookMark> feedToBookMarkCache = new HashMap<FeedLinkReference, IBookMark>();

    /* Group Input */
    int nextId = 0;
    for (Object object : input) {
      if (object instanceof INews) {
        INews news = (INews) object;
        FeedLinkReference feedRef = news.getFeedReference();

        IBookMark bookmark = feedToBookMarkCache.get(feedRef);
        if (bookmark == null) {
          Collection<IBookMark> bookmarks = bookmarkDao.loadAll(feedRef);
          if (bookmarks.isEmpty())
            continue;

          bookmark = bookmarks.iterator().next();
          feedToBookMarkCache.put(feedRef, bookmark);
View Full Code Here

    return false;
  }

  /* Remove existing Bookmarks and Empty Folders */
  private List<IFolderChild> excludeExisting(List<IFolderChild> folderChilds) {
    IBookMarkDAO dao = DynamicDAO.getDAO(IBookMarkDAO.class);

    for (Iterator<IFolderChild> iterator = folderChilds.iterator(); iterator.hasNext();) {
      IFolderChild child = iterator.next();

      /* Bookmark (exclude if another Bookmark with same Link exists) */
      if (child instanceof IBookMark) {
        IBookMark bm = (IBookMark) child;
        if (dao.exists(bm.getFeedLinkReference()))
          iterator.remove();
      }

      /* Bin (exclude if another Bin with same name Exists at same Location) */
      else if (child instanceof INewsBin) {
View Full Code Here

    return folderChilds;
  }

  /* Remove existing Bookmarks and Empty Folders */
  private void excludeExisting(IFolder folder) {
    IBookMarkDAO dao = DynamicDAO.getDAO(IBookMarkDAO.class);
    List<IFolderChild> children = folder.getChildren();

    for (IFolderChild child : children) {

      /* Bookmark (exclude if another Bookmark with same Link exists) */
      if (child instanceof IBookMark) {
        IBookMark bm = (IBookMark) child;
        if (dao.exists(bm.getFeedLinkReference()))
          folder.removeChild(bm);
      }

      /* Bin (exclude if another Bin with same name Exists at same Location) */
      else if (child instanceof INewsBin) {
View Full Code Here

    defaultRootFolder.setProperty(ITypeImporter.TEMPORARY_FOLDER, true);

    /* For Each Link of the Queue - try to interpret as Feed */
    int counter = 0;
    final List<String> foundBookMarkNames = new ArrayList<String>();
    IBookMarkDAO dao = DynamicDAO.getDAO(IBookMarkDAO.class);
    for (String feedLinkVal : links) {
      monitor.worked(1);

      InputStream in = null;
      boolean canceled = false;
      Exception error = null;
      try {
        URI feedLink = new URI(feedLinkVal);

        /* Report Progress Back To User */
        if (counter == 1)
          monitor.subTask(Messages.ImportElementsPage_SINGLE_RESULT);
        else if (counter > 1)
          monitor.subTask(NLS.bind(Messages.ImportElementsPage_N_RESULTS, counter));

        /* Ignore if already present in Subscriptions List (ignoring trailing slashes) */
        if (dao.exists(new FeedLinkReference(feedLink)))
          continue;
        else if (feedLinkVal.endsWith("/") && dao.exists(new FeedLinkReference(new URI(feedLinkVal.substring(0, feedLinkVal.length() - 1))))) //$NON-NLS-1$
          continue;
        else if (!feedLinkVal.endsWith("/") && dao.exists(new FeedLinkReference(new URI(feedLinkVal + "/")))) //$NON-NLS-1$ //$NON-NLS-2$
          continue;

        /* Return on Cancellation */
        if (monitor.isCanceled() || Controller.getDefault().isShuttingDown())
          break;
View Full Code Here

   * Returns a Set of all Links that are added as Bookmarks.
   *
   * @return Returns a Set of all Links that are added as Bookmarks.
   */
  public static Set<String> getFeedLinks() {
    IBookMarkDAO bookMarkDAO = Owl.getPersistenceService().getDAOService().getBookMarkDAO();
    Collection<IBookMark> bookMarks = bookMarkDAO.loadAll();
    Set<String> links = new HashSet<String>(bookMarks.size());

    for (IBookMark bookmark : bookMarks) {
      links.add(bookmark.getFeedLinkReference().getLinkAsText());
    }
View Full Code Here

   * @param feedRef The desired Feed.
   * @return Returns the first <code>IBookMark</code> that references the given
   * Feed or <code>null</code> if none.
   */
  public static IBookMark getBookMark(FeedLinkReference feedRef) {
    IBookMarkDAO bookMarkDAO = Owl.getPersistenceService().getDAOService().getBookMarkDAO();
    Collection<IBookMark> bookMarks = bookMarkDAO.loadAll();
    for (IBookMark bookMark : bookMarks) {
      if (bookMark.getFeedLinkReference().equals(feedRef))
        return bookMark;
    }

View Full Code Here

   * @param feedRef The desired Feed.
   * @return Returns the first <code>IBookMark</code> that references the given
   * Feed or <code>null</code> if none.
   */
  public static IBookMark getBookMark(String feedRef) {
    IBookMarkDAO bookMarkDAO = Owl.getPersistenceService().getDAOService().getBookMarkDAO();
    Collection<IBookMark> bookMarks = bookMarkDAO.loadAll();
    for (IBookMark bookMark : bookMarks) {
      if (bookMark.getFeedLinkReference().getLinkAsText().equals(feedRef))
        return bookMark;
    }

View Full Code Here

  @Test
  public void testLoadAllBookMarks() throws Exception {
    IFeed feed = fFactory.createFeed(null, new URI("http://www.myfeed.com"));
    DynamicDAO.save(feed);

    IBookMarkDAO markDAO = DynamicDAO.getDAO(IBookMarkDAO.class);
    Collection<IBookMark> emptyBookmarks = markDAO.loadAll();
    assertEquals(0, emptyBookmarks.size());

    IFolder root1 = fFactory.createFolder(null, null, "Root 1");
    root1 = DynamicDAO.save(root1);

    IFolder childOfRoot1 = fFactory.createFolder(null, root1, "Child of Root 1");
    childOfRoot1 = DynamicDAO.save(childOfRoot1);

    IBookMark bookmark1 = fFactory.createBookMark(null, root1, new FeedLinkReference(feed.getLink()), "Bookmark 1");
    IBookMark bookmark2 = fFactory.createBookMark(null, root1, new FeedLinkReference(feed.getLink()), "Bookmark 2");
    IBookMark bookmark3 = fFactory.createBookMark(null, childOfRoot1, new FeedLinkReference(feed.getLink()), "Bookmark 3");

    BookMarkReference bookmarkRef1 = new BookMarkReference(DynamicDAO.save(bookmark1).getId());
    BookMarkReference bookmarkRef2 = new BookMarkReference(DynamicDAO.save(bookmark2).getId());
    BookMarkReference bookmarkRef3 = new BookMarkReference(DynamicDAO.save(bookmark3).getId());

    Collection<IBookMark> filledBookmarks = DynamicDAO.loadAll(IBookMark.class);
    assertEquals(3, filledBookmarks.size());

    filledBookmarks = markDAO.loadAll();
    assertEquals(3, filledBookmarks.size());

    for (IBookMark mark : filledBookmarks) {
      if (bookmarkRef1.resolve().equals(mark))
        assertEquals(bookmark1.getName(), mark.getName());
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.dao.IBookMarkDAO

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.