Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IBookMark


    news0.setLink(newsLink);
    news0.setState(INews.State.READ);
    DynamicDAO.save(feed0);

    IFolder folder = fFactory.createFolder(null, null, "Folder");
    IBookMark mark0 = fFactory.createBookMark(null, folder, new FeedLinkReference(feed0.getLink()), "Mark0");
    DynamicDAO.save(folder);
    fAppService.handleFeedReload(mark0, feed0, null, false);

    IFeed feed1 = fFactory.createFeed(null, new URI("http://www.feed1.com"));
    DynamicDAO.save(feed1);
    IBookMark mark1 = fFactory.createBookMark(null, folder, new FeedLinkReference(feed1.getLink()), "Mark1");
    DynamicDAO.save(folder);

    feed1 = fFactory.createFeed(null, new URI("http://www.feed1.com"));
    INews news1 = fFactory.createNews(null, feed1, new Date());
    news1.setLink(newsLink);
View Full Code Here


   */
  @Test
  public void testHandleFeedReloadWithRetentionStrategy() throws Exception {
    IFeed feed = fFactory.createFeed(null, new URI("http://www.rssowl.org"));
    IFolder folder = fFactory.createFolder(null, null, "Folder");
    IBookMark mark = fFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "Mark");
    DynamicDAO.save(feed);
    DynamicDAO.save(folder);

    IFeed emptyFeed = fFactory.createFeed(null, feed.getLink());
    INews news = fFactory.createNews(null, emptyFeed, new Date());
View Full Code Here

      IFeed feed = fFactory.createFeed(null, new URI("http://www.rssowl.org"));
      INews news = fFactory.createNews(null, feed, new Date());
      news.setGuid(fFactory.createGuid(news, "newsguid"));
      fFactory.createAttachment(null, news);
      IFolder folder = fFactory.createFolder(null, null, "Folder");
      IBookMark mark = fFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "Mark");
      DynamicDAO.save(feed);
      DynamicDAO.save(folder);

      IFeed emptyFeed = fFactory.createFeed(null, feed.getLink());
      INews emptyNews = fFactory.createNews(null, emptyFeed, new Date());
