Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IAttachment


      INews news1 = createNews(feed, "Foo", "http://www.news.com/news1.html", State.READ);
      ICategory news1cat1 = fFactory.createCategory(null, news1);
      news1cat1.setName("apple");
      ILabel label1 = fFactory.createLabel(null, "work");
      news1.addLabel(label1);
      IAttachment att1news1 = fFactory.createAttachment(null, news1);
      att1news1.setLink(new URI("http://www.attachment.com/att1news1.file"));
      att1news1.setType("bin/mp3");

      INews news2 = createNews(feed, " Bar", "http://www.news.com/news2.html", State.NEW);
      news2.setRating(10);
      ICategory news2cat1 = fFactory.createCategory(null, news2);
      news2cat1.setName("apple");
      ICategory news2cat2 = fFactory.createCategory(null, news2);
      news2cat2.setName("windows");
      ILabel label2 = fFactory.createLabel(null, "todo");
      news2.addLabel(label2);
      IAttachment att1news2 = fFactory.createAttachment(null, news2);
      att1news2.setLink(new URI("http://www.attachment.com/att1news2.file"));
      att1news2.setType("bin/doc");
      IAttachment att2news2 = fFactory.createAttachment(null, news2);
      att2news2.setLink(new URI("http://www.attachment.com/att2news2.file"));
      att2news2.setType("bin/wav");

      INews news3 = createNews(feed, "Foo Bar", "http://www.news.com/news3.html", State.NEW);
      IPerson author3 = fFactory.createPerson(null, news3);
      author3.setName("Benjamin Pasero");
      ICategory news3cat1 = fFactory.createCategory(null, news3);
View Full Code Here


      INews news1 = createNews(feed, "Foo", "http://www.news.com/news1.html", State.READ);
      ICategory news1cat1 = fFactory.createCategory(null, news1);
      news1cat1.setName("apple");
      ILabel label1 = fFactory.createLabel(null, "work");
      news1.addLabel(label1);
      IAttachment att1news1 = fFactory.createAttachment(null, news1);
      att1news1.setLink(new URI("http://www.attachment.com/att1news1.file"));
      att1news1.setType("bin/mp3 Pasero");

      INews news2 = createNews(feed, " Bar", "http://www.news.com/news2.html", State.NEW);
      news2.setRating(10);
      ICategory news2cat1 = fFactory.createCategory(null, news2);
      news2cat1.setName("apple");
      ICategory news2cat2 = fFactory.createCategory(null, news2);
      news2cat2.setName("pasero");
      ILabel label2 = fFactory.createLabel(null, "todo");
      news2.addLabel(label2);
      IAttachment att1news2 = fFactory.createAttachment(null, news2);
      att1news2.setLink(new URI("http://www.attachment.com/att1news2.file"));
      att1news2.setType("bin/doc");
      IAttachment att2news2 = fFactory.createAttachment(null, news2);
      att2news2.setLink(new URI("http://www.attachment.com/att2news2.file"));
      att2news2.setType("bin/wav");

      INews news3 = createNews(feed, "Foo Bar Pasero", "http://www.news.com/news3.html", State.NEW);
      IPerson author3 = fFactory.createPerson(null, news3);
      author3.setName("Benjamin Pasero");
      ICategory news3cat1 = fFactory.createCategory(null, news3);
View Full Code Here

    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
        public void entitiesAdded(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            attachmentEvents[0] = true;
          }
        }

        @Override
        public void entitiesDeleted(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (attachmentReference[0].references(event.getEntity()))
              attachmentEvents[1] = true;
          }
        }

        @Override
        public void entitiesUpdated(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (attachmentReference[0].references(event.getEntity()))
              attachmentEvents[2] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(IAttachment.class, attachmentListener);
      attachmentReference[0] = new AttachmentReference(DynamicDAO.save(attachment).getId());

      /* Update */
      attachment = attachmentReference[0].resolve();
      attachment.setType("MP3");
      DynamicDAO.save(attachment);

      /* Delete */
      DynamicDAO.delete(attachmentReference[0].resolve());

View Full Code Here

      assertEquals(true, news.getProperty("Boolean"));
      assertEquals(2.2D, news.getProperty("Double"));
      assertEquals(3.3F, news.getProperty("Float"));

      /* Add Properties to an Attachment */
      IAttachment attachment = fFactory.createAttachment(null, newsRef.resolve());
      attachment.setLink(new URI("http://www.attachment.com"));
      attachment.setProperty("String", "Foo");
      attachment.setProperty("Integer", 1);
      attachment.setProperty("Boolean", true);
      attachment.setProperty("Double", 2.2D);
      attachment.setProperty("Float", 3.3F);
      AttachmentReference attachmentRef = new AttachmentReference(DynamicDAO.save(attachment).getId());
      attachment = attachmentRef.resolve();
      assertEquals("Foo", attachment.getProperty("String"));
      assertEquals(1, attachment.getProperty("Integer"));
      assertEquals(true, attachment.getProperty("Boolean"));
      assertEquals(2.2D, attachment.getProperty("Double"));
      assertEquals(3.3F, attachment.getProperty("Float"));

    } catch (PersistenceException e) {
      TestUtils.fail(e);
    }
  }
