Package org.rssowl.core.model.types

Examples of org.rssowl.core.model.types.INews


      /* First add some Types */
      IFeed feed1 = fTypesFactory.createFeed(null, new URL("http://www.feed.com/feed1.xml"));
      IFeed feed2 = fTypesFactory.createFeed(null, new URL("http://www.feed.com/feed2.xml"));

      INews news1 = fTypesFactory.createNews(null, feed1, new Date(System.currentTimeMillis()));
      news1.setDescription("News #1 Description");
      news1.setLink(new URI("http://www.news.com/news1.html"));

      INews news2 = fTypesFactory.createNews(null, feed1, new Date(System.currentTimeMillis()));
      news2.setDescription("News #2 Description");
      news2.setLink(new URI("http://www.news.com/news2.html"));

      INews news3 = fTypesFactory.createNews(null, feed1, new Date(System.currentTimeMillis()));
      news3.setDescription("News #3 Description");
      news3.setLink(new URI("http://www.news.com/news3.html"));

      INews news4 = fTypesFactory.createNews(null, feed2, new Date(System.currentTimeMillis()));
      news4.setDescription("News #4 Description");
      news4.setLink(new URI("http://www.news.com/news4.html"));

      INews news5 = fTypesFactory.createNews(null, feed2, new Date(System.currentTimeMillis()));
      news5.setDescription("News #5 Description Foo Bar");
      news5.setLink(new URI("http://www.news.com/news5.html"));

      INews news6 = fTypesFactory.createNews(null, feed2, new Date(System.currentTimeMillis()));
      news6.setLink(new URI("http://www.news.com/news6.html"));

      fDao.saveFeed(feed1);
      fDao.saveFeed(feed2);

      // TODO Replace this by a event-based solution if that becomes available
      Thread.sleep(500);

      /* 1. SearchCondition: News coming from Feed that contains "feed2.xml" */
      ISearchField field1 = fTypesFactory.createSearchField(IFeed.LINK, IFeed.class);
      ISearchCondition cond1 = fTypesFactory.createSearchCondition(field1, SearchSpecifier.CONTAINS, "feed2.xml", true);
      conditions.add(cond1);

      /* 2. SearchCondition: News Description does not contain "Foo" */
      ISearchField field2 = fTypesFactory.createSearchField(INews.DESCRIPTION, INews.class);
      ISearchCondition cond2 = fTypesFactory.createSearchCondition(field2, SearchSpecifier.CONTAINS_NOT, "Foo", true);
      conditions.add(cond2);

      /* 3. SearchCondition: News State is NEW */
      ISearchField field3 = fTypesFactory.createSearchField(INews.STATE, INews.class);
      ISearchCondition cond3 = fTypesFactory.createSearchCondition(field3, SearchSpecifier.IS, State.NEW.name(), true);
      conditions.add(cond3);

      List<ISearchHit<NewsReference>> results = fModelSearch.searchNews(conditions);
      assertEquals(2, results.size());

      boolean resultsMatch[] = new boolean[2];
      for (ISearchHit<NewsReference> searchHit : results) {
        INews news = searchHit.getResult().resolve();

        if (news.getTitle().equals(news4.getTitle()))
          resultsMatch[0] = true;

        else if (news.getTitle().equals(news6.getTitle()))
          resultsMatch[1] = true;
      }

      for (boolean element : resultsMatch)
        assertTrue("Missing a result match", element);
