Package org.rssowl.core.persist.reference

Examples of org.rssowl.core.persist.reference.NewsReference


  private void rememberSelection() {
    IStructuredSelection sel = (IStructuredSelection) fNewsTableControl.getViewer().getSelection();
    if (!sel.isEmpty()) {
      Object obj = sel.getFirstElement();
      if (obj instanceof INews)
        fgSelectionCache.put(fInput.hashCode(), new NewsReference(((INews) obj).getId()));
      else
        fgSelectionCache.remove(fInput.hashCode());
    }
  }
View Full Code Here


      fFactory.createNews(null, feed, new Date());

      Feed savedFeed = (Feed) DynamicDAO.save(feed);
      assertTrue(savedFeed.isIdentical(DynamicDAO.load(IFeed.class, savedFeed.getId())));

      NewsReference news1 = new NewsReference(savedFeed.getNews().get(0).getId());
      NewsReference news2 = new NewsReference(savedFeed.getNews().get(1).getId());
      NewsReference news3 = new NewsReference(savedFeed.getNews().get(2).getId());

      List<INews> news = new ArrayList<INews>();
      news.add(news1.resolve());
      news.add(news2.resolve());

      assertEquals(news1.resolve().getState(), INews.State.NEW);
      assertEquals(news2.resolve().getState(), INews.State.NEW);
      assertEquals(news3.resolve().getState(), INews.State.NEW);

      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          fail("Unexpected Event");
        }

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

        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(2, events.size());
          for (NewsEvent event : events)
            assertEquals(true, event.isRoot());
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      Owl.getPersistenceService().getDAOService().getNewsDAO().setState(news, INews.State.UNREAD, true, false);

      assertEquals(news1.resolve().getState(), INews.State.UNREAD);
      assertEquals(news2.resolve().getState(), INews.State.UNREAD);
      assertEquals(news3.resolve().getState(), INews.State.NEW);

      Owl.getPersistenceService().getDAOService().getNewsDAO().setState(news, INews.State.READ, true, false);

      assertEquals(news1.resolve().getState(), INews.State.READ);
      assertEquals(news2.resolve().getState(), INews.State.READ);
      assertEquals(news3.resolve().getState(), INews.State.NEW);

      Owl.getPersistenceService().getDAOService().getNewsDAO().setState(news, INews.State.DELETED, true, false);

      assertEquals(news1.resolve().getState(), INews.State.DELETED);
      assertEquals(news2.resolve().getState(), INews.State.DELETED);
      assertEquals(news3.resolve().getState(), INews.State.NEW);
    } finally {
      if (newsListener != null)
        DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
  }
View Full Code Here

          }
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      Owl.getPersistenceService().getDAOService().getNewsDAO().setState(Arrays.asList(new INews[] { new NewsReference(news1ID).resolve() }), INews.State.READ, true, false);

      assertEquals(1, service.getUnreadCount(news1.getFeedReference()));
      assertEquals(1, service.getNewCount(news1.getFeedReference()));
      assertEquals(1, service.getUnreadCount(news2.getFeedReference()));
      assertEquals(1, service.getNewCount(news2.getFeedReference()));
View Full Code Here

      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      List<NewsReference> equivalentNewsRefs = guidToNewsRefs.get(newsItem.getGuid());
      if (equivalentNewsRefs != null && !equivalentNewsRefs.isEmpty()) {
        NewsReference newsRef = equivalentNewsRefs.get(0);
        INews resolvedNews = newsRef.resolve();
        if (resolvedNews != null)
          newsItem.setState(resolvedNews.getState());
        else
          logWarning(NLS.bind(Messages.ApplicationServiceImpl_ERROR_STALE_LUCENE_INDEX, newsRef.getId()));
      } else {
        equivalentNewsRefs = linkToNewsRefs.get(newsItem.getLink());
        if (equivalentNewsRefs != null && !equivalentNewsRefs.isEmpty()) {
          NewsReference newsRef = equivalentNewsRefs.get(0);
          INews resolvedNews = newsRef.resolve();
          if (resolvedNews != null)
            newsItem.setState(resolvedNews.getState());
          else
            logWarning(NLS.bind(Messages.ApplicationServiceImpl_ERROR_STALE_LUCENE_INDEX, newsRef.getId()));
        }
      }
    }
  }
View Full Code Here

    List<NewsReference> result = new ArrayList<NewsReference>(getResultCount(states));

    /* Add Read News */
    if (states.contains(INews.State.READ)) {
      for (long id : fMatchingReadNews)
        result.add(new NewsReference(id));
    }

    /* Add Unread News */
    if (states.contains(INews.State.UNREAD) || states.contains(INews.State.UPDATED)) {
      for (long id : fMatchingUnreadUpdatedNews)
        result.add(new NewsReference(id));
    }

    /* Add New News */
    if (states.contains(INews.State.NEW)) {
      for (long id : fMatchingNewNews)
        result.add(new NewsReference(id));
    }

    return result;
  }
