Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INewsBin


    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


    /* Get the parent Folder */
    IFolder parent = fPage.getFolder();

    /* Create the NewsBin */
    INewsBin fNewsbin = factory.createNewsBin(null, parent, name, fPosition, fPosition != null ? true : null);

    /* Copy all Properties from Parent into this Mark */
    Map<String, Serializable> properties = parent.getProperties();
    for (Map.Entry<String, Serializable> property : properties.entrySet())
      fNewsbin.setProperty(property.getKey(), property.getValue());

    DynamicDAO.save(parent);

    return true;
  }
View Full Code Here

    /* Location: Bin */
    if (news.getParentId() > 0) {
      String location = fMapBinIdToLocation.get(news.getParentId());
      if (location == null) {
        NewsBinReference ref = new NewsBinReference(news.getParentId());
        INewsBin bin = ref.resolve();
        location = bin.getName();
        fMapBinIdToLocation.put(news.getParentId(), location);
      }

      return location;
    }
View Full Code Here

    DynamicDAO.save(feed1);
    DynamicDAO.save(feed2);
    DynamicDAO.save(feed3);

    INewsBin rootBin = fFactory.createNewsBin(null, rootFolder, "Root Bin");
    INewsBin subRootBin = fFactory.createNewsBin(null, subFolder, "Sub Root Bin");

    DynamicDAO.save(rootFolder);
    List<INews> copiedNews = new ArrayList<INews>();
    INews news1Copy = fFactory.createNews(news1, rootBin);
    copiedNews.add(news1Copy);
View Full Code Here

   */
  @Test
  public void testBinRemoveNews() throws Exception {
    IFolder root = fFactory.createFolder(null, null, "Root");

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

    DynamicDAO.save(bin);

    IFeed feed = fFactory.createFeed(null, new URI("feed"));
    INews news1 = fFactory.createNews(null, feed, new Date());
    INews news2 = fFactory.createNews(null, feed, new Date());
    INews news3 = fFactory.createNews(null, feed, new Date());

    DynamicDAO.save(feed);

    news1 = fFactory.createNews(news1, bin);
    DynamicDAO.save(news1);
    news2 = fFactory.createNews(news2, bin);
    DynamicDAO.save(news2);
    news3 = fFactory.createNews(news3, bin);
    DynamicDAO.save(news3);

    DynamicDAO.save(bin);

    bin.removeNews(news1);
    ((NewsBin) bin).removeNewsRefs(Arrays.asList(new NewsReference[] { news2.toReference() }));

    List<INews> news = bin.getNews();
    assertEquals(1, news.size());
    assertEquals(news3, news.get(0));
  }
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(COPY_NEWS_ID);
    action.setData(new Long[] { bin.getId() });
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, true, 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());
      assertEquals(0, newsitem.getParentId());
    }

    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());
    }

  }
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() });
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, true, 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());
    }
  }
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() });
    filter.addAction(action);

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

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, true, 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);
    }

    final AtomicInteger listenerCalled = new AtomicInteger();
    SearchFilterAdapter listener = new SearchFilterAdapter() {
      @Override
      public void filterApplied(ISearchFilter f, Collection<INews> news) {
        listenerCalled.incrementAndGet();
      }
    };

    DynamicDAO.addEntityListener(ISearchFilter.class, listener);

    try {
      fAppService.handleFeedReload(bm, feed, null, false, true, new NullProgressMonitor());
    } finally {
      DynamicDAO.removeEntityListener(ISearchFilter.class, listener);
    }

    assertEquals(3, listenerCalled.get());

    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, true, 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

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.