Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INewsBin


    news2.setState(INews.State.NEW);

    INews news3 = createNews(feed, "News3");
    news3.setState(INews.State.NEW);

    INewsBin bin = fFactory.createNewsBin(null, bm.getParent(), "Bin");
    DynamicDAO.save(bin);

    ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
    filter.setMatchAllNews(true);
    filter.setEnabled(true);

    IFilterAction action = fFactory.createFilterAction(MOVE_NEWS_ID);
    action.setData(new Long[] { bin.getId() });
    filter.addAction(action);

    action = fFactory.createFilterAction(MARK_STICKY_ID);
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());

    List<INews> news = bm.getFeedLinkReference().resolve().getNews();
    assertEquals(3, news.size());
    assertEquals(3, bm.getNewsCount(EnumSet.of(INews.State.DELETED)));
    for (INews newsitem : news) {
      assertEquals(INews.State.DELETED, newsitem.getState());
    }

    List<INews> binNews = bin.getNews();
    assertEquals(3, bin.getNewsCount(EnumSet.of(INews.State.NEW)));
    for (INews newsitem : binNews) {
      assertEquals(INews.State.NEW, newsitem.getState());
      assertEquals(bin.getId(), (Long) newsitem.getParentId());
      assertEquals(true, newsitem.isFlagged());
    }

  }
View Full Code Here


    news4.setState(INews.State.NEW);

    ILabel label = fFactory.createLabel(null, "New Label");
    DynamicDAO.save(label);

    INewsBin bin1 = fFactory.createNewsBin(null, bm.getParent(), "Bin 1");
    INewsBin bin2 = fFactory.createNewsBin(null, bm.getParent(), "Bin 2");

    DynamicDAO.save(bin1);
    DynamicDAO.save(bin2);

    /* Filter "Title is Title": Mark Read, Sticky, Label, Copy */
    {
      ISearch search = createTitleSearch("Title");

      ISearchFilter filter = fFactory.createSearchFilter(null, search, "Title is Title");
      filter.setEnabled(true);
      filter.setOrder(0);

      filter.addAction(fFactory.createFilterAction(MARK_READ_ID));
      filter.addAction(fFactory.createFilterAction(MARK_STICKY_ID));

      IFilterAction labelAction = fFactory.createFilterAction(LABEL_NEWS_ID);
      labelAction.setData(label.getId());
      filter.addAction(labelAction);

      IFilterAction copyAction = fFactory.createFilterAction(COPY_NEWS_ID);
      copyAction.setData(new Long[] { bin1.getId(), bin2.getId() });
      filter.addAction(copyAction);

      DynamicDAO.save(filter);
    }

    /* Filter "Title is Other": Move */
    {
      ISearch search = createTitleSearch("Other");

      ISearchFilter filter = fFactory.createSearchFilter(null, search, "Title is Other");
      filter.setEnabled(true);
      filter.setOrder(1);

      IFilterAction moveAction = fFactory.createFilterAction(MOVE_NEWS_ID);
      moveAction.setData(new Long[] { bin1.getId(), bin2.getId() });
      filter.addAction(moveAction);

      DynamicDAO.save(filter);
    }

    /* Filter "Match All": Label News */
    {

      ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
      filter.setEnabled(true);
      filter.setMatchAllNews(true);
      filter.setOrder(2);

      IFilterAction labelAction = fFactory.createFilterAction(LABEL_NEWS_ID);
      labelAction.setData(label.getId());
      filter.addAction(labelAction);

      DynamicDAO.save(filter);
    }

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());

    List<INews> news = bm.getFeedLinkReference().resolve().getNews();
    assertEquals(4, news.size());
    assertEquals(2, bm.getNewsCount(EnumSet.of(INews.State.READ)));
    assertEquals(1, bm.getNewsCount(EnumSet.of(INews.State.DELETED)));
    assertEquals(1, bm.getNewsCount(EnumSet.of(INews.State.NEW)));
    for (INews newsitem : news) {
      if (newsitem.equals(news1)) {
        assertEquals(INews.State.READ, news1.getState());
        assertTrue(newsitem.isFlagged());
        assertTrue(!news1.getLabels().isEmpty());
        assertEquals(label, news1.getLabels().iterator().next());
      } else if (newsitem.equals(news2)) {
        assertEquals(INews.State.READ, news2.getState());
        assertTrue(newsitem.isFlagged());
        assertTrue(!news2.getLabels().isEmpty());
        assertEquals(label, news2.getLabels().iterator().next());
      } else if (newsitem.equals(news3)) {
        assertEquals(INews.State.DELETED, news3.getState());
      } else if (newsitem.equals(news4)) {
        assertTrue(!news4.getLabels().isEmpty());
        assertEquals(label, news4.getLabels().iterator().next());
      }
    }

    assertEquals(3, bin1.getNews().size());
    assertEquals(1, bin1.getNewsCount(EnumSet.of(INews.State.NEW)));
    assertEquals(2, bin1.getNewsCount(EnumSet.of(INews.State.READ)));

    List<INews> binNews = bin1.getNews();
    for (INews newsitem : binNews) {
      if (newsitem.equals(news1)) {
        assertEquals(INews.State.READ, news1.getState());
        assertTrue(newsitem.isFlagged());
        assertTrue(!news1.getLabels().isEmpty());
        assertEquals(label, news1.getLabels().iterator().next());
      } else if (newsitem.equals(news2)) {
        assertEquals(INews.State.READ, news2.getState());
        assertTrue(newsitem.isFlagged());
        assertTrue(!news2.getLabels().isEmpty());
        assertEquals(label, news2.getLabels().iterator().next());
      } else if (newsitem.equals(news3)) {
        assertEquals(INews.State.NEW, news3.getState());
        assertTrue(newsitem.getLabels().isEmpty());
        assertTrue(!newsitem.isFlagged());
      }
    }

    assertEquals(3, bin2.getNews().size());
    assertEquals(1, bin2.getNewsCount(EnumSet.of(INews.State.NEW)));
    assertEquals(2, bin2.getNewsCount(EnumSet.of(INews.State.READ)));

    binNews = bin2.getNews();
    for (INews newsitem : binNews) {
      if (newsitem.equals(news1)) {
        assertEquals(INews.State.READ, news1.getState());
        assertTrue(newsitem.isFlagged());
      } else if (newsitem.equals(news2)) {
View Full Code Here

    news2.setState(INews.State.NEW);

    INews news3 = createNews(feed, "News3");
    news3.setState(INews.State.NEW);

    INewsBin bin = fFactory.createNewsBin(null, bm.getParent(), "Bin");
    DynamicDAO.save(bin);

    ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
    filter.setMatchAllNews(true);
    filter.setEnabled(true);

    IFilterAction action = fFactory.createFilterAction(MOVE_NEWS_ID);
    action.setData(new Long[] { bin.getId() + 1 });
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());

    List<INews> news = bm.getFeedLinkReference().resolve().getNews();
    assertEquals(3, news.size());
    assertEquals(3, bm.getNewsCount(EnumSet.of(INews.State.NEW)));
    for (INews newsitem : news) {
      assertEquals(INews.State.NEW, newsitem.getState());
    }

    List<INews> binNews = bin.getNews();
    assertEquals(0, binNews.size());
  }