View Full Code Here

        }
      };

      DynamicDAO.addEntityListener(INews.class, newsListener);

      NewsReference newsReference1 = new NewsReference(DynamicDAO.save(news1).getId());
      NewsReference newsReference2 = new NewsReference(DynamicDAO.save(news2).getId());
      NewsReference newsReference3 = new NewsReference(DynamicDAO.save(news3).getId());

      assertEquals(INews.State.DELETED, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(0).getState());
      assertEquals(INews.State.DELETED, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(1).getState());
      assertEquals(INews.State.READ, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(2).getState());

      /* Check Deleted News now being Deleted from DB */
      IFeed emptyFeed = fFactory.createFeed(null, new URI("http://www.feed.com"));
      IFeed savedFeed = feedRef.resolve();
      MergeResult mergeResult = savedFeed.mergeAndCleanUp(emptyFeed);
      TestUtils.saveFeed(mergeResult);

      feed = null;
      news1 = null;
      news2 = null;
      news3 = null;
      System.gc();

      /* Asserts follow */
      assertEquals(1, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().size());
      assertNull(DynamicDAO.load(INews.class, newsReference1.getId()));
      assertNull(DynamicDAO.load(INews.class, newsReference2.getId()));
      assertNotNull(DynamicDAO.load(INews.class, newsReference3.getId()));

      for (int i = 0; i < newsUpdatedEvents.length; i++)
        if (!newsUpdatedEvents[i])
          fail("Missing newsUpdated event in NewsListener!");
    } finally {
View Full Code Here

      /* Add */
      final IFeed feed = DynamicDAO.save(fFactory.createFeed(null, new URI("http://www.feed.com")));
      INews news = fFactory.createNews(null, feed, new Date());
      news.setTitle("News");
      final boolean newsEvents[] = new boolean[3];
      final NewsReference newsReference[] = new NewsReference[1];
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertLinkEquals(feed.getLink(), event.getEntity().getFeedReference().getLink());
            newsEvents[0] = true;
          }
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertLinkEquals(feed.getLink(), event.getEntity().getFeedReference().getLink());
            if (newsReference[0].references(event.getEntity()))
              newsEvents[1] = true;
          }
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertLinkEquals(feed.getLink(), event.getEntity().getFeedReference().getLink());
            if (newsReference[0].references(event.getEntity()))
              newsEvents[2] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);
      newsReference[0] = new NewsReference(DynamicDAO.save(news).getId());

      /* Update */
      news = newsReference[0].resolve();
      news.setTitle("News Updated");
      DynamicDAO.save(news);
View Full Code Here

  public void testFlatAttachmentEvents() throws Exception {
    AttachmentListener attachmentListener = null;
    try {
      /* Add */
      FeedReference feedRef = new FeedReference(DynamicDAO.save(fFactory.createFeed(null, new URI("http://www.feed1.com"))).getId());
      NewsReference newsRef = new NewsReference(DynamicDAO.save(fFactory.createNews(null, feedRef.resolve(), new Date())).getId());
      IAttachment attachment = fFactory.createAttachment(null, newsRef.resolve());
      attachment.setLink(new URI("http://www.attachment.com"));
      final boolean attachmentEvents[] = new boolean[3];
      final AttachmentReference attachmentReference[] = new AttachmentReference[1];
      attachmentListener = new AttachmentAdapter() {
        @Override
View Full Code Here

  public void testFlatCategoryEvents() throws Exception {
    CategoryListener categoryListener = null;
    try {
      /* Add */
      FeedReference feedRef = new FeedReference(DynamicDAO.save(fFactory.createFeed(null, new URI("http://www.feed2.com"))).getId());
      NewsReference newsRef = new NewsReference(DynamicDAO.save(fFactory.createNews(null, feedRef.resolve(), new Date())).getId());
      ICategory category1 = fFactory.createCategory(null, feedRef.resolve());
      category1.setName("Category");
      ICategory category2 = fFactory.createCategory(null, newsRef.resolve());
      category2.setName("Category");
      final boolean categoryEvents[] = new boolean[6];
      final CategoryReference categoryReference[] = new CategoryReference[2];
      categoryListener = new CategoryListener() {
        public void entitiesAdded(Set<CategoryEvent> events) {
View Full Code Here

  public void testFlatPersonEvents() throws Exception {
    PersonListener personListener = null;
    try {
      /* Add */
      FeedReference feedRef = new FeedReference(DynamicDAO.save(fFactory.createFeed(null, new URI("http://www.feed4.com"))).getId());
      NewsReference newsRef = new NewsReference(DynamicDAO.save(fFactory.createNews(null, feedRef.resolve(), new Date())).getId());
      IPerson person1 = fFactory.createPerson(null, feedRef.resolve());
      person1.setName("Person1");
      IPerson person2 = fFactory.createPerson(null, newsRef.resolve());
      person2.setName("Person2");
      final boolean personEvents[] = new boolean[6];
      final PersonReference personReference[] = new PersonReference[2];
      personListener = new PersonListener() {
        public void entitiesAdded(Set<PersonEvent> events) {
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.reference.NewsReference

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.