Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INewsBin


    fTypesFactory.createGuid(news, "http://www.link.com", true);
    DynamicDAO.save(feed);

    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    IBookMark bookMark = fTypesFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");
    INewsBin newsBin = fTypesFactory.createNewsBin(null, folder, "NewsBin");
    DynamicDAO.save(folder);

    INews newsCopy = fTypesFactory.createNews(news, newsBin);
    DynamicDAO.save(newsCopy);
    DynamicDAO.save(newsBin);

    assertEquals(1, bookMark.getNewsCount(EnumSet.of(INews.State.NEW)));
    assertEquals(1, newsBin.getNewsCount(EnumSet.of(INews.State.NEW)));

    fNewsDAO.setState(Collections.singleton(newsCopy), INews.State.READ, false, false);

    assertEquals(1, bookMark.getNewsCount(EnumSet.of(INews.State.NEW)));
    assertEquals(0, newsBin.getNewsCount(EnumSet.of(INews.State.NEW)));
  }
View Full Code Here


    fTypesFactory.createGuid(news, "http://www.link.com", true);
    DynamicDAO.save(feed);

    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    fTypesFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");
    INewsBin newsBin = fTypesFactory.createNewsBin(null, folder, "NewsBin");
    DynamicDAO.save(folder);

    INews newsCopy = fTypesFactory.createNews(news, newsBin);
    DynamicDAO.save(newsCopy);
    DynamicDAO.save(newsBin);

    fNewsDAO.setState(Collections.singleton(newsCopy), INews.State.HIDDEN, false, false);
    assertEquals(1, newsBin.getNewsRefs().size());
    assertEquals(1, newsBin.getNewsRefs(EnumSet.of(INews.State.HIDDEN)).size());
    assertEquals(0, newsBin.getNewsRefs(EnumSet.of(INews.State.NEW)).size());
    assertEquals(newsCopy, newsBin.getNews().get(0));

    fNewsDAO.setState(Collections.singleton(newsCopy), INews.State.DELETED, false, false);
    assertEquals(0, newsBin.getNewsRefs().size());
    assertNull(fNewsDAO.load(newsCopy.getId()));
  }
View Full Code Here

    fTypesFactory.createGuid(news, "http://www.link.com", true);
    DynamicDAO.save(feed);

    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    IBookMark mark = fTypesFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");
    INewsBin newsBin = fTypesFactory.createNewsBin(null, folder, "NewsBin");
    DynamicDAO.save(folder);

    INews newsCopy = fTypesFactory.createNews(news, newsBin);
    DynamicDAO.save(newsCopy);
    DynamicDAO.save(newsBin);

    DynamicDAO.delete(mark);
    /*
     * Mark containing the feed was deleted, but feed is not deleted because
     * it's still referenced by a copied news. The feed is hence empty.
     */
    assertEquals(0, feed.getNews().size());
    assertEquals(1, newsBin.getNewsRefs().size());
    assertEquals(newsCopy, newsBin.getNews().get(0));
  }
View Full Code Here

    fTypesFactory.createGuid(news, "http://www.link.com", true);
    DynamicDAO.save(feed);

    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    IBookMark bookMark = fTypesFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "Mark");
    INewsBin newsBin = fTypesFactory.createNewsBin(null, folder, "bin");
    DynamicDAO.save(folder);

    INews newsCopy = fTypesFactory.createNews(news, newsBin);
    DynamicDAO.save(newsCopy);
    DynamicDAO.save(newsBin);
View Full Code Here

    fTypesFactory.createGuid(news, "http://www.link.com", true);
    DynamicDAO.save(feed);

    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    fTypesFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");
    INewsBin newsBin = fTypesFactory.createNewsBin(null, folder, "NewsBin");
    DynamicDAO.save(folder);

    INews newsCopy = fTypesFactory.createNews(news, newsBin);
    DynamicDAO.save(newsCopy);
    DynamicDAO.save(newsBin);
View Full Code Here

   * Tests that deleting a news bin is not sending out folder-deleted events.
   */
  @Test
  public void testDeleteBinIsNotSendindFolderDeleteEvents() {
    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    INewsBin bin = fTypesFactory.createNewsBin(null, folder, "News Bin");
    DynamicDAO.save(folder);

    assertNotNull(DynamicDAO.load(INewsBin.class, bin.getId()));

    final boolean[] bool = new boolean[] { false };

    FolderAdapter folderListener = new FolderAdapter() {
      @Override
      public void entitiesDeleted(Set<FolderEvent> events) {
        bool[0] = true;
      }
    };

    DynamicDAO.addEntityListener(IFolder.class, folderListener);

    DynamicDAO.delete(bin);
    assertNull(DynamicDAO.load(INewsBin.class, bin.getId()));

    DynamicDAO.removeEntityListener(IFolder.class, folderListener);

    assertFalse("Unexpected Folder Event", bool[0]);
  }