View Full Code Here

          return true;
      }

      /* News could be part of Bin (and is a copy) */
      else if (news.getParentId() != 0 && child instanceof INewsBin) {
        INewsBin bin = (INewsBin) child;
        if (bin.getId() == news.getParentId())
          return true;
      }
    }

    return false;
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testMoveCopyToBinAction() throws Exception {
    IFolder folder = fFactory.createFolder(null, null, "Root");
    INewsBin bin = fFactory.createNewsBin(null, folder, "Bin");
    folder = DynamicDAO.save(folder);
    bin = (INewsBin) folder.getMarks().get(0);

    IFeed feed = Owl.getModelFactory().createFeed(null, new URI("feed"));
    INews news1 = Owl.getModelFactory().createNews(null, feed, new Date());
    news1.setTitle("News 1");
    INews news2 = Owl.getModelFactory().createNews(null, feed, new Date());
    news2.setTitle("News 2");
    INews news3 = Owl.getModelFactory().createNews(null, feed, new Date());
    news3.setTitle("News 3");
    DynamicDAO.save(feed);

    MoveCopyNewsToBinAction action = new MoveCopyNewsToBinAction(new StructuredSelection(news1), bin, false);
    action.run();

    assertEquals(1, bin.getNews().size());
    assertEquals("News 1", bin.getNews().get(0).getTitle());

    action = new MoveCopyNewsToBinAction(new StructuredSelection(news2), bin, true);
    action.run();

    assertEquals(2, bin.getNews().size());
    assertEquals("News 1", bin.getNews().get(0).getTitle());
    assertEquals("News 2", bin.getNews().get(1).getTitle());
  }