View Full Code Here

    BookMarkListener bookMarkListener = null;
    SearchMarkListener searchMarkListener = null;
    try {
      /* Add */
      final IFolder oldMarkParent = fFactory.createFolder(null, null, "Old parent");
      final IBookMark bookMark = fFactory.createBookMark(null, oldMarkParent, new FeedLinkReference(new URI("http://www.link.com")), "bookmark");
      final ISearchMark searchMark = fFactory.createSearchMark(null, oldMarkParent, "searchmark");
      DynamicDAO.save(oldMarkParent);

      final IFolder newMarkParent = fFactory.createFolder(null, null, "New parent");
      fFactory.createFolder(null, newMarkParent, "New parent child");
      DynamicDAO.save(newMarkParent);

      /* Add */
      final IFolder oldFolderParent = fFactory.createFolder(null, null, "Old parent");
      final IFolder folder = fFactory.createFolder(null, oldFolderParent, "Folder");
      DynamicDAO.save(oldFolderParent);

      final IFolder newFolderParent = fFactory.createFolder(null, null, "New parent");
      fFactory.createFolder(null, newFolderParent, "New parent child");
      DynamicDAO.save(newFolderParent);

      final boolean[] folderUpdateEventOccurred = new boolean[1];
      folderListener = new FolderListener() {
        public void entitiesAdded(Set<FolderEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesDeleted(Set<FolderEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesUpdated(Set<FolderEvent> events) {
          folderUpdateEventOccurred[0] = true;
          assertEquals(7, events.size());
          boolean foundFolder = false;
          for (FolderEvent event : events) {
            if (event.getEntity().equals(folder)) {
              foundFolder = true;
              assertTrue("Expected this Event to be Root Event", event.isRoot());
              assertEquals(oldFolderParent, event.getOldParent());
              assertEquals(newFolderParent, event.getEntity().getParent());
            } else
              assertFalse("Expected this Event to be NO Root Event", event.isRoot());
          }
          assertTrue("No event was issued for folder", foundFolder);
        }
      };
      final boolean[] bookMarkUpdateEventOccurred = new boolean[1];
      bookMarkListener = new BookMarkListener() {
        public void entitiesAdded(Set<BookMarkEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesDeleted(Set<BookMarkEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesUpdated(Set<BookMarkEvent> events) {
          bookMarkUpdateEventOccurred[0] = true;
          assertEquals(1, events.size());
          BookMarkEvent event = events.iterator().next();
          assertEquals(bookMark, event.getEntity());
          assertTrue("Expected this Event to be Root Event", event.isRoot());
          assertEquals(oldMarkParent, event.getOldParent());
          assertEquals(newMarkParent, event.getEntity().getParent());
        }
      };

      final boolean[] searchMarkUpdateEventOccurred = new boolean[1];
      searchMarkListener = new SearchMarkListener() {
        public void entitiesAdded(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesDeleted(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesUpdated(Set<SearchMarkEvent> events) {
          searchMarkUpdateEventOccurred[0] = true;
          assertEquals(1, events.size());
          SearchMarkEvent event = events.iterator().next();
          assertEquals(searchMark, event.getEntity());
          assertTrue("Expected this Event to be Root Event", event.isRoot());
          assertEquals(oldMarkParent, event.getOldParent());
          assertEquals(newMarkParent, event.getEntity().getParent());
        }

        public void resultsChanged(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }
      };

      DynamicDAO.addEntityListener(IFolder.class, folderListener);
      DynamicDAO.addEntityListener(IBookMark.class, bookMarkListener);
      DynamicDAO.addEntityListener(ISearchMark.class, searchMarkListener);

      List<ReparentInfo<IFolderChild, IFolder>> reparentInfos = new ArrayList<ReparentInfo<IFolderChild, IFolder>>();
      reparentInfos.add(new ReparentInfo<IFolderChild, IFolder>(folder, newFolderParent, null, null));
      reparentInfos.add(new ReparentInfo<IFolderChild, IFolder>(bookMark, newMarkParent, null, null));
      reparentInfos.add(new ReparentInfo<IFolderChild, IFolder>(searchMark, newMarkParent, null, null));

      Owl.getPersistenceService().getDAOService().getFolderDAO().reparent(reparentInfos);

      /* Asserts Follow */

      /* Folder reparenting */
      assertFalse(oldFolderParent.getFolders().contains(folder));
      assertEquals(0, oldFolderParent.getFolders().size());
      assertTrue(newFolderParent.getFolders().contains(folder));
      assertEquals(newFolderParent, folder.getParent());
      assertEquals(2, newFolderParent.getFolders().size());

      /* Marks reparenting */
      assertFalse(oldMarkParent.getFolders().contains(bookMark));
      assertFalse(oldMarkParent.getFolders().contains(searchMark));
      assertEquals(0, oldMarkParent.getMarks().size());
      assertTrue(newMarkParent.getMarks().contains(bookMark));
      assertTrue(newMarkParent.getMarks().contains(searchMark));
      assertEquals(newMarkParent, bookMark.getParent());
      assertEquals(newMarkParent, searchMark.getParent());
      assertEquals(2, newMarkParent.getMarks().size());

      /* Events fired */
      assertTrue("Missing folderUpdated Event", folderUpdateEventOccurred[0]);
View Full Code Here

    FolderReference root1Ref = new FolderReference(DynamicDAO.save(root1).getId());

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

    IBookMark bookmark1 = fFactory.createBookMark(null, root1Ref.resolve(), new FeedLinkReference(feed.getLink()), "Bookmark 1");
    IBookMark bookmark2 = fFactory.createBookMark(null, root1Ref.resolve(), new FeedLinkReference(feed.getLink()), "Bookmark 2");
    IBookMark bookmark3 = fFactory.createBookMark(null, childOfRoot1Ref.resolve(), 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 = Owl.getPersistenceService().getDAOService().getBookMarkDAO().loadAll(feedLinkRef);
    assertEquals(3, filledBookmarks.size());
    for (IBookMark mark : filledBookmarks) {
      if (bookmarkRef1.resolve().equals(mark))
        assertEquals(bookmark1.getName(), mark.getName());
      else if (bookmarkRef2.resolve().equals(mark))
        assertEquals(bookmark2.getName(), mark.getName());
      else if (bookmarkRef3.resolve().equals(mark))
        assertEquals(bookmark3.getName(), mark.getName());
      else
        fail();
    }
  }
View Full Code Here

    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());
      else if (bookmarkRef2.resolve().equals(mark))
        assertEquals(bookmark2.getName(), mark.getName());
      else if (bookmarkRef3.resolve().equals(mark))
        assertEquals(bookmark3.getName(), mark.getName());
      else
        fail();
    }
  }
View Full Code Here

    /* Close Editor if Input was Deleted (BookMark) */
    fBookMarkListener = new BookMarkAdapter() {
      @Override
      public void entitiesDeleted(Set<BookMarkEvent> events) {
        for (BookMarkEvent event : events) {
          IBookMark mark = event.getEntity();
          if (mark.getId().equals(fInput.getMark().getId())) {
            fInput.setDeleted();
            fEditorSite.getPage().closeEditor(FeedView.this, false);
            break;
          }
        }
      }

      @Override
      public void entitiesUpdated(Set<BookMarkEvent> events) {
        for (BookMarkEvent event : events) {
          final IBookMark mark = event.getEntity();
          if (mark.getId().equals(fInput.getMark().getId())) {
            JobRunner.runInUIThread(fParent, new Runnable() {
              public void run() {
                setPartName(mark.getName());
                OwlUI.updateWindowTitle(new IMark[] { fInput.getMark() });
              }
            });

            break;
          }
        }
      }
    };
    DynamicDAO.addEntityListener(IBookMark.class, fBookMarkListener);

    /* Close Editor if Input was Deleted & Update on results Changed */
    fSearchMarkListener = new SearchMarkAdapter() {
      @Override
      public void entitiesDeleted(Set<SearchMarkEvent> events) {
        for (SearchMarkEvent event : events) {
          ISearchMark mark = event.getEntity();
          if (fInput.getMark().getId().equals(mark.getId())) {
            fEditorSite.getPage().closeEditor(FeedView.this, false);
            fInput.setDeleted();
            break;
          }
        }
      }

      @Override
      public void entitiesUpdated(Set<SearchMarkEvent> events) {
        for (SearchMarkEvent event : events) {
          final ISearchMark mark = event.getEntity();
          if (mark.getId().equals(fInput.getMark().getId())) {
            JobRunner.runInUIThread(fParent, new Runnable() {
              public void run() {
                setPartName(mark.getName());
                OwlUI.updateWindowTitle(new IMark[] { fInput.getMark() });
              }
            });

            break;
View Full Code Here

      }
    }

    /* Update BookMark */
    else if (entity instanceof IBookMark) {
      IBookMark bookmark = (IBookMark) entity;

      /* Check for changed Name */
      if (!bookmark.getName().equals(fNameInput.getText())) {
        bookmark.setName(fNameInput.getText());
        entitiesToSave.add(bookmark);
      }

      /* Append "http" to Link if missing */
      String uriAsString = fFeedInput.getText();
      if (URIUtils.looksLikeLink(uriAsString)) {
        if (!uriAsString.contains("://"))
          uriAsString = "http://" + uriAsString;
      }

      /* Check for changed Feed */
      if (!bookmark.getFeedLinkReference().getLink().toString().equals(uriAsString)) {
        try {
          DAOService daoService = Owl.getPersistenceService().getDAOService();

          /* 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);
          }

          /* Remember the old Reference */
          FeedLinkReference oldFeedRef = bookmark.getFeedLinkReference();

          /* Apply the new Reference */
          bookmark.setFeedLinkReference(new FeedLinkReference(newFeedLink));
          entitiesToSave.add(bookmark);

          /* Check if the old reference can be deleted now */
          if (daoService.getBookMarkDAO().loadAll(oldFeedRef).size() == 1)
            DynamicDAO.delete(oldFeedRef.resolve());

          /* Delete the Favicon since the feed has changed */
          OwlUI.deleteImage(bookmark.getId());
        }

        /* Supplied Feed Link not valid */
        catch (URISyntaxException e) {
          fSite.select(this);
View Full Code Here

        IMark mark = fInput.getMark();

        /* Trigger a reload if this is the first time open */
        if (mark instanceof IBookMark) {
          IBookMark bookmark = (IBookMark) mark;
          if ((bookmark.getLastVisitDate() == null && !fContentProvider.hasCachedNews()))
            new ReloadTypesAction(new StructuredSelection(mark), getEditorSite().getShell()).run();
        }

        /* Update some fields due to displaying the mark */
        if (mark instanceof ISearchMark) {
View Full Code Here

    if (unread && fInput.getMark() instanceof ISearchMark) {
      ISearchMark searchmark = (ISearchMark) fInput.getMark();
      if (searchmark.getResultCount(EnumSet.of(INews.State.NEW, INews.State.UNREAD, INews.State.UPDATED)) == 0)
        return false;
    } else if (unread && fInput.getMark() instanceof IBookMark) {
      IBookMark bookmark = (IBookMark) fInput.getMark();
      if (fNewsService.getUnreadCount(bookmark.getFeedLinkReference()) == 0)
        return false;
    }

    /* Don't update Selection in Tree, since this is not News-Scoped */
    if (!newsScoped)
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IBookMark

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.