Package org.rssowl.core.internal.persist

Examples of org.rssowl.core.internal.persist.Folder


    /* Delete previously stored favicons */
    for (int i = 0; i < 5; i++)
      OwlUI.deleteImage(i);

    IFeed feed = new Feed(new URI("http://www.rssowl.org/node/feed"));
    IFolder root = new Folder(null, null, "Root");
    IBookMark bookmark = new BookMark(null, root, new FeedLinkReference(feed.getLink()), "Bookmark");
    root.addMark(bookmark, null, false);

    feed = DynamicDAO.save(feed);
    DynamicDAO.save(root);

    assertEquals(null, OwlUI.getFavicon(bookmark));
View Full Code Here


    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());
  }

  private ITreeNode getStartingNode(boolean beginFromRoot) throws URISyntaxException {
    IFolder root = new Folder(null, null, "Root");
    FeedLinkReference feed = new FeedLinkReference(new URI("http://www.link.com"));

    /* Sub Root 1 */
    IFolder subRootFolder1 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder1, null, false);

    IFolder subRoot1Folder1 = new Folder(null, subRootFolder1, "SubRoot1Folder1");
    subRootFolder1.addFolder(subRoot1Folder1, null, false);

    subRoot1Folder1.addFolder(new Folder(null, subRoot1Folder1, "SubRoot11Folder1"), null, false);
    subRoot1Folder1.addMark(new BookMark(null, subRoot1Folder1, feed, "SubRoot11Mark1"), null, false);

    subRootFolder1.addMark(new BookMark(null, subRootFolder1, feed, "SubRoot1Mark1"), null, false);
    subRootFolder1.addMark(new BookMark(null, subRootFolder1, feed, "SubRoot1Mark2"), null, false);

    /* Sub Root 2 */
    IFolder subRootFolder2 = new Folder(null, root, "SubRootFolder2");
    root.addFolder(subRootFolder2, null, false);

    subRootFolder2.addMark(new BookMark(null, subRootFolder2, feed, "SubRoot2Mark1"), null, false);

    IFolder subRoot2Folder1 = new Folder(null, subRootFolder2, "SubRoot2Folder1");
    subRootFolder2.addFolder(subRoot2Folder1, null, false);

    IFolder subRoot21Folder1 = new Folder(null, subRoot2Folder1, "SubRoot21Folder1");
    subRoot2Folder1.addFolder(subRoot21Folder1, null, false);

    IBookMark subRoot211Mark1 = new BookMark(null, subRoot21Folder1, feed, "SubRoot211Mark1");
    subRoot21Folder1.addMark(subRoot211Mark1, null, false);

    /* Sub Root 3 */
    IFolder subRootFolder3 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder3, null, false);

    IFolder subRoot3Folder1 = new Folder(null, subRootFolder3, "SubRoot3Folder1");
    subRootFolder3.addFolder(subRoot3Folder1, null, false);

    subRoot3Folder1.addMark(new BookMark(null, subRoot3Folder1, feed, "SubRoot31Mark1"), null, false);

    return beginFromRoot ? new ModelTreeNode(root) : new ModelTreeNode(subRoot211Mark1);
  }
