Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.INews


  @Test
  public void testSaveNewsSetsCurrentAndOldState() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news = fFactory.createNews(null, feed, new Date());
    news.setTitle("News Title #1");
    news.setLink(new URI("http://www.link.com"));
    news.setState(INews.State.UNREAD);

    final ICategory category = fFactory.createCategory(null, news);
    category.setName("Category name");

    final IAttachment attachment = fFactory.createAttachment(null, news);
    attachment.setLink(new URI("http://attachment.com"));

    feed = DynamicDAO.save(feed);

    final INews savedNews = feed.getNews().get(0);
    savedNews.setTitle("News Title Updated #1");

    Collection<INews> newsList = new ArrayList<INews>();
    newsList.add(savedNews);

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(true, event.getEntity().equals(savedNews));
        INews oldNews = event.getOldNews();
        assertEquals(State.UNREAD, oldNews.getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
        assertEquals(category.getName(), oldNews.getCategories().get(0).getName());
        IAttachment oldAttachment = oldNews.getAttachments().get(0);
        assertEquals(attachment.getLink(), oldAttachment.getLink());
        assertNull(oldAttachment.getNews());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
View Full Code Here


        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);
View Full Code Here

      feed.getUpdatePeriod();
      feed.getWebmaster();
    }

    else if (type instanceof INews) {
      INews news = (INews) type;
      news.getBase();
      news.getComments();
      news.getDescription();
      news.getLink();
      news.getModifiedDate();
      news.getPublishDate();
      news.getRating();
      news.getReceiveDate();
      news.getState();
      news.getTitle();
    }

    else if (type instanceof IAttachment) {
      IAttachment attachment = (IAttachment) type;
      attachment.getLength();
View Full Code Here

      }
    }
  }

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

    /* Check wether the Attributes are to be processed by a Contribution */
    processNamespaceAttributes(element, feed);

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

      news.setLink(feed.getHomepage());

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

      /* Who */
      else if ("who".equals(name)) { //$NON-NLS-1$
        URI uri = URIUtils.createURI(child.getText());
        if (uri != null) {
          IPerson person = Owl.getModelFactory().createPerson(null, news);
          person.setEmail(uri);
        }
        news.setTitle("Comment from " + child.getText());
      }

      /* Date of the comment */
      else if ("bug_when".equals(name)) { //$NON-NLS-1$ {
        news.setModifiedDate(DateUtils.parseDate(child.getText()));
      }

      /* Text of the comment */
      else if ("thetext".equals(name)) { //$NON-NLS-1$ {
        news.setDescription(child.getText());
      }
    }
  }
View Full Code Here

    /* First check if this rule applies at all */
    if (actualSize <= limit)
      return;

    /* Fill actual items into Array */
    INews newsArray[] = new INews[actualSize];
    int i = 0;
    for (INews news : targetNews) {
      if (!newsToDelete.contains(news)) {
        newsArray[i] = news;
        i++;
View Full Code Here

        processAuthor(child, feed);
    }
  }

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

    /* Check wether the Attributes are to be processed by a Contribution */
    processNamespaceAttributes(element, news);

    /* 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(getContent(child));
        processNamespaceAttributes(child, news);
      }

      /* Content / Summary */
      else if ("content".equals(name) || "summary".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
        news.setDescription(getContent(child));
        processNamespaceAttributes(child, news);
      }

      /* Modified / Updated */
      else if ("modified".equals(name) || "updated".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
        news.setModifiedDate(DateUtils.parseDate(child.getText()));
        processNamespaceAttributes(child, news);
      }

      /* Issued / Created / Published */
      else if ("issued".equals(name) || "created".equals(name) || "published".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        news.setPublishDate(DateUtils.parseDate(child.getText()));
        processNamespaceAttributes(child, news);
      }

      /* Id */
      else if ("id".equals(name)) { //$NON-NLS-1$
        IGuid guid = Owl.getModelFactory().createGuid(news, child.getText());

        processNamespaceAttributes(child, guid);
      }

      /* Link */
      else if ("link".equals(name)) { //$NON-NLS-1$
        String rel = child.getAttributeValue("rel"); //$NON-NLS-1$

        /* News Link */
        if (rel == null || "alternate".equals(rel)) {//$NON-NLS-1$
          URI uri = URIUtils.createURI(child.getAttributeValue("href")); //$NON-NLS-1$
          if (uri != null)
            news.setLink(uri);
          processNamespaceAttributes(child, news);
        }

        /* Enclosure */
        else if ("enclosure".equals(rel)) { //$NON-NLS-1$
View Full Code Here

    /* Group Input */
    int nextId = Group.NO_TOPIC.ordinal() + TITLE_ID_BEGIN;
    for (Object object : input) {
      if (object instanceof INews) {
        INews news = (INews) object;
        EntityGroup group = gDefault;

        /* Normalize Title */
        String normalizedTitle = ModelUtils.getHeadline(news);
        normalizedTitle = ModelUtils.normalizeTitle(normalizedTitle);

        /* Determine Group ID */
        String groupId;
        if (StringUtils.isSet(news.getInReplyTo()))
          groupId = news.getInReplyTo();
        else
          groupId = normalizedTitle;

        /* Add or Create Group */
        if (StringUtils.isSet(groupId)) {
View Full Code Here

    fFactory.createBookMark(null, folder, new FeedLinkReference(feed.getLink()), "BookMark");

    DynamicDAO.save(folder);

    /* Add unpersisted News */
    INews news1 = fFactory.createNews(null, feed, new Date());
    news1.setTitle("News #1");
    news1.setState(INews.State.READ);
    INews news2 = fFactory.createNews(null, feed, new Date());
    news2.setTitle("News #2");
    news2.setPublishDate(new Date(today - 7 * DAY));
    fFactory.createNews(null, feed, new Date()).setTitle("News #3");

    IBookMark bookmark = (IBookMark) folder.getMarks().get(0);
    assertEquals(103, countNews(feed));

View Full Code Here

    EntityGroup gNotSticky = new EntityGroup(Group.NOT_STICKY.ordinal(), GROUP_CATEGORY_ID, Group.NOT_STICKY.getName());

    /* Group Input */
    for (Object object : input) {
      if (object instanceof INews) {
        INews news = (INews) object;

        /* Sticky */
        if (news.isFlagged())
          new EntityGroupItem(gSticky, news);

        /* Not Sticky */
        else
          new EntityGroupItem(gNotSticky, news);
View Full Code Here

    /* Group Input */
    int nextId = 0;
    for (Object object : input) {
      if (object instanceof INews) {
        INews news = (INews) object;
        IFeed feed = news.getFeedReference().resolve();

        EntityGroup group = groupCache.get(feed.getId());

        if (group == null) {
          String name = StringUtils.isSet(feed.getTitle()) ? feed.getTitle() : feed.getLink().toString();
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.