View Full Code Here

    IBookMark subSubSubRoot1BM1 = DynamicDAO.save(fFactory.createBookMark(null, subSubSubRoot1, new FeedLinkReference(feed8.getLink()), "Sub Sub Sub Root 1 Bookmark 1"));
    Long subSubSubRoot1BM1Id = subSubSubRoot1BM1.getId();
    setProperties(subSubSubRoot1BM1);

    /* News Bins */
    INewsBin rootNB1 = DynamicDAO.save(fFactory.createNewsBin(null, root, "Root Newsbin 1"));
    Long rootNB1Id = rootNB1.getId();
    setProperties(rootNB1);

    INewsBin rootNB2 = DynamicDAO.save(fFactory.createNewsBin(null, root, "Root Newsbin 2"));
    Long rootNB2Id = rootNB2.getId();
    setProperties(rootNB2);

    INewsBin subRoot1NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot1, "Sub Root 1 Newsbin 1"));
    Long subRoot1NB1Id = subRoot1NB1.getId();
    setProperties(subRoot1NB1);

    INewsBin subRoot1NB2 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot1, "Sub Root 1 Newsbin 2"));
    Long subRoot1NB2Id = subRoot1NB2.getId();
    setProperties(subRoot1NB2);

    INewsBin subRoot2NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot2, "Sub Root 2 Newsbin 1"));
    Long subRoot2NB1Id = subRoot2NB1.getId();
    setProperties(subRoot2NB1);

    INewsBin subRoot3NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot3, "Sub Root 3 Newsbin 1"));
    Long subRoot3NB1Id = subRoot3NB1.getId();
    setProperties(subRoot3NB1);

    INewsBin subSubRoot1NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subSubRoot1, "Sub Sub Root 1 Newsbin 1"));
    Long subSubRoot1NB1Id = subSubRoot1NB1.getId();
    setProperties(subSubRoot1NB1);

    INewsBin subSubSubRoot1NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subSubSubRoot1, "Sub Sub Sub Root 1 Newsbin 1"));
    Long subSubSubRoot1NB1Id = subSubSubRoot1NB1.getId();
    setProperties(subSubSubRoot1NB1);

    /* Search Marks */
    ISearchMark rootSM1 = DynamicDAO.save(fFactory.createSearchMark(null, root, "Root Searchmark 1"));
    Long rootSM1Id = rootSM1.getId();
    setProperties(rootSM1);

    ISearchMark rootSM2 = DynamicDAO.save(fFactory.createSearchMark(null, root, "Root Searchmark 2"));
    Long rootSM2Id = rootSM2.getId();
    setProperties(rootSM2);

    ISearchMark subRoot1SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot1, "Sub Root 1 Searchmark 1"));
    Long subRoot1SM1Id = subRoot1SM1.getId();
    setProperties(subRoot1SM1);

    ISearchMark subRoot1SM2 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot1, "Sub Root 1 Searchmark 2"));
    Long subRoot1SM2Id = subRoot1SM2.getId();
    setProperties(subRoot1SM2);

    ISearchMark subRoot2SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot2, "Sub Root 2 Searchmark 1"));
    Long subRoot2SM1Id = subRoot2SM1.getId();
    setProperties(subRoot2SM1);

    ISearchMark subRoot3SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot3, "Sub Root 3 Searchmark 1"));
    Long subRoot3SM1Id = subRoot3SM1.getId();
    setProperties(subRoot3SM1);

    ISearchMark subSubRoot1SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subSubRoot1, "Sub Sub Root 1 Searchmark 1"));
    Long subSubRoot1SM1Id = subSubRoot1SM1.getId();
    setProperties(subSubRoot1SM1);

    ISearchMark subSubSubRoot1SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subSubSubRoot1, "Sub Sub Sub Root 1 Searchmark 1"));
    Long subSubSubRoot1SM1Id = subSubSubRoot1SM1.getId();
    setProperties(subSubSubRoot1SM1);

    DynamicDAO.save(root);

    /* Reopen Database */
    Owl.getPersistenceService().shutdown(false);

    root = null;
    subRoot1 = null;
    subRoot2 = null;
    subRoot3 = null;
    subSubRoot1 = null;
    subSubSubRoot1 = null;

    rootBM1 = null;
    rootBM2 = null;
    subRoot1BM1 = null;
    subRoot1BM2 = null;
    subRoot2BM1 = null;
    subRoot3BM1 = null;
    subSubRoot1BM1 = null;
    subSubSubRoot1BM1 = null;

    rootNB1 = null;
    rootNB2 = null;
    subRoot1NB1 = null;
    subRoot1NB2 = null;
    subRoot2NB1 = null;
    subRoot3NB1 = null;
    subSubRoot1NB1 = null;
    subSubSubRoot1NB1 = null;

    rootSM1 = null;
    rootSM2 = null;
    subRoot1SM1 = null;
    subRoot1SM2 = null;
    subRoot2SM1 = null;
    subRoot3SM1 = null;
    subSubRoot1SM1 = null;
    subSubSubRoot1SM1 = null;

    System.gc();
    Owl.getPersistenceService().startup(new NullOperationMonitor());

    /* Assert Folders */
    CachingDAO dao = (CachingDAO) DynamicDAO.getDAO(IFolderDAO.class);
    root = (IFolder) dao.load(rootFolderId);
    assertNotNull(root);
    assertEquals("Root", root.getName());
    assertProperties(root);

    subRoot1 = (IFolder) dao.load(subRootFolder1Id);
    assertNotNull(subRoot1);
    assertEquals("Sub Root 1", subRoot1.getName());
    assertProperties(subRoot1);

    subRoot2 = (IFolder) dao.load(subRootFolder2Id);
    assertNotNull(subRoot2);
    assertEquals("Sub Root 2", subRoot2.getName());
    assertProperties(subRoot2);

    subRoot3 = (IFolder) dao.load(subRootFolder3Id);
    assertNotNull(subRoot3);
    assertEquals("Sub Root 3", subRoot3.getName());
    assertProperties(subRoot3);

    subSubRoot1 = (IFolder) dao.load(subSubRootFolder1Id);
    assertNotNull(subSubRoot1);
    assertEquals("Sub Sub Root 1", subSubRoot1.getName());
    assertProperties(subSubRoot1);

    subSubSubRoot1 = (IFolder) dao.load(subSubSubRootFolder1Id);
    assertNotNull(subSubSubRoot1);
    assertEquals("Sub Sub Sub Root 1", subSubSubRoot1.getName());
    assertProperties(subSubSubRoot1);

    /* Assert Bookmarks */
    dao = (CachingDAO) DynamicDAO.getDAO(IBookMarkDAO.class);

    rootBM1 = (IBookMark) dao.load(rootBM1Id);
    assertNotNull(rootBM1);
    assertEquals("Root Bookmark 1", rootBM1.getName());
    assertProperties(rootBM1);

    rootBM2 = (IBookMark) dao.load(rootBM2Id);
    assertNotNull(rootBM2);
    assertEquals("Root Bookmark 2", rootBM2.getName());
    assertProperties(rootBM2);

    subRoot1BM1 = (IBookMark) dao.load(subRoot1BM1Id);
    assertNotNull(subRoot1BM1);
    assertEquals("Sub Root 1 Bookmark 1", subRoot1BM1.getName());
    assertProperties(subRoot1BM1);

    subRoot1BM2 = (IBookMark) dao.load(subRoot1BM2Id);
    assertNotNull(subRoot1BM2);
    assertEquals("Sub Root 1 Bookmark 2", subRoot1BM2.getName());
    assertProperties(subRoot1BM2);

    subRoot2BM1 = (IBookMark) dao.load(subRoot2BM1Id);
    assertNotNull(subRoot2BM1);
    assertEquals("Sub Root 2 Bookmark 1", subRoot2BM1.getName());
    assertProperties(subRoot2BM1);

    subRoot3BM1 = (IBookMark) dao.load(subRoot3BM1Id);
    assertNotNull(subRoot3BM1);
    assertEquals("Sub Root 3 Bookmark 1", subRoot3BM1.getName());
    assertProperties(subRoot3BM1);

    subSubRoot1BM1 = (IBookMark) dao.load(subSubRoot1BM1Id);
    assertNotNull(subSubRoot1BM1);
    assertEquals("Sub Sub Root 1 Bookmark 1", subSubRoot1BM1.getName());
    assertProperties(subSubRoot1BM1);

    subSubSubRoot1BM1 = (IBookMark) dao.load(subSubSubRoot1BM1Id);
    assertNotNull(subSubSubRoot1BM1);
    assertEquals("Sub Sub Sub Root 1 Bookmark 1", subSubSubRoot1BM1.getName());
    assertProperties(subSubSubRoot1BM1);

    /* Assert News Bins */
    dao = (CachingDAO) DynamicDAO.getDAO(INewsBinDAO.class);

    rootNB1 = (INewsBin) dao.load(rootNB1Id);
    assertNotNull(rootNB1);
    assertEquals("Root Newsbin 1", rootNB1.getName());
    assertProperties(rootNB1);

    rootNB2 = (INewsBin) dao.load(rootNB2Id);
    assertNotNull(rootNB2);
    assertEquals("Root Newsbin 2", rootNB2.getName());
    assertProperties(rootNB2);

    subRoot1NB1 = (INewsBin) dao.load(subRoot1NB1Id);
    assertNotNull(subRoot1NB1);
    assertEquals("Sub Root 1 Newsbin 1", subRoot1NB1.getName());
    assertProperties(subRoot1NB1);

    subRoot1NB2 = (INewsBin) dao.load(subRoot1NB2Id);
    assertNotNull(subRoot1NB2);
    assertEquals("Sub Root 1 Newsbin 2", subRoot1NB2.getName());
    assertProperties(subRoot1NB2);

    subRoot2NB1 = (INewsBin) dao.load(subRoot2NB1Id);
    assertNotNull(subRoot2NB1);
    assertEquals("Sub Root 2 Newsbin 1", subRoot2NB1.getName());
    assertProperties(subRoot2NB1);

    subRoot3NB1 = (INewsBin) dao.load(subRoot3NB1Id);
    assertNotNull(subRoot3NB1);
    assertEquals("Sub Root 3 Newsbin 1", subRoot3NB1.getName());
    assertProperties(subRoot3NB1);

    subSubRoot1NB1 = (INewsBin) dao.load(subSubRoot1NB1Id);
    assertNotNull(subSubRoot1NB1);
    assertEquals("Sub Sub Root 1 Newsbin 1", subSubRoot1NB1.getName());
    assertProperties(subSubRoot1NB1);

    subSubSubRoot1NB1 = (INewsBin) dao.load(subSubSubRoot1NB1Id);
    assertNotNull(subSubSubRoot1NB1);
    assertEquals("Sub Sub Sub Root 1 Newsbin 1", subSubSubRoot1NB1.getName());
    assertProperties(subSubSubRoot1NB1);

    /* Assert Search Marks */
    dao = (CachingDAO) DynamicDAO.getDAO(ISearchMarkDAO.class);