View Full Code Here


      List<ISearchCondition> conditions = new ArrayList<ISearchCondition>();

      /* First add some Types */
      IFeed feed = fTypesFactory.createFeed(null, new URL("http://www.feed.com/feed.xml"));

      INews news1 = fTypesFactory.createNews(null, feed, new Date(System.currentTimeMillis()));
      news1.setLink(new URI("http://www.news.com/news1.html"));

      INews news2 = fTypesFactory.createNews(null, feed, new Date(System.currentTimeMillis()));
      news2.setLink(new URI("http://www.news.com/news2.html"));

      INews news3 = fTypesFactory.createNews(null, feed, new Date(System.currentTimeMillis()));
      news3.setLink(new URI("http://www.news.com/news3.html"));

      fTypesFactory.createAttachment(null, news1).setType("text/html");
      fTypesFactory.createAttachment(null, news2).setType("text/xml");
      fTypesFactory.createAttachment(null, news3).setType("audio/mp3");

      fDao.saveFeed(feed);

      // TODO Replace this by a event-based solution if that becomes available
      Thread.sleep(500);

      /* 1. SearchCondition: News has Attachment with Type "audio/mp3" */
      ISearchField field1 = fTypesFactory.createSearchField(IAttachment.TYPE, IAttachment.class);
      ISearchCondition cond1 = fTypesFactory.createSearchCondition(field1, SearchSpecifier.IS, "audio/mp3", false);
      conditions.add(cond1);

      List<ISearchHit<NewsReference>> results = fModelSearch.searchNews(conditions);
      assertEquals(1, results.size());

      boolean resultsMatch[] = new boolean[1];
      for (ISearchHit<NewsReference> searchHit : results) {
        INews news = searchHit.getResult().resolve();

        if (news.getTitle().equals(news3.getTitle()))
          resultsMatch[0] = true;
      }

      for (boolean element : resultsMatch)
        assertTrue("Missing a result match", element);
View Full Code Here

    assertNotNull(feed.getImage());
    assertEquals(new URI("rss_image.url"), feed.getImage().getUrl());

    assertEquals(3, feed.getNews().size());
    INews news1 = feed.getNews().get(0);

    assertEquals("rss_item1.title", news1.getTitle());
    assertEquals(new URI("rss_item1.link"), news1.getLink());

    assertNotNull(news1.getAuthor());
    assertEquals("rss_item1.author", news1.getAuthor().getName());

    assertEquals("rss_item1.description", news1.getDescription());

    assertNotNull(news1.getPublishDate());

    assertEquals("rss_item1.guid", news1.getGuid().getValue());
    assertEquals("rss_item1.comments", news1.getComments());

    assertEquals(1, news1.getAttachments().size());
    assertEquals(new URI("rss_item1.enclosure.url"), news1.getAttachments().get(0).getUrl());
    assertEquals("rss_item1.enclosure.type", news1.getAttachments().get(0).getType());
    assertEquals(2500000, news1.getAttachments().get(0).getLength());

    assertEquals(1, news1.getCategories().size());
    assertEquals("rss_item1.category", news1.getCategories().get(0).getName());
    assertEquals("rss_item1.category.domain", news1.getCategories().get(0).getDomain());

    assertNotNull(news1.getSource());
    assertEquals("rss_item1.source", news1.getSource().getName());
    assertEquals(new URI("rss_item1.source.url"), news1.getSource().getUrl());
  }
View Full Code Here

    assertEquals("rdf_image.title", feed.getImage().getTitle());
    assertEquals(new URI("rdf_image.link"), feed.getImage().getLink());

    assertEquals(3, feed.getNews().size());

    INews news1 = feed.getNews().get(0);
    assertEquals("rdf_item1.title", news1.getTitle());
    assertEquals(new URI("rdf_item1.link"), news1.getLink());
    assertEquals("rdf_item1.description", news1.getDescription());

    assertNotNull(news1.getGuid());
    assertEquals("rdf_item1.identifier", news1.getGuid().getValue());

    assertNotNull(news1.getPublishDate());

    assertNotNull(news1.getAuthor());
    assertEquals("rdf_item1.publisher", news1.getAuthor().getName());

    assertNotNull(news1.getSource());
    assertEquals(new URI("rdf_item1.source"), news1.getSource().getUrl());
  }