View Full Code Here

  private List<ITask> getReloadFeedsTasks(boolean withRetention) {
    List<ITask> tasks = new ArrayList<ITask>();
    Random rand = new Random();

    /* Create Folder with all Bookmarks */
    IFolder rootFolder = new Folder(null, null, "Root");
    for (int i = 1; i < FEEDS + 1; i++) {
      try {
        URI feedLink = fPluginLocation.resolve("data/performance/" + i + ".xml").toURL().toURI();

        IFeed feed = new Feed(feedLink);

        if (withRetention) {
          for (int j = 0; j < 10; j++) {
            INews news = new News(feed);
            news.setTitle("Random Title " + j);
            news.setDescription(getLongDecription());
            news.setLink(new URI("http://www." + System.currentTimeMillis() + ".com/" + rand.nextInt(10000) + j));
            news.setComments("Comments");
            news.setState(INews.State.READ);
            feed.addNews(news);
          }
        }

        feed = DynamicDAO.save(feed);

        IBookMark bookmark = new BookMark(null, rootFolder, new FeedLinkReference(feed.getLink()), "Bookmark");

        if (withRetention)
          Owl.getPreferenceService().getEntityScope(bookmark).putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);

        rootFolder.addMark(bookmark, null, false);
        DynamicDAO.save(rootFolder);
      } catch (Exception e) {
        Activator.getDefault().logError(e.getMessage(), e);
      }
    }

    /* Create Tasks */
    List<IMark> marks = rootFolder.getMarks();
    for (IMark mark : marks) {
      if (mark instanceof IBookMark) {
        final IBookMark bookmark = (IBookMark) mark;

        tasks.add(new TaskAdapter() {
View Full Code Here

  /**
   * Tests adding, updating and getting a folder with no parent.
   */
  @Test
  public void testAddUpdateAndGetFolder() {
    final Folder initialFolder = (Folder) createFolder();
    final Folder[] updatedFolder = new Folder[1];
    final boolean[] folderAddedCalled = new boolean[] { false };
    final boolean[] folderUpdatedCalled = new boolean[] { false };
    FolderListener folderListener = null;
    try {
      folderListener = new FolderAdapter() {
        @Override
        public void entitiesAdded(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            try {
              folderAddedCalled[0] = true;
              Folder dbFolder = (Folder) event.getEntity();
              initialFolder.setId(dbFolder.getId());
              assertTrue(NOT_IDENTICAL_MESSAGE, initialFolder.isIdentical(dbFolder));
              dbFolder.setBlogrollLink(createURI("http://www.newuri.com"));
              dbFolder.setName("New name");
              updatedFolder[0] = dbFolder;
              DynamicDAO.save(dbFolder);
            } catch (PersistenceException e) {
              fail(e.getMessage());
            }
          }
        }

        @Override
        public void entitiesUpdated(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            folderUpdatedCalled[0] = true;
            Folder dbFolder = (Folder) event.getEntity();
            assertTrue(updatedFolder[0].isIdentical(dbFolder));
          }
        }
      };
      DynamicDAO.addEntityListener(IFolder.class, folderListener);
View Full Code Here

        @Override
        public void entitiesAdded(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            try {
              folderAddedCalled[0] = true;
              Folder dbFolder = (Folder) event.getEntity();
              initialFolder[0].setId(dbFolder.getId());
              assertTrue(initialFolder[0].isIdentical(dbFolder));
              dbFolder.setBlogrollLink(createURI("http://www.newuri.com"));
              updatedFolder[0] = dbFolder;
              DynamicDAO.save(dbFolder);
            } catch (PersistenceException e) {
              fail(e.getMessage());
            }
          }
        }

        @Override
        public void entitiesUpdated(Set<FolderEvent> events) {
          for (FolderEvent event : events) {
            /* Ignore event from parent */
            if (!folderName[0].equals(event.getEntity().getName())) {
              return;
            }
            folderUpdatedCalled[0] = true;
            Folder dbFolder = (Folder) event.getEntity();
            assertTrue(updatedFolder[0].isIdentical(dbFolder));
          }
        }
      };
      DynamicDAO.addEntityListener(IFolder.class, folderListener);
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public void testHasChildRelation() throws Exception {
    IFolder root = new Folder(null, null, "Root");
    FeedLinkReference feed = new FeedLinkReference(new URI("http://www.link.com"));

    /* Sub Root 1 */
    IFolder subRootFolder1 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder1, null, false);

    IFolder subRoot1Folder1 = new Folder(null, subRootFolder1, "SubRoot1Folder1");
    subRootFolder1.addFolder(subRoot1Folder1, null, false);

    IFolder subRoot11Folder1 = new Folder(null, subRoot1Folder1, "SubRoot11Folder1");
    subRoot1Folder1.addFolder(subRoot11Folder1, null, false);

    IBookMark subRoot11Mark1 = new BookMark(null, subRoot1Folder1, feed, "SubRoot11Mark1");
    subRoot1Folder1.addMark(subRoot11Mark1, null, false);

View Full Code Here

  private List<ITask> getRealWorldReloadTasks(String feedDirectory) {
    List<ITask> tasks = new ArrayList<ITask>();

    /* Create Folder with all Bookmarks */
    IFolder rootFolder = new Folder(null, null, "Root");
    for (int i = 1; i < FEEDS + 1; i++) {
      try {
        File file = new File(feedDirectory, i + ".xml");
        if (!file.exists())
          continue;

        URI feedLink = file.toURI();

        IFeed feed = new Feed(feedLink);

        feed = DynamicDAO.save(feed);

        IBookMark bookmark = new BookMark(null, rootFolder, new FeedLinkReference(feed.getLink()), "Bookmark");
        IPreferenceScope entityScope = Owl.getPreferenceService().getEntityScope(bookmark);
        entityScope.putInteger(DefaultPreferences.DEL_NEWS_BY_COUNT_VALUE, 50);
        rootFolder.addMark(bookmark, null, false);
        DynamicDAO.save(rootFolder);
      } catch (Exception e) {
        Activator.getDefault().logError(e.getMessage(), e);
      }
    }

    /* Create Tasks */
    List<IMark> marks = rootFolder.getMarks();
    for (IMark mark : marks) {
      if (mark instanceof IBookMark) {
        final IBookMark bookmark = (IBookMark) mark;

        tasks.add(new TaskAdapter() {
View Full Code Here

  private List<ITask> getReloadFeedsTasks(boolean withRetention) {
    List<ITask> tasks = new ArrayList<ITask>();
    Random rand = new Random();

    /* Create Folder with all Bookmarks */
    IFolder rootFolder = new Folder(null, null, "Root");
    for (int i = 1; i < FEEDS + 1; i++) {
      try {
        URI feedLink = fPluginLocation.resolve("data/performance/" + i + ".xml").toURL().toURI();

        IFeed feed = new Feed(feedLink);

        if (withRetention) {
          for (int j = 0; j < 10; j++) {
            INews news = new News(feed);
            news.setTitle("Random Title " + j);
            news.setDescription(getLongDecription());
            news.setLink(new URI("http://www." + System.currentTimeMillis() + ".com/" + rand.nextInt(10000) + j));
            news.setComments("Comments");
            news.setState(INews.State.READ);
            feed.addNews(news);
          }
        }

        feed = DynamicDAO.save(feed);

        IBookMark bookmark = new BookMark(null, rootFolder, new FeedLinkReference(feed.getLink()), "Bookmark");

        if (withRetention)
          Owl.getPreferenceService().getEntityScope(bookmark).putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);

        rootFolder.addMark(bookmark, null, false);
        DynamicDAO.save(rootFolder);
      } catch (Exception e) {
        Activator.getDefault().logError(e.getMessage(), e);
      }
    }

    /* Create Tasks */
    List<IMark> marks = rootFolder.getMarks();
    for (IMark mark : marks) {
      if (mark instanceof IBookMark) {
        final IBookMark bookmark = (IBookMark) mark;

        tasks.add(new TaskAdapter() {
View Full Code Here

    assertEquals(subRoot31Mark1, t.nextNode().getData());
    assertEquals(null, t.nextNode());
  }

  private ITreeNode getStartingNode(boolean beginFromRoot) throws URISyntaxException {
    IFolder root = new Folder(null, null, "Root");
    FeedLinkReference feed = new FeedLinkReference(new URI("http://www.link.com"));

    /* Sub Root 1 */
    IFolder subRootFolder1 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder1, null, false);

    IFolder subRoot1Folder1 = new Folder(null, subRootFolder1, "SubRoot1Folder1");
    subRootFolder1.addFolder(subRoot1Folder1, null, false);

    subRoot1Folder1.addFolder(new Folder(null, subRoot1Folder1, "SubRoot11Folder1"), null, false);
    subRoot1Folder1.addMark(new BookMark(null, subRoot1Folder1, feed, "SubRoot11Mark1"), null, false);

    subRootFolder1.addMark(new BookMark(null, subRootFolder1, feed, "SubRoot1Mark1"), null, false);
    subRootFolder1.addMark(new BookMark(null, subRootFolder1, feed, "SubRoot1Mark2"), null, false);

    /* Sub Root 2 */
    IFolder subRootFolder2 = new Folder(null, root, "SubRootFolder2");
    root.addFolder(subRootFolder2, null, false);

    subRootFolder2.addMark(new BookMark(null, subRootFolder2, feed, "SubRoot2Mark1"), null, false);

    IFolder subRoot2Folder1 = new Folder(null, subRootFolder2, "SubRoot2Folder1");
    subRootFolder2.addFolder(subRoot2Folder1, null, false);

    IFolder subRoot21Folder1 = new Folder(null, subRoot2Folder1, "SubRoot21Folder1");
    subRoot2Folder1.addFolder(subRoot21Folder1, null, false);

    IBookMark subRoot211Mark1 = new BookMark(null, subRoot21Folder1, feed, "SubRoot211Mark1");
    subRoot21Folder1.addMark(subRoot211Mark1, null, false);

    /* Sub Root 3 */
    IFolder subRootFolder3 = new Folder(null, root, "SubRootFolder1");
    root.addFolder(subRootFolder3, null, false);

    IFolder subRoot3Folder1 = new Folder(null, subRootFolder3, "SubRoot3Folder1");
    subRootFolder3.addFolder(subRoot3Folder1, null, false);

    subRoot3Folder1.addMark(new BookMark(null, subRoot3Folder1, feed, "SubRoot31Mark1"), null, false);

    return beginFromRoot ? new ModelTreeNode(root) : new ModelTreeNode(subRoot211Mark1);
  }
View Full Code Here

    /* Delete previously stored favicons */
    for (int i = 0; i < 5; i++)
      OwlUI.deleteImage(i);

    IFeed feed = new Feed(new URI("http://www.rssowl.org/node/feed"));
    IFolder root = new Folder(null, null, "Root");
    IBookMark bookmark = new BookMark(null, root, new FeedLinkReference(feed.getLink()), "Bookmark");
    root.addMark(bookmark, null, false);

    feed = DynamicDAO.save(feed);
    DynamicDAO.save(root);

    assertEquals(null, OwlUI.getFavicon(bookmark));
View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.Folder

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.