View Full Code Here

    IBookMark subSubSubRoot1BM1 = DynamicDAO.save(fFactory.createBookMark(null, subSubSubRoot1, new FeedLinkReference(feed8.getLink()), "Sub Sub Sub Root 1 Bookmark 1"));
    Long subSubSubRoot1BM1Id = subSubSubRoot1BM1.getId();
    setProperties(subSubSubRoot1BM1);

    /* News Bins */
    INewsBin rootNB1 = DynamicDAO.save(fFactory.createNewsBin(null, root1, "Root Newsbin 1"));
    Long rootNB1Id = rootNB1.getId();
    setProperties(rootNB1);

    INewsBin rootNB2 = DynamicDAO.save(fFactory.createNewsBin(null, root1, "Root Newsbin 2"));
    Long rootNB2Id = rootNB2.getId();
    setProperties(rootNB2);

    INewsBin subRoot1NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot1, "Sub Root 1 Newsbin 1"));
    Long subRoot1NB1Id = subRoot1NB1.getId();
    setProperties(subRoot1NB1);

    INewsBin subRoot1NB2 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot1, "Sub Root 1 Newsbin 2"));
    Long subRoot1NB2Id = subRoot1NB2.getId();
    setProperties(subRoot1NB2);

    INewsBin subRoot2NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot2, "Sub Root 2 Newsbin 1"));
    Long subRoot2NB1Id = subRoot2NB1.getId();
    setProperties(subRoot2NB1);

    INewsBin subRoot3NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subRoot3, "Sub Root 3 Newsbin 1"));
    Long subRoot3NB1Id = subRoot3NB1.getId();
    setProperties(subRoot3NB1);

    INewsBin subSubRoot1NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subSubRoot1, "Sub Sub Root 1 Newsbin 1"));
    Long subSubRoot1NB1Id = subSubRoot1NB1.getId();
    setProperties(subSubRoot1NB1);

    INewsBin subSubSubRoot1NB1 = DynamicDAO.save(fFactory.createNewsBin(null, subSubSubRoot1, "Sub Sub Sub Root 1 Newsbin 1"));
    Long subSubSubRoot1NB1Id = subSubSubRoot1NB1.getId();
    setProperties(subSubSubRoot1NB1);

    /* Search Marks */
    ISearchMark rootSM1 = DynamicDAO.save(fFactory.createSearchMark(null, root1, "Root Searchmark 1"));
    Long rootSM1Id = rootSM1.getId();
    setProperties(rootSM1);

    ISearchMark rootSM2 = DynamicDAO.save(fFactory.createSearchMark(null, root1, "Root Searchmark 2"));
    Long rootSM2Id = rootSM2.getId();
    setProperties(rootSM2);

    ISearchMark subRoot1SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot1, "Sub Root 1 Searchmark 1"));
    Long subRoot1SM1Id = subRoot1SM1.getId();
    setProperties(subRoot1SM1);

    ISearchMark subRoot1SM2 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot1, "Sub Root 1 Searchmark 2"));
    Long subRoot1SM2Id = subRoot1SM2.getId();
    setProperties(subRoot1SM2);

    ISearchMark subRoot2SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot2, "Sub Root 2 Searchmark 1"));
    Long subRoot2SM1Id = subRoot2SM1.getId();
    setProperties(subRoot2SM1);

    ISearchMark subRoot3SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subRoot3, "Sub Root 3 Searchmark 1"));
    Long subRoot3SM1Id = subRoot3SM1.getId();
    setProperties(subRoot3SM1);

    ISearchMark subSubRoot1SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subSubRoot1, "Sub Sub Root 1 Searchmark 1"));
    Long subSubRoot1SM1Id = subSubRoot1SM1.getId();
    setProperties(subSubRoot1SM1);

    ISearchMark subSubSubRoot1SM1 = DynamicDAO.save(fFactory.createSearchMark(null, subSubSubRoot1, "Sub Sub Sub Root 1 Searchmark 1"));
    Long subSubSubRoot1SM1Id = subSubSubRoot1SM1.getId();
    setProperties(subSubSubRoot1SM1);

    DynamicDAO.save(root1);

    /* Reopen Database */
    Owl.getPersistenceService().shutdown(false);

    root1 = null;
    root2 = null;
    root3 = null;
    subRoot1 = null;
    subRoot2 = null;
    subRoot3 = null;
    subSubRoot1 = null;
    subSubSubRoot1 = null;

    rootBM1 = null;
    rootBM2 = null;
    subRoot1BM1 = null;
    subRoot1BM2 = null;
    subRoot2BM1 = null;
    subRoot3BM1 = null;
    subSubRoot1BM1 = null;
    subSubSubRoot1BM1 = null;

    rootNB1 = null;
    rootNB2 = null;
    subRoot1NB1 = null;
    subRoot1NB2 = null;
    subRoot2NB1 = null;
    subRoot3NB1 = null;
    subSubRoot1NB1 = null;
    subSubSubRoot1NB1 = null;

    rootSM1 = null;
    rootSM2 = null;
    subRoot1SM1 = null;
    subRoot1SM2 = null;
    subRoot2SM1 = null;
    subRoot3SM1 = null;
    subSubRoot1SM1 = null;
    subSubSubRoot1SM1 = null;

    System.gc();
    Owl.getPersistenceService().startup(new NullOperationMonitor());

    /* Assert Folders */
    CachingDAO dao = (CachingDAO) DynamicDAO.getDAO(IFolderDAO.class);
    root1 = (IFolder) dao.load(rootFolder1Id);
    assertNotNull(root1);
    assertEquals("Root 1", root1.getName());
    assertProperties(root1);

    root2 = (IFolder) dao.load(rootFolder2Id);
    assertNotNull(root2);
    assertEquals("Root 2", root2.getName());
    assertProperties(root2);

    root3 = (IFolder) dao.load(rootFolder3Id);
    assertNotNull(root3);
    assertEquals("Root 3", root3.getName());
    assertProperties(root3);

    subRoot1 = (IFolder) dao.load(subRootFolder1Id);
    assertNotNull(subRoot1);
    assertEquals("Sub Root 1", subRoot1.getName());
    assertProperties(subRoot1);

    subRoot2 = (IFolder) dao.load(subRootFolder2Id);
    assertNotNull(subRoot2);
    assertEquals("Sub Root 2", subRoot2.getName());
    assertProperties(subRoot2);

    subRoot3 = (IFolder) dao.load(subRootFolder3Id);
    assertNotNull(subRoot3);
    assertEquals("Sub Root 3", subRoot3.getName());
    assertProperties(subRoot3);

    subSubRoot1 = (IFolder) dao.load(subSubRootFolder1Id);
    assertNotNull(subSubRoot1);
    assertEquals("Sub Sub Root 1", subSubRoot1.getName());
    assertProperties(subSubRoot1);

    subSubSubRoot1 = (IFolder) dao.load(subSubSubRootFolder1Id);
    assertNotNull(subSubSubRoot1);
    assertEquals("Sub Sub Sub Root 1", subSubSubRoot1.getName());
    assertProperties(subSubSubRoot1);

    /* Assert Bookmarks */
    dao = (CachingDAO) DynamicDAO.getDAO(IBookMarkDAO.class);

    rootBM1 = (IBookMark) dao.load(rootBM1Id);
    assertNotNull(rootBM1);
    assertEquals("Root Bookmark 1", rootBM1.getName());
    assertProperties(rootBM1);

    rootBM2 = (IBookMark) dao.load(rootBM2Id);
    assertNotNull(rootBM2);
    assertEquals("Root Bookmark 2", rootBM2.getName());
    assertProperties(rootBM2);

    subRoot1BM1 = (IBookMark) dao.load(subRoot1BM1Id);
    assertNotNull(subRoot1BM1);
    assertEquals("Sub Root 1 Bookmark 1", subRoot1BM1.getName());
    assertProperties(subRoot1BM1);

    subRoot1BM2 = (IBookMark) dao.load(subRoot1BM2Id);
    assertNotNull(subRoot1BM2);
    assertEquals("Sub Root 1 Bookmark 2", subRoot1BM2.getName());
    assertProperties(subRoot1BM2);

    subRoot2BM1 = (IBookMark) dao.load(subRoot2BM1Id);
    assertNotNull(subRoot2BM1);
    assertEquals("Sub Root 2 Bookmark 1", subRoot2BM1.getName());
    assertProperties(subRoot2BM1);

    subRoot3BM1 = (IBookMark) dao.load(subRoot3BM1Id);
    assertNotNull(subRoot3BM1);
    assertEquals("Sub Root 3 Bookmark 1", subRoot3BM1.getName());
    assertProperties(subRoot3BM1);

    subSubRoot1BM1 = (IBookMark) dao.load(subSubRoot1BM1Id);
    assertNotNull(subSubRoot1BM1);
    assertEquals("Sub Sub Root 1 Bookmark 1", subSubRoot1BM1.getName());
    assertProperties(subSubRoot1BM1);

    subSubSubRoot1BM1 = (IBookMark) dao.load(subSubSubRoot1BM1Id);
    assertNotNull(subSubSubRoot1BM1);
    assertEquals("Sub Sub Sub Root 1 Bookmark 1", subSubSubRoot1BM1.getName());
    assertProperties(subSubSubRoot1BM1);

    /* Assert News Bins */
    dao = (CachingDAO) DynamicDAO.getDAO(INewsBinDAO.class);

    rootNB1 = (INewsBin) dao.load(rootNB1Id);
    assertNotNull(rootNB1);
    assertEquals("Root Newsbin 1", rootNB1.getName());
    assertProperties(rootNB1);

    rootNB2 = (INewsBin) dao.load(rootNB2Id);
    assertNotNull(rootNB2);
    assertEquals("Root Newsbin 2", rootNB2.getName());
    assertProperties(rootNB2);

    subRoot1NB1 = (INewsBin) dao.load(subRoot1NB1Id);
    assertNotNull(subRoot1NB1);
    assertEquals("Sub Root 1 Newsbin 1", subRoot1NB1.getName());
    assertProperties(subRoot1NB1);

    subRoot1NB2 = (INewsBin) dao.load(subRoot1NB2Id);
    assertNotNull(subRoot1NB2);
    assertEquals("Sub Root 1 Newsbin 2", subRoot1NB2.getName());
    assertProperties(subRoot1NB2);

    subRoot2NB1 = (INewsBin) dao.load(subRoot2NB1Id);
    assertNotNull(subRoot2NB1);
    assertEquals("Sub Root 2 Newsbin 1", subRoot2NB1.getName());
    assertProperties(subRoot2NB1);

    subRoot3NB1 = (INewsBin) dao.load(subRoot3NB1Id);
    assertNotNull(subRoot3NB1);
    assertEquals("Sub Root 3 Newsbin 1", subRoot3NB1.getName());
    assertProperties(subRoot3NB1);

    subSubRoot1NB1 = (INewsBin) dao.load(subSubRoot1NB1Id);
    assertNotNull(subSubRoot1NB1);
    assertEquals("Sub Sub Root 1 Newsbin 1", subSubRoot1NB1.getName());
    assertProperties(subSubRoot1NB1);

    subSubSubRoot1NB1 = (INewsBin) dao.load(subSubSubRoot1NB1Id);
    assertNotNull(subSubSubRoot1NB1);
    assertEquals("Sub Sub Sub Root 1 Newsbin 1", subSubSubRoot1NB1.getName());
    assertProperties(subSubSubRoot1NB1);

    /* Assert Search Marks */
    dao = (CachingDAO) DynamicDAO.getDAO(ISearchMarkDAO.class);