View Full Code Here

  public void testIsNewsStateChange() throws Exception {
    IFeed feed = fFactory.createFeed(Long.valueOf(0L), new URL("http://www.rssowl.org"));

    Set<ModelEvent> events = new HashSet<ModelEvent>();

    INews newNews = fFactory.createNews(0L, feed, new Date());
    newNews.setState(INews.State.NEW);

    INews unreadNews = fFactory.createNews(1L, feed, new Date());
    unreadNews.setState(INews.State.UNREAD);

    INews readNews = fFactory.createNews(2L, feed, new Date());
    readNews.setState(INews.State.READ);

    INews hiddenNews = fFactory.createNews(3L, feed, new Date());
    hiddenNews.setState(INews.State.HIDDEN);

    INews deletedNews = fFactory.createNews(4L, feed, new Date());
    deletedNews.setState(INews.State.DELETED);

    INews readNews2 = fFactory.createNews(5L, feed, new Date());
    readNews2.setState(INews.State.READ);

    INews unreadNews2 = fFactory.createNews(6L, feed, new Date());
    unreadNews2.setState(INews.State.UNREAD);

    INews hiddenNews2 = fFactory.createNews(7L, feed, new Date());
    hiddenNews2.setState(INews.State.HIDDEN);

    NewsEvent event1 = new NewsEvent(newNews, newNews, true);
    NewsEvent event2 = new NewsEvent(newNews, unreadNews, true);
    NewsEvent event3 = new NewsEvent(newNews, readNews, true);
    NewsEvent event4 = new NewsEvent(unreadNews, readNews2, true);
View Full Code Here

      return;
    }
    final News initialNews = (News) createNews(feed);
    initialNews.setState(State.NEW);
    initialNews.setGuid(null);
    INews newsItem = null;
    NewsReference newsRef = null;
    try {
      newsItem = fModelDAO.saveNews(initialNews);
      newsRef = new NewsReference(newsItem.getId());
    } catch (PersistenceException e) {
      fail(e.getMessage());
      return;
    }
    try {
      List<INews> newsList = new ArrayList<INews>();
      newsList.add(newsItem);
      fAppLayer.setNewsState(newsList, State.UPDATED, true, false);
      INews news = newsRef.resolve();
      assertEquals(State.UPDATED, news.getState());
      fAppLayer.setNewsState(newsList, State.DELETED, true, false);
      news = newsRef.resolve();
      assertEquals(State.DELETED, news.getState());
      fAppLayer.setNewsState(newsList, State.HIDDEN, true, false);
      news = newsRef.resolve();
      assertEquals(State.HIDDEN, news.getState());
      fAppLayer.setNewsState(newsList, State.READ, true, false);
      news = newsRef.resolve();
      assertEquals(State.READ, news.getState());
      fAppLayer.setNewsState(newsList, State.UNREAD, true, false);
      news = newsRef.resolve();
      assertEquals(State.UNREAD, news.getState());
      fAppLayer.setNewsState(newsList, State.NEW, true, false);
      news = newsRef.resolve();
      assertEquals(State.NEW, news.getState());
      // Make sure it doesn't change when we set it to the same
      fAppLayer.setNewsState(newsList, State.NEW, true, false);
      news = newsRef.resolve();
      assertEquals(State.NEW, news.getState());
     
      fModelDAO.deleteNews(newsRef);
      fModelDAO.deleteFeed(new FeedReference(feed.getId()));
    } catch (PersistenceException e) {
      fail(e.getMessage());
View Full Code Here

      }

      List<INews> changedNews = new ArrayList<INews>(newsList.size());

      for (INews news : newsList) {
        INews oldNews = fDb.ext().peekPersisted(news, 2, true);
        if (oldNews == null || !checkIfNewsIsIdentical || !news.isIdentical(oldNews)) {
          ModelEvent eventTemplate = new NewsEvent(oldNews, news, true);
          DBHelper.putEventTemplate(eventTemplate);
          changedNews.add(news);
        }
View Full Code Here

    ModelEvent feedEventTemplate = new FeedEvent(feed, true);
    DBHelper.putEventTemplate(feedEventTemplate);
    List<INews> changedNews = new ArrayList<INews>(feed.getNews().size());
   
    for (INews news : feed.getNews()) {
      INews oldNews = db.ext().peekPersisted(news, 2, true);
      if (oldNews == null) {
        changedNews.add(news);
      }
      else if (!news.isIdentical(oldNews)) {
        ModelEvent newsEventTemplate = new NewsEvent(oldNews, news, false);
View Full Code Here

   
    removeFromItemsBeingDeleted(feed);
  }

  private void removeFromParentNews(IAttachment attachment) {
    INews news = attachment.getNews();
    news.removeAttachment(attachment);
    fDb.set(news);
  }
View Full Code Here

  }

  private ModelEvent createNewsEvent(INews news, ModelEvent template, boolean root) {
    ModelEvent modelEvent;
    NewsEvent newsTemplate = (NewsEvent) template;
    INews oldNews = newsTemplate == null ? null : newsTemplate.getOldNews();
   
    modelEvent = new NewsEvent(oldNews, news, root);
    return modelEvent;
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.model.types.INews

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.