View Full Code Here

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

    INews news = feed.getNews().get(0);
    assertEquals(1, news.getAttachments().size());
    IAttachment attachment = news.getAttachments().get(0);
    assertEquals("http://blip.tv/file/get/NostalgiaCritic-HercNYBMB104.FLV", attachment.getLink().toString());
    assertEquals("video/x-flv", attachment.getType());
    assertEquals(162018262, attachment.getLength());

    news = feed.getNews().get(1);
    assertEquals(2, news.getAttachments().size());
    IAttachment attachment1 = news.getAttachments().get(0);
    IAttachment attachment2 = news.getAttachments().get(1);

    assertEquals("http://blip.tv/file/get/NostalgiaCritic-BimbosBCCrossover552.wmv", attachment1.getLink().toString());
    assertEquals("video/ms-wmv", attachment1.getType());
    assertEquals(434020795, attachment1.getLength());

    assertEquals("http://blip.tv/file/get/NostalgiaCritic-BimbosBCCrossover785.m4v", attachment2.getLink().toString());
    assertEquals("video/x-m4v", attachment2.getType());
    assertEquals(217916291, attachment2.getLength());
  }
View Full Code Here

    assertEquals("bpasero", news1.getAuthor().getName());
    assertEquals("RSSOwl 2.1 Beta available", news1.getTitle());
    assertEquals(1308564626000l, news1.getPublishDate().getTime());

    assertEquals(1, news1.getAttachments().size());
    IAttachment attachment = news1.getAttachments().get(0);
    assertEquals("http://feedproxy.google.com/~r/astronomycast/~5/4TPW83-0h4Y/AstroCast-090921.mp3", attachment.getLink().toString());
    assertEquals("audio/mpeg", attachment.getType());
    assertEquals(17610000, attachment.getLength());

    assertEquals(2, news1.getCategories().size());
    assertEquals("Test 123", news1.getCategories().get(0).getName());
    assertEquals("Foo Bar", news1.getCategories().get(1).getName());
View Full Code Here

    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);
    try {
      DynamicDAO.saveAll(newsList);
View Full Code Here

    if (item.has(ENCLOSURE)) {
      JSONArray attachments = item.getJSONArray(ENCLOSURE);
      for (int i = 0; i < attachments.length(); i++) {
        JSONObject attachment = attachments.getJSONObject(i);
        if (attachment.has(HREF)) {
          IAttachment att = factory.createAttachment(null, news);
          att.setLink(new URI(attachment.getString(HREF)));

          if (attachment.has(LENGTH)) {
            try {
              att.setLength(attachment.getInt(LENGTH));
            } catch (JSONException e) {
              // Can happen if the length is larger than Integer.MAX_VALUE, in that case just ignore
            }
          }

          if (attachment.has(TYPE))
            att.setType(attachment.getString(TYPE));
        }
      }
    }

    /* Categories / Labels / State */
 
View Full Code Here

        attachmentLength = StringUtils.stringToInt(attribute.getValue());
    }

    /* Create Attachment only if valid */
    if (attachmentUri != null && !CoreUtils.hasAttachment(news, attachmentUri)) {
      IAttachment attachment = Owl.getModelFactory().createAttachment(null, news);
      attachment.setLink(attachmentUri);
      if (StringUtils.isSet(attachmentType))
        attachment.setType(attachmentType);
      if (attachmentLength != -1)
        attachment.setLength(attachmentLength);
    }
  }
View Full Code Here

        attachmentLength = StringUtils.stringToInt(attribute.getValue());
    }

    /* Create Attachment only if valid */
    if (attachmentUri != null && !CoreUtils.hasAttachment(news, attachmentUri)) {
      IAttachment attachment = Owl.getModelFactory().createAttachment(null, news);
      attachment.setLink(attachmentUri);
      if (StringUtils.isSet(attachmentType))
        attachment.setType(attachmentType);
      if (attachmentLength != -1)
        attachment.setLength(attachmentLength);

      /* Check wether this Attribute is to be processed by a Contribution */
      for (Iterator<?> iter = attachmentAttributes.iterator(); iter.hasNext();) {
        Attribute attribute = (Attribute) iter.next();
        processAttributeExtern(attribute, attachment);
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IAttachment

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.