Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INewsBin


    return false;
  }

  private void perfromNewsDrop(List<?> draggedObjects) {
    int operation = getCurrentOperation();
    INewsBin dropTarget = (INewsBin) getCurrentTarget();

    new MoveCopyNewsToBinAction(new StructuredSelection(draggedObjects), dropTarget, operation == DND.DROP_MOVE).run();
  }
View Full Code Here


        position = (IMark) selectedFolderChild;
      }

      NewNewsBinAction action = new NewNewsBinAction(getShell(), folder, position);
      action.run(null);
      INewsBin newsbin = action.getNewsbin();
      if (newsbin != null) {
        fFilteredTree.getPatternFilter().setPattern(""); //$NON-NLS-1$
        fFilteredTree.getFilterControl().setText(""); //$NON-NLS-1$
        fViewer.refresh();
        fViewer.expandAll();
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

  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

    sm.addSearchCondition(sc1);
    sm.addSearchCondition(sc2);
    sm.addSearchCondition(sc3);

    /* News Bin with News */
    INewsBin bin = fFactory.createNewsBin(null, folder, "NewsBin");
    DynamicDAO.save(folder);
    INews newsCopy = fFactory.createNews(news, bin);
    DynamicDAO.save(newsCopy);
    DynamicDAO.save(bin);

View Full Code Here

    assertEquals(1, bins.getChildren().size());
    IFolderChild next = bins.getChildren().iterator().next();
    assertEquals("Bin A", next.getName());
    assertTrue(next instanceof INewsBin);

    INewsBin binA = (INewsBin) next;

    children = secondSet.getChildren();
    assertEquals(4, children.size());
    IFolder folderB = null;
    IBookMark macOsHints = null;
    INewsBin binC = null;
    ISearchMark searchA = null;
    for (IFolderChild foo : children) {
      if (foo instanceof IFolder && "Folder B".equals(foo.getName()))
        folderB = (IFolder) foo;
      else if (foo instanceof IBookMark && "MacOSXHints.com".equals(foo.getName()))
        macOsHints = (IBookMark) foo;
      else if (foo instanceof INewsBin && "Bin C".equals(foo.getName()))
        binC = (INewsBin) foo;
      else if (foo instanceof ISearchMark && "Search A".equals(foo.getName()))
        searchA = (ISearchMark) foo;
    }

    assertEquals(2, searchA.getSearchConditions().size());
    List<ISearchCondition> conditions = searchA.getSearchConditions();
    for (ISearchCondition condition : conditions) {
      if (condition.getField().getId() == INews.LOCATION) {
        List<IFolderChild> entities = CoreUtils.toEntities((Long[][]) condition.getValue());
        assertEquals(1, entities.size());
        assertTrue(entities.contains(folderA));
      }
    }

    assertNotNull(folderB);
    assertNotNull(macOsHints);
    assertNotNull(binC);
    assertNotNull(searchA);

    children = folderB.getChildren();
    IBookMark golemMark = null;
    IFolder bins2 = null;
    for (IFolderChild foo : children) {
      if (foo instanceof IBookMark && "Golem.de".equals(foo.getName()))
        golemMark = (IBookMark) foo;
      else if (foo instanceof IFolder && "Bins".equals(foo.getName()))
        bins2 = (IFolder) foo;
      else
        fail();
    }

    assertNotNull(golemMark);
    assertNotNull(bins2);

    assertEquals(1, bins2.getChildren().size());
    next = bins2.getChildren().iterator().next();
    assertEquals("Bin B", next.getName());
    assertTrue(next instanceof INewsBin);

    INewsBin binB = (INewsBin) next;

    assertEquals(6, count(Label.class.getName(), elements));
    assertEquals(1, count(SearchFilter.class.getName(), elements));
    assertTrue(count(Preference.class.getName(), elements) > 0);

    ISearchFilter filter = null;
    for (IEntity element : elements) {
      if (element instanceof ISearchFilter) {
        filter = (ISearchFilter) element;
      }
    }

    assertNotNull(filter);

    ILabel label = null;
    for (IEntity element : elements) {
      if (element instanceof ILabel && "RSSOwl".equals(((ILabel) element).getName())) {
        label = (ILabel) element;
      }
    }

    assertNotNull(label);

    List<IFilterAction> actions = filter.getActions();
    assertEquals(2, actions.size());
    for (IFilterAction action : actions) {
      if (MoveNewsAction.ID.equals(action.getActionId())) {
        Object data = action.getData();
        assertTrue(data instanceof Long[]);
        assertEquals(binB.getId().longValue(), ((Long[]) data)[0].longValue());
      } else if (LabelNewsAction.ID.equals(action.getActionId())) {
        Object data = action.getData();
        assertEquals(label.getId().longValue(), ((Long) data).longValue());
      } else
        fail();
View Full Code Here

    assertNotNull(bookmark1);
    assertEquals("http://feed1", bookmark1.getFeedLinkReference().getLink().toString());
    if (useBackup)
      assertProperties(Owl.getPreferenceService().getEntityScope(bookmark1));

    INewsBin bin = null;
    for (IMark mark : defaultMarks) {
      if (mark instanceof INewsBin && mark.getName().equals("Bin 1"))
        bin = (INewsBin) mark;
    }
View Full Code Here

        assertEquals(MoveNewsAction.ID, filter.getActions().get(1).getActionId());
        data = filter.getActions().get(1).getData();
        assertNotNull(data);
        assertEquals(true, data instanceof Long[]);
        assertEquals(1, ((Long[]) data).length);
        INewsBin bin = DynamicDAO.getDAO(INewsBinDAO.class).load(((Long[]) data)[0].longValue());
        assertNotNull(bin);
        assertEquals(fNewsBin.getName(), bin.getName());

        assertEquals("org.rssowl.ui.PlaySoundAction", filter.getActions().get(2).getActionId());
        data = filter.getActions().get(2).getData();
        assertNotNull(data);
        assertEquals("C:\\ProgramData\\Microsoft\\Windows & Help\\Start Menu", data);
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.