Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INews


        processItem(child, feed);
    }
  }

  private void processItem(Element element, IFeed feed) {
    INews news = Owl.getModelFactory().createNews(null, feed, new Date(System.currentTimeMillis() - (fNewsCounter++ * 1)));

    String baseUrl = feed.getHomepage() != null ? feed.getHomepage().toString() : ""; //$NON-NLS-1$

    /* Interpret Attributes */
    List< ? > itemAttributes = element.getAttributes();
    for (Iterator< ? > iter = itemAttributes.iterator(); iter.hasNext();) {
      Attribute attribute = (Attribute) iter.next();
      String name = attribute.getName().toLowerCase();

      /* Check wether this Attribute is to be processed by a Contribution */
      if (processAttributeExtern(attribute, news))
        continue;

      /* Last Modificated */
      else if ("lastmod".equals(name)) //$NON-NLS-1$
        news.setPublishDate(DateUtils.parseDate(attribute.getValue()));

      /* Href - Append with Feed-Base */
      else if ("href".equals(name)) { //$NON-NLS-1$
        URI uri = URIUtils.createURI(baseUrl + attribute.getValue());
        if (uri != null)
          news.setLink(uri);
      }
    }

    /* Interpret Children */
    List< ? > newsChilds = element.getChildren();
    for (Iterator< ? > iter = newsChilds.iterator(); iter.hasNext();) {
      Element child = (Element) iter.next();
      String name = child.getName().toLowerCase();

      /* Check wether this Element is to be processed by a Contribution */
      if (processElementExtern(child, news))
        continue;

      /* Title */
      else if ("title".equals(name)) { //$NON-NLS-1$
        news.setTitle(child.getText());
        processNamespaceAttributes(child, news);
      }

      /* Abstract */
      else if ("abstract".equals(name)) { //$NON-NLS-1$
        news.setDescription(child.getText());
        processNamespaceAttributes(child, news);
      }
    }
  }
View Full Code Here


   * delete the feed.
   */
  @Test
  public void testDeleteBookMarkWithNewsCopies() {
    IFeed feed = createFeed();
    INews news = fTypesFactory.createNews(null, feed, new Date());
    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);

    DynamicDAO.delete(bookMark);
    feed = DynamicDAO.load(IFeed.class, feed.getId());
View Full Code Here

   * in a INewsBin works.
   */
  @Test
  public void testQueryNewsOnIsCopy() {
    IFeed feed = createFeed();
    INews news = fTypesFactory.createNews(null, feed, new Date());
    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);

    Query query = fDb.query();
    query.constrain(News.class);
View Full Code Here

   * Tests that deleting a news bin deletes the internal news container too.
   */
  @Test
  public void testDeleteNewsBinDeletesNewsContainer() {
    IFeed feed = createFeed();
    INews news = fTypesFactory.createNews(null, feed, new Date());
    DynamicDAO.save(feed);

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

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

    /* Ensure that arrays are treated specially by db4o, don't need to delete them manually */
    assertFalse(fDb.ext().isStored(bin.internalGetNewsContainer().internalGetNewsIds()));
View Full Code Here

    return category;
  }

  private ICategory createNewsCategory() throws PersistenceException {
    IFeed feed = DynamicDAO.save(createFeed());
    INews news = DynamicDAO.save(createNews(feed));
    ICategory category = fTypesFactory.createCategory(null, news);
    category.setName("categoryName");
    category.setDomain("some/domain");
    category.setProperty("one_property", "value");
    return category;
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testNewsMergeLink() throws Exception {
    IFeed feed = DynamicDAO.save(createFeed());
    INews news = fTypesFactory.createNews(null, feed, new Date());
    news.setId(1L);
    news.setLink(createURI("http://www.uri.com"));

    INews anotherNews = fTypesFactory.createNews(null, feed, new Date());
    URI uri = createURI("http://www.anotheruri.com");
    anotherNews.setLink(uri);

    news.merge(anotherNews);

    assertEquals(uri, news.getLink());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testNewsSetLink() throws Exception {
    IFeed feed = DynamicDAO.save(createFeed());
    INews news = fTypesFactory.createNews(null, feed, new Date());
    URI uri = createURI("http://uri.com");
    news.setLink(uri);
    assertEquals(uri, news.getLink());
    news.setLink(null);
    assertNull(news.getLink());
    news.setLink(uri);
    assertEquals(uri, news.getLink());
    URI anotherUri = createURI("http://anotheruri.com");
    news.setLink(anotherUri);

    assertEquals(anotherUri, news.getLink());
  }
View Full Code Here

   */
  @Test
  public void testDeleteNews() throws PersistenceException {
    IFeed feed = createFeed();
    feed = DynamicDAO.save(feed);
    INews news = createNews(feed);
    news = DynamicDAO.save(news);
    Long newsId = news.getId();
    DynamicDAO.delete(new NewsReference(newsId).resolve());
    feed = DynamicDAO.load(IFeed.class, feed.getId());
    assertEquals(0, feed.getNews().size());
    assertNull(DynamicDAO.load(INews.class, newsId));
  }
View Full Code Here

  @Test
  public void testAddAttachmentToNewsAfterGC() {
    NewsListener newsListener = null;
    try {
      IFeed feed = createFeed();
      INews news = createNews(feed);
      List<IAttachment> attachments = new ArrayList<IAttachment>(news.getAttachments());
      for (IAttachment attachment : attachments)
        news.removeAttachment(attachment);

      DynamicDAO.save(feed);
      NewsReference newsRef = new NewsReference(feed.getNews().get(0).getId());
      fTypesFactory.createAttachment(null, news);
      DynamicDAO.save(feed);
View Full Code Here

          News dbNews = (News) event.getEntity();
          assertTrue(updatedNews[0].isIdentical(dbNews));
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);
      INews news = DynamicDAO.save(initialNews);
      news.setDescription("The description has been changed in the news");
      news.setState(State.UNREAD);
      updatedNews[0] = (News) news;
      DynamicDAO.save(news);
      assertTrue(NewsAddedCalled[0]);
      assertTrue(NewsUpdatedCalled[0]);
      DynamicDAO.delete(updatedNews[0]);
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.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.