View Full Code Here

    Long id = null;
    Attribute idAttribute = newsBinElement.getAttribute(Attributes.ID.get(), RSSOWL_NS);
    if (idAttribute != null)
      id = Long.valueOf(idAttribute.getValue());

    INewsBin newsbin = Owl.getModelFactory().createNewsBin(null, folder, name);

    /* Assign old ID value */
    if (id != null)
      newsbin.setProperty(ID_KEY, id);

    /* Recursively Interpret Children */
    List<?> children = newsBinElement.getChildren();
    for (Iterator<?> iter = children.iterator(); iter.hasNext();) {
      Element child = (Element) iter.next();
View Full Code Here

  public void testVisitedNewsBin() throws Exception {

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

    INewsBin bin = DynamicDAO.save(fFactory.createNewsBin(null, folder, "News Bin"));

    IFeed feed = DynamicDAO.save(fFactory.createFeed(null, URI.create("http://www.rssowl.org")));
    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);

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

    DynamicDAO.save(bin);

    NewsBinReference binRef = new NewsBinReference(bin.getId());
    int popularity = bin.getPopularity();
    Date lastVisitDate = bin.getLastVisitDate();

    if (lastVisitDate == null) {
      lastVisitDate = new Date();
    }
    Thread.sleep(100);

    INewsBinDAO dao = DynamicDAO.getDAO(INewsBinDAO.class);
    dao.visited(bin);
    bin = null;
    System.gc();

    bin = binRef.resolve();
    assertEquals(popularity + 1, bin.getPopularity());
    assertTrue(bin.getLastVisitDate().compareTo(lastVisitDate) > 0);
    assertTrue(bin.getLastVisitDate().compareTo(new Date()) < 0);
    assertEquals(3, bin.getNews().size());

    bin = null;
    System.gc();

    bin = binRef.resolve();
    dao.visited(bin);
    dao.visited(bin);
    dao.visited(bin);

    bin = null;
    System.gc();

    bin = binRef.resolve();
    assertEquals(3, bin.getNews().size());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testStateChangeFromNewToUnreadToHiddenInBin() throws Exception {
    IFolder root = fFactory.createFolder(null, null, "Root");
    INewsBin newsBin = fFactory.createNewsBin(null, root, "Bin");

    DynamicDAO.save(root);

    IFeed feed = fFactory.createFeed(null, new URI("http://www.foo.com"));
    INews news = fFactory.createNews(null, feed, new Date());

    DynamicDAO.save(feed);

    INews copiedNews = fFactory.createNews(news, newsBin);
    copiedNews.setState(INews.State.UNREAD);

    DynamicDAO.save(copiedNews);
    DynamicDAO.save(newsBin);

    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singleton(copiedNews), INews.State.HIDDEN, false, false);

    assertEquals(0, newsBin.getNews(INews.State.getVisible()).size());
  }
View Full Code Here

      IFeed feed = fFactory.createFeed(null, new URI("feed"));
      DynamicDAO.save(feed);

      IBookMark bookmark = fFactory.createBookMark(null, root, new FeedLinkReference(feed.getLink()), "Bookmark");

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

      ISearchMark searchMark = fFactory.createSearchMark(null, root, "Search");
      ISearchField field = fFactory.createSearchField(INews.TITLE, INews.class.getName());
      searchMark.addSearchCondition(fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "Foo"));

      DynamicDAO.save(root);

      listener = new SearchConditionListener() {

        public void entitiesUpdated(Set<SearchConditionEvent> events) {
          fail("Unexpected Event");
        }

        public void entitiesDeleted(Set<SearchConditionEvent> events) {
          fail("Unexpected Event");
        }

        public void entitiesAdded(Set<SearchConditionEvent> events) {
          fail("Unexpected Event");
        }
      };
      DynamicDAO.addEntityListener(ISearchCondition.class, listener);

      childFolder.setName("Other");
      DynamicDAO.save(childFolder);

      bookmark.setName("Other");
      DynamicDAO.save(bookmark);

      bin.setName("Other");
      DynamicDAO.save(bin);
    } finally {
      DynamicDAO.removeEntityListener(ISearchCondition.class, listener);
    }
  }
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.