View Full Code Here

      IFeed feed = fFactory.createFeed(null, URI.create("1"));
      IBookMark bm = DynamicDAO.save(fFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "Bookmark " + i));
      setProperties(bm);

      INewsBin nb = DynamicDAO.save(fFactory.createNewsBin(null, folder, "Newsbin " + i));
      setProperties(nb);

      ISearchMark sm = DynamicDAO.save(fFactory.createSearchMark(null, folder, "Searchmark " + i));
      setProperties(sm);
View Full Code Here

    input.add(searchmark2);
    input.add(searchmark3);
    input.add(searchmark4);
    input.add(searchmark5);

    INewsBin bin = fFactory.createNewsBin(null, root, "Bin");
    input.add(bin);

    NewsCounter count = new NewsCounter();
    NewsCounterItem item = new NewsCounterItem(1, 0, 0);
    count.put(feed1.getLink().toString(), item);
    ((BookMark) bookmark1).setNewsCounter(count);

    count = new NewsCounter();
    item = new NewsCounterItem(0, 1, 0);
    count.put(feed2.getLink().toString(), item);
    ((BookMark) bookmark2).setNewsCounter(count);

    count = new NewsCounter();
    item = new NewsCounterItem(0, 0, 1);
    count.put(feed3.getLink().toString(), item);
    ((BookMark) bookmark3).setNewsCounter(count);

    INews news = fFactory.createNews(null, fFactory.createFeed(null, new URI("feed4")), new Date());
    news.setState(INews.State.NEW);
    news.setId(System.currentTimeMillis());
    bin.addNews(news);

    /* Group by State */
    {
      fGrouping.setType(BookMarkGrouping.Type.GROUP_BY_STATE);
      EntityGroup[] group = fGrouping.group(input);
View Full Code Here

    news.setLink(new URI("http://www.news.com"));

    DynamicDAO.save(feed);

    IFolder folder = fFactory.createFolder(null, null, "Root");
    INewsBin bin = fFactory.createNewsBin(null, folder, "Bin");

    DynamicDAO.save(folder);

    INews copiedNews = fFactory.createNews(news, bin);
    DynamicDAO.save(copiedNews);
    DynamicDAO.save(bin);

    UndoStack.getInstance().addOperation(new CopyOperation(Collections.singletonList(copiedNews)));

    assertTrue(bin.containsNews(copiedNews));

    UndoStack.getInstance().undo();

    assertEquals(0, bin.getNewsCount(INews.State.getVisible()));

    UndoStack.getInstance().redo();

    assertTrue(bin.containsNews(copiedNews));
  }
View Full Code Here

TOP

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

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.